PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/extensions/content-extensions.php

https://github.com/envex/Micro-Theme
PHP | 1008 lines | 291 code | 84 blank | 633 comment | 40 complexity | d38474c42824aa3db5b886a5d75311f2 MD5 | raw file
  1. <?php
  2. /**
  3. * Theme Content Extension Functions file
  4. *
  5. * The /inc/extensions/content-extensions.php file defines
  6. * all of the Theme's callback functions that hook into
  7. * Theme custom and WordPress action/filter hooks in content.php,
  8. * content-page.php, and content-single.php
  9. * - micro_post_footer
  10. * - micro_post_header
  11. * - micro_postmeta
  12. * - the_content
  13. *
  14. * This file also defines content-related custom functions:
  15. * - micro_author_details()
  16. * - micro_gallery()
  17. * - micro_image_grid()
  18. * - micro_image_list()
  19. * - micro_image_slider()
  20. * - micro_no_posts()
  21. * - micro_post_images()
  22. * - micro_time_posted()
  23. *
  24. * @link http://codex.wordpress.org/Function_Reference/add_action add_action()
  25. *
  26. * @package Micro
  27. * @copyright Copyright (c) 2011, UpThemes
  28. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
  29. *
  30. * @since Micro 1.0
  31. */
  32. /**
  33. * Output Author Details
  34. *
  35. * Outputs "Posted by {Author Name}", where
  36. * {Author Name} is linked to the author's
  37. * archive index page.
  38. *
  39. * The micro_author_details() function is called
  40. * by the micro_author_meta() function.
  41. *
  42. * The micro_author_meta() function is defined
  43. * in /inc/extensions/content-extensions.php and
  44. * is hooked into the micro_postmeta hook, which is
  45. * fired inside the micro_postmeta() function.
  46. *
  47. * The micro_postmeta() function is defined
  48. * in /inc/extensions/content-extensions.php and
  49. * is called inside the micro_showmeta() function.
  50. *
  51. * The micro_showmeta() function is defined
  52. * in /inc/extensions/content-extensions.php and
  53. * is hooked into the micro_post_footer hook, which
  54. * is fired in the content.php and content-single.php
  55. * template files.
  56. *
  57. * Template file: content.php, content-single.php
  58. *
  59. * @link http://codex.wordpress.org/Function_Reference/the_author_posts_link the_author_posts_link()
  60. *
  61. * @param none
  62. * @return type description
  63. *
  64. * @since Micro 1.0
  65. *
  66. */
  67. function micro_author_details() {
  68. echo '<div class="author">' . __( "Posted by", "micro" ) . " ";
  69. the_author_posts_link();
  70. echo '</div>';
  71. }
  72. /**
  73. * Output Post Timestamp Details
  74. *
  75. * Outputs a timestamped post permalink,
  76. * using either a human-readable time
  77. * difference or a date/time string,
  78. * depending on Theme setting.
  79. *
  80. * The micro_time_posted() function is called
  81. * by the micro_time_meta() function.
  82. *
  83. * The micro_time_meta() function is defined
  84. * in /inc/extensions/content-extensions.php and
  85. * is hooked into the micro_postmeta hook, which is
  86. * fired inside the micro_postmeta() function.
  87. *
  88. * The micro_postmeta() function is defined
  89. * in /inc/extensions/content-extensions.php and
  90. * is called inside the micro_showmeta() function.
  91. *
  92. * The micro_showmeta() function is defined
  93. * in /inc/extensions/content-extensions.php and
  94. * is hooked into the micro_post_footer hook, which
  95. * is fired in the content.php and content-single.php
  96. * template files.
  97. *
  98. * Template file: content.php, content-single.php
  99. *
  100. * @link http://codex.wordpress.org/Function_Reference/get_permalink get_permalink()
  101. * @link http://codex.wordpress.org/Function_Reference/human_time_diff human_time_diff()
  102. * @link http://codex.wordpress.org/Function_Reference/get_the_time get_the_time()
  103. * @link http://codex.wordpress.org/Function_Reference/the_time the_time()
  104. *
  105. * @link http://php.net/manual/en/function.time.php time()
  106. *
  107. * @param none
  108. * @return string Markup for post timestamp metadata
  109. *
  110. * @since Micro 1.0
  111. *
  112. */
  113. function micro_time_posted() {
  114. global $up_options, $post;?>
  115. <div class="post-date">
  116. <?php
  117. if( 'human' == $up_options->showtime_format ):
  118. echo '<a href="' . get_permalink( $post->ID ) . '">' . human_time_diff( get_the_time( 'U' ), time() ) . ' ago</a>';
  119. else:
  120. echo '<a href="' . get_permalink( $post->ID ) . '">';
  121. the_time( get_option( 'time_format' ) );
  122. echo '</a>';
  123. endif;?>
  124. </div>
  125. <?php
  126. }
  127. /**
  128. * Output Default Post Content
  129. *
  130. * Outputs error message when no posts are
  131. * found/returned by the current query.
  132. *
  133. * The micro_no_posts() function is called
  134. * in the content.php, content-page.php, and
  135. * content-single.php template files.
  136. *
  137. * Template file: content.php, content-page.php, content-single.php
  138. *
  139. * @link http://codex.wordpress.org/Function_Reference/_e _e()
  140. *
  141. * @param none
  142. * @return string Markup for error message output when no posts found
  143. *
  144. * @since Micro 1.0
  145. *
  146. */
  147. function micro_no_posts(){ ?>
  148. <li>
  149. <h1><?php _e( "No Posts Found.", "micro" ); ?></h1>
  150. <p><?php _e( "There were no posts found. Please try back later.", "micro" ); ?></p>
  151. <div class="clear"></div>
  152. </li>
  153. <?php }
  154. /**
  155. * Return Gallery Post Content
  156. *
  157. * Returns gallery post content for posts with
  158. * the Post Format type "Gallery". The function
  159. * returns different markup for gallery lists,
  160. * gallery grids, or gallery sliders, depending
  161. * on the post meta data gallery style setting.
  162. *
  163. * The micro_gallery() function is called within
  164. * the micro_content() function, which is hooked
  165. * into the_content filter hook, which is applied
  166. * in the the_content() template tag.
  167. *
  168. * The the_content() template tag is called in the
  169. * content.php, content-page, and content-single.php
  170. * template files.
  171. *
  172. * Template file: content.php, content-page.php, content-single.php
  173. *
  174. * @uses micro_image_grid() Defined in /inc/extensions/content-extensions.php
  175. * @uses micro_image_list() Defined in /inc/extensions/content-extensions.php
  176. * @uses micro_image_slider() Defined in /inc/extensions/content-extensions.php
  177. * @uses micro_post_images() Defined in /inc/extensions/content-extensions.php
  178. *
  179. * @link http://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()
  180. *
  181. * @link http://php.net/manual/en/function.is-array.php is_array()
  182. *
  183. * @param none
  184. * @return string Markup for post gallery content
  185. *
  186. * @since Micro 1.0
  187. *
  188. */
  189. function micro_gallery() {
  190. global $post;
  191. $output = '';
  192. $images = micro_post_images();
  193. $style = get_post_meta( $post->ID, 'gallery', true );
  194. if( is_array( $images ) ) :
  195. switch( $style ):
  196. case 'slider':
  197. $output = micro_image_slider( $images );
  198. break;
  199. case 'grid':
  200. $output = micro_image_grid( $images );
  201. break;
  202. case 'list':
  203. $output = micro_image_list( $images );
  204. break;
  205. endswitch;
  206. else:
  207. return false;
  208. endif;
  209. return $output;
  210. }
  211. /**
  212. * Return Array of Post Images
  213. *
  214. * Returns an indexed array of associative arrays of
  215. * attached post images, indexed by attachment id.
  216. *
  217. * The micro_post_images() function is called by the
  218. * micro_gallery() function.
  219. *
  220. * The micro_gallery() function is called by the
  221. * micro_content() function, which is hooked into
  222. * the the_content filter hook, which is applied
  223. * in the the_content() template tag.
  224. *
  225. * The the_content() template tag is called in the
  226. * content.php, content-page, and content-single.php
  227. * template files.
  228. *
  229. * Template files: content.php, content-page.php, content-single.php
  230. *
  231. * @link http://codex.wordpress.org/Function_Reference/get_children get_children()
  232. * @link http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src wp_get_attachment_image_src()
  233. *
  234. * @link http://php.net/manual/en/function.is-array.php is_array()
  235. *
  236. * @param none
  237. * @return array Array of array of image attachments
  238. *
  239. * @since Micro 1.0
  240. *
  241. */
  242. function micro_post_images(){
  243. global $post, $content_width;
  244. $post_id = $post->ID;
  245. $images = get_children( 'post_parent=' . $post_id . '&showposts=99999post_type=attachment&post_mime_type=image&order=ASC&orderby=menu_order' );
  246. if( is_array( $images ) ):
  247. foreach( $images as $image ):
  248. $thumb = wp_get_attachment_image_src( $image->ID, 'thumbnail' );
  249. $medium = wp_get_attachment_image_src( $image->ID, 'full-width-image' );
  250. $full = wp_get_attachment_image_src( $image->ID, 'large' );
  251. $contentwidth = wp_get_attachment_image_src( $image->ID, array($content_width,99999) );
  252. $post_images[$image->ID]['thumb'] = $thumb[0];
  253. $post_images[$image->ID]['medium'] = $medium[0];
  254. $post_images[$image->ID]['full'] = $full[0];
  255. $post_images[$image->ID]['contentwidth'] = $contentwidth[0];
  256. endforeach;
  257. endif;
  258. return $post_images;
  259. }
  260. /**
  261. * Return Grid-Style Gallery
  262. *
  263. * Returns markup for a grid-style image gallery.
  264. *
  265. * The micro_image_grid() function is called by the
  266. * micro_gallery() function.
  267. *
  268. * The micro_gallery() function is called by the
  269. * micro_content() function, which is hooked into
  270. * the the_content filter hook, which is applied
  271. * in the the_content() template tag.
  272. *
  273. * The the_content() template tag is called in the
  274. * content.php, content-page, and content-single.php
  275. * template files.
  276. *
  277. * Template files: content.php, content-page.php, content-single.php
  278. *
  279. * @link http://codex.wordpress.org/Function_Reference/wp_rand wp_rand()
  280. * @link http://codex.wordpress.org/Function_Reference/get_the_title get_the_title()
  281. *
  282. * @param none
  283. * @return string Markup for grid-style image gallery
  284. *
  285. * @since Micro 1.0
  286. *
  287. */
  288. function micro_image_grid( $images ){
  289. $output = '<div class="gallery-grid">';
  290. $rand = wp_rand( 0, 999999 );
  291. $count;
  292. foreach( $images as $id => $image ) :
  293. $count++;
  294. $class = $count === 4 ? 'last view' : ' view';
  295. $title = get_the_title( $id );
  296. $output .= "<a class='$class' rel='grid-$rand' title='$title' href='{$image['full']}'><img src='{$image['medium']}' alt='$title' /></a>";
  297. $count = $count === 4 ? 0 : $count;
  298. endforeach;
  299. $output .= '<div class="clear"></div>';
  300. $output .= '</div>';
  301. return $output;
  302. }
  303. /**
  304. * Return List-Style Gallery
  305. *
  306. * Returns markup for a list-style image gallery.
  307. *
  308. * The micro_image_list() function is called by the
  309. * micro_gallery() function.
  310. *
  311. * The micro_gallery() function is called by the
  312. * micro_content() function, which is hooked into
  313. * the the_content filter hook, which is applied
  314. * in the the_content() template tag.
  315. *
  316. * The the_content() template tag is called in the
  317. * content.php, content-page, and content-single.php
  318. * template files.
  319. *
  320. * Template files: content.php, content-page.php, content-single.php
  321. *
  322. * @link http://codex.wordpress.org/Function_Reference/wp_rand wp_rand()
  323. * @link http://codex.wordpress.org/Function_Reference/get_the_title get_the_title()
  324. *
  325. * @param none
  326. * @return string Markup for list-style image gallery
  327. *
  328. * @since Micro 1.0
  329. *
  330. */
  331. function micro_image_list( $images ){
  332. $output = '<div class="gallery-list">';
  333. $rand = wp_rand( 0, 999999 );
  334. foreach( $images as $id => $image ):
  335. $title = get_the_title( $id );
  336. $output .= "<a class='view' rel='grid-$rand' title='$title' href='{$image['full']}'><img src='{$image['contentwidth']}' alt='$title' /></a>";
  337. endforeach;
  338. $output .= '</div>';
  339. return $output;
  340. }
  341. /**
  342. * Return Slider-Style Gallery
  343. *
  344. * Returns markup for a slider-style image gallery.
  345. *
  346. * The micro_image_slider() function is called by the
  347. * micro_gallery() function.
  348. *
  349. * The micro_gallery() function is called by the
  350. * micro_content() function, which is hooked into
  351. * the the_content filter hook, which is applied
  352. * in the the_content() template tag.
  353. *
  354. * The the_content() template tag is called in the
  355. * content.php, content-page, and content-single.php
  356. * template files.
  357. *
  358. * Template files: content.php, content-page.php, content-single.php
  359. *
  360. * @link http://codex.wordpress.org/Function_Reference/wp_rand wp_rand()
  361. * @link http://codex.wordpress.org/Function_Reference/get_the_title get_the_title()
  362. *
  363. * @param none
  364. * @return string Markup for slider-style image gallery
  365. *
  366. * @since Micro 1.0
  367. *
  368. */
  369. function micro_image_slider( $images ){
  370. $rand = wp_rand( 0, 999999 );
  371. $output = '
  372. <div class="flex-container">
  373. <div class="flexslider">
  374. <ul class="slides">';
  375. foreach( $images as $id => $image ):
  376. $title = get_the_title( $id );
  377. $output .= "<li><a class='view' title='$title' rel='grid-$rand' href='{$image['full']}'><img src='{$image['contentwidth']}' alt='$title' /></a></li>";
  378. endforeach;
  379. $output .= '
  380. </ul>
  381. </div>
  382. </div>
  383. ';
  384. return $output;
  385. }
  386. /**
  387. * Output Post Title
  388. *
  389. * Outputs the post title content, including
  390. * Post Format icons and the Post Title. Two
  391. * custom action hooks, micro_before_title and
  392. * micro_after_title, are fired inside this
  393. * function.
  394. *
  395. * The micro_post_title() function is hooked
  396. * into the micro_post_header hook, which is
  397. * fired inside the micro_post_header() function.
  398. *
  399. * The micro_post_header() function is defined
  400. * in /inc/hooks.php and is fired in the
  401. * content.php, content-page.php, and
  402. * content-single.php template files.
  403. *
  404. * Template file: content.php, content-page.php, content-single.php
  405. *
  406. * Child Themes can remove this output by calling
  407. * remove_action( 'micro_post_header', 'micro_post_title', 600 );
  408. *
  409. * @uses micro_after_title() Defined in /inc/hooks.php
  410. * @uses micro_before_title() Defined in /inc/hooks.php
  411. *
  412. * @link http://codex.wordpress.org/Function_Reference/get_permalink get_permalink()
  413. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  414. * @link http://codex.wordpress.org/Function_Reference/get_post_format_link get_post_format_link()
  415. * @link http://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()
  416. * @link http://codex.wordpress.org/Function_Reference/get_post_type get_post_type()
  417. * @link http://codex.wordpress.org/Function_Reference/get_the_ID get_the_ID()
  418. * @link http://codex.wordpress.org/Function_Reference/get_the_title get_the_title()
  419. * @link http://codex.wordpress.org/Function_Reference/is_singular is_singular()
  420. *
  421. * @link http://php.net/manual/en/function.in-array.php in_array()
  422. * @link http://php.net/manual/en/function.isset.php isset()
  423. *
  424. * @param none
  425. * @return string HTML markup for post title
  426. *
  427. * @since Micro 1.0
  428. *
  429. */
  430. function micro_post_title(){
  431. global $post, $up_options;
  432. micro_before_title();
  433. $postformat = get_post_format();
  434. $postformat = $postformat ? $postformat : 'standard';
  435. if( get_post_type() == 'post' ):
  436. /* Post Icons */
  437. $post_icon_pref = ( isset( $up_options->post_format_icon ) ? $up_options->post_format_icon : 'left' );
  438. $post_icon_pref = 'icon-' . $post_icon_pref;
  439. $post_icon_link = ( get_post_format() ? get_post_format_link( get_post_format() ) : home_url( '/' ) );
  440. if( ! $postformat || $postformat == 'aside' || $postformat == 'status' || $postformat == 'link' || ( isset( $up_options->showtitle ) && in_array( $postformat, $up_options->showtitle ) ) ) : ?>
  441. <div class="post-type <?php echo $post_icon_pref;?>">
  442. <a href="<?php echo $post_icon_link; ?>"><?php echo $post->ID; ?></a>
  443. </div>
  444. <?php
  445. endif;
  446. endif;
  447. /* Post Title */
  448. $url = get_post_meta( get_the_ID(), 'link-url', true );
  449. $url = $url ? $url : get_permalink();
  450. $title = get_post_meta( get_the_ID(), 'link-text', true );
  451. $title = $title ? $title . " &#8594;" : get_the_title();
  452. if( !$postformat || $postformat == 'aside' || $postformat == 'status' || $postformat == 'link' || ( isset( $up_options->showtitle ) && in_array( $postformat, $up_options->showtitle ) ) ):
  453. if( ( $url && 'link' == get_post_format() ) || ! is_singular() ): ?>
  454. <h2 class="title"><a href="<?php echo $url; ?>"><?php echo $title; ?></a></h2>
  455. <?php else: ?>
  456. <h1 class="title"><?php echo $title; ?></h1>
  457. <?php endif;
  458. endif;
  459. micro_after_title();
  460. echo "<div class='clear'></div>";
  461. }
  462. // Hook micro_post_title() into micro_post_header action
  463. add_action( 'micro_post_header', 'micro_post_title', 600 );
  464. /**
  465. * Add Post-Before container open tag
  466. *
  467. * Adds opening DIV tag for post-before container
  468. * in the post header.
  469. *
  470. * The micro_open_before_post() function is hooked
  471. * into the micro_post_header hook, which is
  472. * fired inside the micro_post_header() function.
  473. *
  474. * The micro_post_header() function is defined
  475. * in /inc/hooks.php and is fired in the
  476. * content.php, content-page.php, and
  477. * content-single.php template files.
  478. *
  479. * Template file: content.php, content-page.php, content-single.php
  480. *
  481. * Child Themes can remove this output by calling
  482. * remove_action( 'micro_post_header', 'micro_open_before_post', 5 );
  483. *
  484. * Template file: sidebar.php
  485. *
  486. * @param none
  487. * @return string Markup for post-before container open HTML tag
  488. *
  489. * @since Micro 1.0
  490. *
  491. */
  492. function micro_open_before_post(){
  493. echo '<div class="post-before">';
  494. }
  495. // Hook micro_open_before_post() into micro_post_header action
  496. add_action( 'micro_post_header', 'micro_open_before_post', 5 );
  497. /**
  498. * Add Post-Before container close tag
  499. *
  500. * Adds closing DIV tag for post-before container
  501. * in the post header.
  502. *
  503. * The micro_close_before_post() function is hooked
  504. * into the micro_post_header hook, which is
  505. * fired inside the micro_post_header() function.
  506. *
  507. * The micro_post_header() function is defined
  508. * in /inc/hooks.php and is fired in the
  509. * content.php, content-page.php, and
  510. * content-single.php template files.
  511. *
  512. * Template file: content.php, content-page.php, content-single.php
  513. *
  514. * Child Themes can remove this output by calling
  515. * remove_action( 'micro_post_header', 'micro_close_before_post', 500 );
  516. *
  517. * Template file: sidebar.php
  518. *
  519. * @param none
  520. * @return string Markup for post-before container close HTML tag
  521. *
  522. * @since Micro 1.0
  523. *
  524. */
  525. function micro_close_before_post(){
  526. echo '</div>';
  527. }
  528. add_action( 'micro_post_header', 'micro_close_before_post', 500 );
  529. /**
  530. * Output Author Meta
  531. *
  532. * Outputs the author meta data in the post
  533. * footer.
  534. *
  535. * The micro_author_meta() function is hooked
  536. * into the micro_postmeta hook, which is
  537. * fired inside the micro_postmeta() function.
  538. *
  539. * The micro_postmeta() function is defined
  540. * in /inc/extensions/content-extensions.php and
  541. * is called inside the micro_showmeta() function.
  542. *
  543. * The micro_showmeta() function is defined
  544. * in /inc/extensions/content-extensions.php and
  545. * is hooked into the micro_post_footer hook, which
  546. * is fired in the content.php and content-single.php
  547. * template files.
  548. *
  549. * Template file: content.php, content-single.php
  550. *
  551. * Child Themes can remove this output by calling
  552. * remove_action( 'micro_postmeta', 'micro_author_meta' );
  553. *
  554. * @uses micro_author_details() Defined in /inc/extensions/content-extensions.php
  555. *
  556. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  557. *
  558. * @link http://php.net/manual/en/function.in-array.php in_array()
  559. * @link http://php.net/manual/en/function.isset.php isset()
  560. *
  561. * @param none
  562. * @return string Markup for post author metadata
  563. *
  564. * @since Micro 1.0
  565. *
  566. */
  567. function micro_author_meta(){
  568. global $up_options;
  569. $postformat = get_post_format();
  570. $postformat = $postformat ? $postformat : 'standard';
  571. if( isset( $up_options->showmeta ) && in_array( $postformat, $up_options->showmeta ) )
  572. micro_author_details();
  573. }
  574. // Hook micro_author_meta() into micro_postmeta action
  575. add_action( 'micro_postmeta', 'micro_author_meta' );
  576. /**
  577. * Output Post Category Meta Data
  578. *
  579. * Outputs the category meta data in the post
  580. * footer.
  581. *
  582. * The micro_categories_meta() function is hooked
  583. * into the micro_postmeta hook, which is
  584. * fired inside the micro_postmeta() function.
  585. *
  586. * The micro_postmeta() function is defined
  587. * in /inc/extensions/content-extensions.php and
  588. * is called inside the micro_showmeta() function.
  589. *
  590. * The micro_showmeta() function is defined
  591. * in /inc/extensions/content-extensions.php and
  592. * is hooked into the micro_post_footer hook, which
  593. * is fired in the content.php and content-single.php
  594. * template files.
  595. *
  596. * Template file: content.php, content-single.php
  597. *
  598. * Child Themes can remove this output by calling
  599. * remove_action( 'micro_postmeta', 'micro_categories_meta' );
  600. *
  601. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  602. * @link http://codex.wordpress.org/Function_Reference/the_category the_category()
  603. *
  604. * @link http://php.net/manual/en/function.in-array.php in_array()
  605. * @link http://php.net/manual/en/function.isset.php isset()
  606. *
  607. * @param none
  608. * @return string Markup for post categories metadata
  609. *
  610. * @since Micro 1.0
  611. *
  612. */
  613. function micro_categories_meta(){
  614. global $up_options;
  615. $postformat = get_post_format();
  616. $postformat = $postformat ? $postformat : 'standard';
  617. if( isset( $up_options->showcategory ) && in_array( $postformat, $up_options->showcategory ) ) :
  618. echo "<div class='post-category'>".__('Posted in ', 'micro');
  619. the_category(', ');
  620. echo "</div>";
  621. endif;
  622. }
  623. // Hook micro_categories_meta() into micro_postmeta action
  624. add_action( 'micro_postmeta', 'micro_categories_meta' );
  625. /**
  626. * Output Post Date/Time Meta Data
  627. *
  628. * Outputs the date/time meta data in the post
  629. * footer.
  630. *
  631. * The micro_time_meta() function is hooked
  632. * into the micro_postmeta hook, which is
  633. * fired inside the micro_postmeta() function.
  634. *
  635. * The micro_postmeta() function is defined
  636. * in /inc/extensions/content-extensions.php and
  637. * is called inside the micro_showmeta() function.
  638. *
  639. * The micro_showmeta() function is defined
  640. * in /inc/extensions/content-extensions.php and
  641. * is hooked into the micro_post_footer hook, which
  642. * is fired in the content.php and content-single.php
  643. * template files.
  644. *
  645. * Template file: content.php, content-single.php
  646. *
  647. * Child Themes can remove this output by calling
  648. * remove_action( 'micro_postmeta', 'micro_time_meta' );
  649. *
  650. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  651. * @link http://codex.wordpress.org/Function_Reference/the_category the_category()
  652. *
  653. * @link http://php.net/manual/en/function.in-array.php in_array()
  654. * @link http://php.net/manual/en/function.isset.php isset()
  655. *
  656. * @param none
  657. * @return string Markup for post timestamp metadata
  658. *
  659. * @since Micro 1.0
  660. *
  661. */
  662. function micro_time_meta(){
  663. global $up_options;
  664. $postformat = get_post_format();
  665. $postformat = $postformat ? $postformat : 'standard';
  666. if( isset( $up_options->showtime ) && in_array( $postformat, $up_options->showtime ) )
  667. micro_time_posted();
  668. }
  669. add_action( 'micro_postmeta', 'micro_time_meta' );
  670. /**
  671. * Output Post Tags Meta Data
  672. *
  673. * Outputs the post tags meta data in the post
  674. * footer.
  675. *
  676. * The micro_tags_meta() function is hooked
  677. * into the micro_postmeta hook, which is
  678. * fired inside the micro_postmeta() function.
  679. *
  680. * The micro_postmeta() function is defined
  681. * in /inc/extensions/content-extensions.php and
  682. * is called inside the micro_showmeta() function.
  683. *
  684. * The micro_showmeta() function is defined
  685. * in /inc/extensions/content-extensions.php and
  686. * is hooked into the micro_post_footer hook, which
  687. * is fired in the content.php and content-single.php
  688. * template files.
  689. *
  690. * Template file: content.php, content-single.php
  691. *
  692. * Child Themes can remove this output by calling
  693. * remove_action( 'micro_postmeta', 'micro_tags_meta' );
  694. *
  695. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  696. * @link http://codex.wordpress.org/Function_Reference/the_tags the_tags()
  697. *
  698. * @link http://php.net/manual/en/function.in-array.php in_array()
  699. * @link http://php.net/manual/en/function.isset.php isset()
  700. *
  701. * @param none
  702. * @return string Markup for post tags metadata
  703. *
  704. * @since Micro 1.0
  705. *
  706. */
  707. function micro_tags_meta(){
  708. global $up_options;
  709. $postformat = get_post_format();
  710. $postformat = $postformat ? $postformat : 'standard';
  711. if( isset( $up_options->showtag ) && in_array( $postformat, $up_options->showtag ) )
  712. the_tags( '<div class="tags">',' ','</div>' );
  713. }
  714. // Hook micro_tags_meta() into micro_postmeta action
  715. add_action( 'micro_postmeta', 'micro_tags_meta' );
  716. /**
  717. * Output Post Comments Meta Data
  718. *
  719. * Outputs the post comments meta data in the post
  720. * footer.
  721. *
  722. * The micro_comment_meta() function is hooked
  723. * into the micro_postmeta hook, which is
  724. * fired inside the micro_postmeta() function.
  725. *
  726. * The micro_postmeta() function is defined
  727. * in /inc/extensions/content-extensions.php and
  728. * is called inside the micro_showmeta() function.
  729. *
  730. * The micro_showmeta() function is defined
  731. * in /inc/extensions/content-extensions.php and
  732. * is hooked into the micro_post_footer hook, which
  733. * is fired in the content.php and content-single.php
  734. * template files.
  735. *
  736. * Template file: content.php, content-single.php
  737. *
  738. * Child Themes can remove this output by calling
  739. * remove_action( 'micro_postmeta', 'micro_comment_meta' );
  740. *
  741. * @link http://codex.wordpress.org/Function_Reference/_2 __()
  742. * @link http://codex.wordpress.org/Function_Reference/comments_popup_link comments_popup_link()
  743. *
  744. * @param none
  745. * @return string Markup for post comment metadata
  746. *
  747. * @since Micro 1.0
  748. *
  749. */
  750. function micro_comment_meta(){ ?>
  751. <div class="post-comments">
  752. <?php comments_popup_link( __( '0 notes', 'micro' ), __( '1 note', 'micro' ), __( '% notes', 'micro' ) ); ?>
  753. </div>
  754. <?php
  755. }
  756. add_action( 'micro_postmeta', 'micro_comment_meta' );
  757. /**
  758. * Output Post Meta Data
  759. *
  760. * Outputs the post meta data in the post
  761. * footer.
  762. *
  763. * The micro_showmeta() function is hooked into the
  764. * micro_post_footer hook, which is fired in the
  765. * content.php and content-single.php template files.
  766. *
  767. * Template file: content.php, content-single.php
  768. *
  769. * Child Themes can remove this output by calling
  770. * remove_action( 'micro_post_footer', 'micro_showmeta', 40 );
  771. *
  772. * @uses micro_postmeta() Defined in /inc/extensions/content-extensions.php
  773. *
  774. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  775. *
  776. * @param none
  777. * @return string Markup for post metadata
  778. *
  779. * @since Micro 1.0
  780. *
  781. */
  782. function micro_showmeta(){
  783. global $up_options;
  784. $postformat = get_post_format();
  785. $postformat = $postformat ? $postformat : 'standard';
  786. ?>
  787. <div class="post-meta">
  788. <?php micro_postmeta(); ?>
  789. </div>
  790. <?php
  791. }
  792. // Hook micro_showmeta() into micro_post_footer action
  793. add_action( 'micro_post_footer', 'micro_showmeta', 40 );
  794. /**
  795. * Output Post Content
  796. *
  797. * Outputs post content, based on Post Format
  798. * type.
  799. *
  800. * The micro_content() function is hooked into the
  801. * the_content filter hook, which is applied in the
  802. * the_content() template tag.
  803. *
  804. * The the_content() template tag is called in the
  805. * content.php, content-page, and content-single.php
  806. * template files.
  807. *
  808. * Template file: content.php, content-page.php, content-single.php
  809. *
  810. * Child Themes can remove this output by calling
  811. * remove_action( 'the_content', 'micro_content' );
  812. *
  813. * @uses micro_tumblog_embed() Defined in /inc/media.php
  814. * @uses micro_gallery() Defined in /inc/extensions/content-extensions.php
  815. *
  816. * @uses woo_tumblog_image() Defined by WooTumblog Plugin
  817. *
  818. * @link http://codex.wordpress.org/Function_Reference/get_post_format get_post_format()
  819. * @link http://codex.wordpress.org/Function_Reference/get_post_meta get_post_meta()
  820. * @link http://codex.wordpress.org/Function_Reference/get_the_ID get_the_ID()
  821. * @link http://codex.wordpress.org/Function_Reference/get_template_directory_uri get_template_directory_uri()
  822. * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail get_the_post_thumbnail()
  823. * @link http://codex.wordpress.org/Function_Reference/has_post_thumbnail has_post_thumbnail()
  824. * @link http://codex.wordpress.org/Function_Reference/wp_rand wp_rand()
  825. *
  826. * @link http://php.net/manual/en/function.function-exists.php function_exists()
  827. *
  828. * @param none
  829. * @return string Filtered post content
  830. *
  831. * @since Micro 1.0
  832. *
  833. */
  834. function micro_content( $content ) {
  835. global $post;
  836. $posttype = get_post_format();
  837. $posttype = $posttype ? $posttype : 'standard';
  838. $old_content = $content;
  839. $content = '';
  840. switch( $posttype ){
  841. case 'quote':
  842. $url = get_post_meta(get_the_ID(), 'quote-url', true);
  843. $author = get_post_meta(get_the_ID(), 'quote-author', true);
  844. $content .= "<blockquote>" . get_post_meta(get_the_ID(), 'quote-copy', true) . "</blockquote>";
  845. if($author):
  846. $content .= '&#45; ';
  847. if($url) $content .= '<a href="'.$url.'">';
  848. $content .= $author;
  849. if($url) $content .= "</a>";
  850. endif;
  851. break;
  852. case 'video':
  853. $content .= micro_tumblog_embed( array( "id" => $post->ID, "return" => true ) );
  854. break;
  855. case 'gallery':
  856. $content .= micro_gallery();
  857. break;
  858. case 'image':
  859. if( function_exists( 'woo_tumblog_image' ) )
  860. $content .= woo_tumblog_image( array("id" => get_the_ID(), "width" => CONTENT_WIDTH ) );
  861. elseif( has_post_thumbnail() )
  862. $content .= get_the_post_thumbnail( 'full-width-image' );
  863. break;
  864. case 'audio':
  865. $rand = wp_rand( 0, 999999999 );
  866. $audio = get_post_meta( $post->ID, 'audio', true );
  867. $ext = pathinfo( $audio, PATHINFO_EXTENSION );
  868. $content .= '
  869. <script type="text/javascript">
  870. //<![CDATA[
  871. jQuery(document).ready(function($){
  872. $("#jquery_jplayer_'.$rand.'").jPlayer({
  873. ready: function () {
  874. $(this).jPlayer("setMedia", {
  875. '.$ext.': "'.$audio.'"
  876. });
  877. },
  878. ended: function (event) {
  879. $(this).jPlayer("play");
  880. },
  881. swfPath: "' . get_template_directory_uri() . '/inc/scripts/jplayer",
  882. supplied: "'.$ext.'"
  883. });
  884. });
  885. //]]>
  886. </script>
  887. <div class="post-audio">
  888. <div id="jquery_jplayer_'.$rand.'" class="jp-jplayer"></div>
  889. <div class="jp-audio">
  890. <div class="jp-type-single">
  891. <div id="jp_interface_1" class="jp-interface">
  892. <ul class="jp-controls">
  893. <li><a href="#" class="jp-play" tabindex="1">play</a></li>
  894. <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
  895. <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
  896. <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
  897. </ul>
  898. <div class="jp-progress-container">
  899. <div class="jp-progress">
  900. <div class="jp-seek-bar">
  901. <div class="jp-play-bar"></div>
  902. </div>
  903. </div>
  904. </div>
  905. <div class="jp-volume-bar-container">
  906. <div class="jp-volume-bar">
  907. <div class="jp-volume-bar-value"></div>
  908. </div>
  909. </div>
  910. </div>
  911. </div>
  912. </div>
  913. </div>
  914. ';
  915. break;
  916. }
  917. $content .= $old_content;
  918. return $content;
  919. }
  920. // Hook micro_content() into the_content filter
  921. add_filter( 'the_content', 'micro_content' );