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