| [ Index ] |
PHP Cross Reference of PageLines Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * PageLines Posts Handling 4 * 5 * @package PageLines Framework 6 * @subpackage Posts 7 * @since 2.0.b2 8 */ 9 class PageLinesPosts { 10 11 var $tabs = array(); 12 13 /** PHP5 constructor */ 14 function __construct( ) { 15 16 global $pagelines_layout; 17 global $post; 18 global $wp_query; 19 20 $this->count = 1; // Used to get the number of the post as we loop through them. 21 $this->clipcount = 2; // The number of clips in a row 22 23 $this->post_count = $wp_query->post_count; // Used to prevent markup issues when there aren't an even # of posts. 24 $this->paged = intval(get_query_var('paged')); // Control output if on a paginated page 25 26 $this->thumb_space = get_option('thumbnail_size_w') + 33; // Space for thumb with padding 27 28 $this->continue_reading = apply_filters('continue_reading_link_text', load_pagelines_option('continue_reading_text', __('[Continue Reading...]', 'pagelines'))); 29 30 add_filter('pagelines_post_metabar', 'do_shortcode', 20); 31 32 if( has_action( 'add_social_under_meta' ) || ploption( 'share_under_meta' ) ) 33 add_filter( 'pagelines_post_metabar', array( &$this,'add_social_share' ), 10, 2 ); 34 35 if( has_action( 'add_social_under_excerpt' ) ) 36 add_filter( 'pagelines_post_header', array( &$this,'add_social' ), 10, 2 ); 37 38 } 39 40 41 /** 42 * Add Social Share 43 * 44 * Adds the information from the ShareBar Section to the input information and returns it 45 * 46 * @uses section PageLinesShareBar 47 * #uses get_shares from PageLinesShareBar class 48 * 49 * @param $input 50 * @param $format 51 * 52 * @return string 53 */ 54 function add_social_share( $input, $format ){ 55 56 if ( ! class_exists( 'PageLinesShareBar' ) || $format == 'clip' ) 57 return $input; 58 global $post; 59 60 $share = PageLinesShareBar::get_shares(); 61 $meta_share = sprintf( '<div class="meta-share">%s</div>', $share ); 62 63 return $input.$meta_share; 64 } 65 66 67 /** 68 * Add Social 69 * 70 * Adds Facebook and Twitter sharing options with details relevant to the post 71 * 72 * @uses section PageLinesShareBar 73 * @uses facebook from PageLinesShareBar class 74 * @uses twitter from PageLinesShareBar class 75 * 76 * @param $input 77 * @param $format 78 * @return string 79 */ 80 function add_social($input, $format){ 81 82 if ( ! class_exists( 'PageLinesShareBar' ) || $format == 'clip' ) 83 return $input; 84 global $post; 85 86 $args = array( 'permalink' => get_permalink( $post->ID ), 'width'=>'50', 'title' => wp_strip_all_tags( get_the_title( $post->ID ) ) ); 87 $share = PageLinesShareBar::facebook( $args ); 88 $share .= PageLinesShareBar::twitter( $args ); 89 $meta_share = sprintf( '<div class="meta-share">%s</div>', $share ); 90 91 return $input.$meta_share; 92 } 93 94 95 /** 96 * Load Loop 97 * 98 * Loads the content using WP's standard output functions, if no posts exists the framework's 404 page is loaded instead. 99 * 100 * @uses get_article 101 * @uses posts_404 102 * 103 * @since 2.0.0 104 */ 105 function load_loop(){ 106 107 if( have_posts() ) 108 while ( have_posts() ) : the_post(); $this->get_article(); endwhile; 109 else 110 $this->posts_404(); 111 112 } 113 114 115 /** 116 * Get Article 117 * 118 * Builds the post being displayed by the load_loop function adding clip formatting as required as well as relevant post classes 119 * 120 * @uses pagelines_show_clip 121 * @uses post_header 122 * @uses post_entry 123 * 124 * @internal uses filter 'pagelines_get_article_post_classes' 125 * @internal uses filter 'pageliens_get_article_output' 126 */ 127 function get_article(){ 128 global $wp_query; 129 global $post; 130 131 /* clip handling */ 132 $clip = ( $this->pagelines_show_clip( $this->count, $this->paged ) ) ? true : false; 133 134 $format = ( $clip ) ? 'clip' : 'feature'; 135 $clip_row_start = ( $this->clipcount % 2 == 0 ) ? true : false; 136 $clip_right = ( ( $this->clipcount+1 ) % 2 == 0 ) ? true : false; 137 $clip_row_end = ( $clip_right || $this->count == $this->post_count ) ? true : false; 138 139 $post_type_class = ( $clip ) ? ( $clip_right ? 'clip clip-right' : 'clip' ) : 'fpost'; 140 141 $pagelines_post_classes = apply_filters( 'pagelines_get_article_post_classes', sprintf( '%s post-number-%s', $post_type_class, $this->count ) ); 142 143 $post_classes = join( ' ', get_post_class( $pagelines_post_classes ) ); 144 145 $wrap_start = ( $clip && $clip_row_start ) ? sprintf( '<div class="clip_box fix">' ) : ''; 146 $wrap_end = ( $clip && $clip_row_end ) ? sprintf( '</div>' ) : ''; 147 148 149 150 $post_args = array( 151 'header' => $this->post_header( $format ), 152 'entry' => $this->post_entry(), 153 'classes' => $post_classes, 154 'pad-class' => ( $clip ) ? 'hentry-pad blocks' : 'hentry-pad', 155 'wrap-start' => $wrap_start, 156 'wrap-end' => $wrap_end, 157 'format' => $format, 158 'count' => $this->count 159 ); 160 161 $post_args['markup-start'] = sprintf( 162 '%s<article class="%s" id="post-%s"><div class="%s">', 163 $post_args['wrap-start'], 164 $post_args['classes'], 165 $post->ID, 166 $post_args['pad-class'] 167 ); 168 169 $post_args['markup-end'] = sprintf( 170 '</div></article>%s', 171 $post_args['wrap-end'] 172 ); 173 174 $original = join(array( 175 $post_args['markup-start'], 176 $post_args['header'], 177 $post_args['entry'], 178 $post_args['markup-end'] 179 )); 180 181 echo apply_filters( 'pagelines_get_article_output', $original, $post, $post_args ); 182 183 // Count the clips 184 if( $clip ) 185 $this->clipcount++; 186 187 // Count the posts 188 $this->count++; 189 } 190 191 192 /** 193 * Post Entry 194 * 195 * @uses pagelines_show_content 196 * @internal uses filter 'pagelines_post_entry' 197 * 198 * @return mixed|string|void 199 */ 200 function post_entry(){ 201 202 $id = get_the_ID(); 203 204 if( $this->pagelines_show_content( $id ) ){ 205 206 $excerpt_mode = ploption( 'excerpt_mode_full' ); 207 208 209 if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && is_single() && $this->pagelines_show_thumb( $id ) ) 210 $thumb = $this->post_thumbnail_markup( $excerpt_mode ); 211 else 212 $thumb = ''; 213 214 $post_entry = sprintf( '<div class="entry_wrap fix"><div class="entry_content">%s%s</div></div>', $thumb, $this->post_content() ); 215 216 return apply_filters( 'pagelines_post_entry', $post_entry ); 217 218 } else 219 return ''; 220 } 221 222 223 /** 224 * Post Content 225 * 226 * Captures the post content wrapped in 'pageslines_loop_*_post_content' hooks and returns it 227 * 228 * @uses pageslines_register_hook 229 * @uses pledit 230 * 231 * @return string - the content 232 */ 233 function post_content(){ 234 235 ob_start(); 236 237 pagelines_register_hook( 'pagelines_loop_before_post_content', 'theloop' ); // Hook 238 239 // global $post; 240 241 $content = get_the_content( $this->continue_reading ); 242 243 $content .= pledit( get_the_ID() ); 244 245 echo apply_filters( 'the_content', $content ); 246 247 if( is_single() || is_page() ){ 248 249 $pgn = array( 250 'before' => __( "<div class='pagination'><span class='desc'>pages:</span><ul>", 'pagelines' ), 251 'after' => '</ul></div>', 252 'link_before' => '<span class="pg">', 253 'link_after' => '</span>' 254 ); 255 256 wp_link_pages( $pgn ); 257 } 258 259 if ( is_single() && get_the_tags() ) 260 printf( 261 '<div class="p tags">%s </div>', 262 get_the_tag_list( 263 __( "<span class='note'>Tagged with →</span> ", 'pagelines' ), 264 ' • ', 265 '' 266 ) 267 ); 268 269 pagelines_register_hook( 'pagelines_loop_after_post_content', 'theloop' ); // Hook 270 271 $the_content = ob_get_clean(); 272 273 return $the_content; 274 275 } 276 277 278 /** 279 * Post Header 280 * 281 * Creates the post header information adding classes as required for clipped format and thumbnails images as required 282 * 283 * @param string $format 284 * 285 * @uses pagelines_get_post_metabar 286 * @uses pagelines_get_post_title 287 * @uses pagelines_show_content 288 * @uses pagelines_show_excerpt 289 * @uses pagelines_show_thumb 290 * @uses ploption() for excerpt mode 291 * @uses post_excerpt_markup 292 * @uses post_thumbnail_markup 293 * 294 * @internal uses filter 'pagelines_post_header' 295 * 296 * @return mixed|string|void 297 */ 298 function post_header( $format = '' ){ 299 300 if( $this->show_post_header() ){ 301 302 global $post; 303 304 $id = get_the_ID(); 305 306 $excerpt_mode = ( $format == 'clip' ) ? ploption( 'excerpt_mode_clip' ) : ploption( 'excerpt_mode_full' ); 307 $thumb = ( $this->pagelines_show_thumb( $id ) ) ? $this->post_thumbnail_markup( $excerpt_mode, $format ) : ''; 308 309 $excerpt_thumb = ( $thumb && ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) ) ? '' : $thumb; 310 311 $excerpt = ( $this->pagelines_show_excerpt( $id ) ) ? $this->post_excerpt_markup( $excerpt_mode, $excerpt_thumb ) : ''; 312 313 $classes = 'post-meta fix '; 314 $classes .= ( ! $this->pagelines_show_thumb( $id ) ) ? 'post-nothumb ' : ''; 315 $classes .= ( ! $this->pagelines_show_content( $id ) ) ? 'post-nocontent ' : ''; 316 317 $title = sprintf( '<section class="bd post-title-section fix"><hgroup class="post-title fix">%s</hgroup>%s</section>', $this->pagelines_get_post_title( $format ), $this->pagelines_get_post_metabar( $format ) ); 318 319 if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && ! is_single() ) 320 $post_header = sprintf( '<section class="%s"><section class="bd post-header fix" >%s %s%s</section></section>', $classes, $title, $thumb, $excerpt ); 321 elseif( $excerpt_mode == 'top' ) 322 $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s</section></section>',$classes, $thumb, $title, $excerpt ); 323 elseif( $excerpt_mode == 'left' ) 324 $post_header = sprintf( '<section class="%s media">%s<section class="bd post-header fix" >%s %s</section></section>', $classes, $thumb, $title, $excerpt ); 325 else 326 $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s</section></section>',$classes, '', $title, $excerpt ); 327 328 return apply_filters( 'pagelines_post_header', $post_header, $format ); 329 330 } else 331 return ''; 332 333 } 334 335 336 337 /** 338 * Determines if the post title area should be shown 339 * 340 * @since 2.0.0 341 * 342 * @return bool True if the title area should be shown 343 */ 344 function show_post_header( ) { 345 346 if( !is_page() || (is_page() && ploption('pagetitles')) ) 347 return true; 348 else 349 return false; 350 351 } 352 353 /** 354 * Get post excerpt and markup 355 * 356 * @since 2.0.0 357 * 358 * @return string the excerpt markup 359 */ 360 function post_excerpt_markup( $mode = '', $thumbnail = '' ) { 361 362 ob_start(); 363 364 pagelines_register_hook( 'pagelines_loop_before_excerpt', 'theloop' ); // Hook 365 366 if($mode == 'left-excerpt' || $mode == 'right-excerpt') 367 printf( '<aside class="post-excerpt">%s %s</aside>', $thumbnail, get_the_excerpt() ); 368 else 369 printf( '<aside class="post-excerpt">%s</aside>', get_the_excerpt() ); 370 371 372 if(pagelines_is_posts_page() && !$this->pagelines_show_content( get_the_ID() )) // 'Continue Reading' link 373 echo $this->get_continue_reading_link( get_the_ID() ); 374 375 pagelines_register_hook( 'pagelines_loop_after_excerpt', 'theloop' ); // Hook 376 377 $pagelines_excerpt = ob_get_clean(); 378 379 return apply_filters('pagelines_excerpt', $pagelines_excerpt); 380 381 } 382 383 384 /** 385 * Post Thumbnail Markup 386 * 387 * Get post thumbnail and markup 388 * 389 * @since 2.0.0 390 * 391 * @param string $mode - right, left, or top 392 * @param string $format - ... 393 * @param string $frame - not used 394 * 395 * @return string - the thumbnail markup 396 * 397 * @version 2.2 - fixed image size when thumbnail is displayed on top of excerpt 398 * @todo review if top displayed image should be centered above post, or remain left aligned 399 */ 400 function post_thumbnail_markup( $mode = '', $format = '', $frame = '' ) { 401 402 $thumb_width = get_option( 'thumbnail_size_w' ); 403 404 $classes = 'post-thumb img fix'; 405 406 $percent_width = ( $mode == 'top' ) ? 100 : 25; 407 408 $style = ( 'top' == $mode ) ? 'width: 100%' : sprintf( 'width: %s%%; max-width: %spx', apply_filters( 'pagelines_thumb_width', $percent_width ), $thumb_width ); 409 410 if ( $mode == 'left-excerpt' ) 411 $classes .= ' alignleft'; 412 elseif ( $mode == 'right-excerpt' ) 413 $classes .= ' alignright'; 414 /** By default image will left align, explicitly adding this class for 'top' == $mode is not needed at this time. 415 * elseif ( $mode == 'top' ) $classes .= ' left'; 416 */ 417 418 global $post; 419 420 $img = ( $mode == 'top' ) ? get_the_post_thumbnail( null, 'large' ) : get_the_post_thumbnail( null, 'thumbnail' ); 421 422 $the_image = sprintf( '<span class="c_img">%s</span>', $img ); 423 424 $thumb_link = sprintf( '<a class="%s" href="%s" rel="bookmark" title="%s %s" style="%s">%s</a>', $classes, get_permalink( $post ), __( 'Link To', 'pagelines' ), the_title_attribute( array( 'echo' => false ) ), $style, $the_image ); 425 426 $output = ( 'top' == $mode ) ? sprintf( '<div class="full_img fix">%s</div>', $thumb_link ) : $thumb_link; 427 428 return apply_filters( 'pagelines_thumb_markup', $output, $mode, $format ); 429 430 } 431 432 /** 433 * Adds the metabar or byline under the post title 434 * 435 * @since 1.1.0 436 */ 437 function pagelines_get_post_metabar( $format = '' ) { 438 439 $metabar = ''; 440 $before = '<em>'; 441 $after = '</em>'; 442 if ( is_page() ) 443 return; // don't do post-info on pages 444 445 if( $format == 'clip'){ 446 447 $metabar = ( pagelines_option( 'metabar_clip' ) ) 448 ? $before . pagelines_option( 'metabar_clip' ) . $after 449 : sprintf( '%s%s [post_date] %s [post_author_posts_link] [post_edit]%s', $before, __('On','pagelines'), __('By','pagelines'), $after ); 450 451 } else { 452 453 $metabar = ( pagelines_option( 'metabar_standard' ) ) 454 ? $before . pagelines_option( 'metabar_standard' ) . $after 455 : sprintf( '%s%s [post_author_posts_link] %s [post_date] · [post_comments] · %s [post_categories] [post_edit]%s', $before, __('By','pagelines'), __('On','pagelines'), __('In','pagelines'), $after); 456 457 } 458 459 return sprintf( '<div class="metabar"><div class="metabar-pad">%s</div></div>', apply_filters('pagelines_post_metabar', $metabar, $format) ); 460 461 } 462 463 /** 464 * PageLines Get Post Title 465 * 466 * Gets the post title for all posts 467 * 468 * @package PageLines Framework 469 * @subpackage Functions Library 470 * @since 1.1.0 471 * 472 * @param string $format 473 * 474 * @uses pagelines_option( 'pagetitles' ) 475 * @uses get_the_title - default WordPress post title text 476 * 477 * @internal adds filter 'pagelines_post_title_text' 478 * @internal adds filter 'pagelines_post_title_output' 479 * 480 * @return string - (new) Post $title 481 */ 482 function pagelines_get_post_title( $format = '' ){ 483 484 global $post; 485 global $pagelines_ID; 486 487 /** Check if page and show page title option is set to true */ 488 if( is_page() && pagelines_option('pagetitles') && ! has_filter( "pagelines_no_page_title_{$pagelines_ID}" ) ) { 489 $title = sprintf( '<h1 class="entry-title pagetitle">%s</h1>', apply_filters( 'pagelines_post_title_text', get_the_title() ) ); 490 } elseif(!is_page()) { 491 492 if ( is_singular() ) 493 $title = sprintf( '<h1 class="entry-title">%s</h1>', apply_filters( 'pagelines_post_title_text', get_the_title() ) ); 494 elseif( $format == 'clip') 495 $title = sprintf( '<h4 class="entry-title"><a href="%s" title="%s" rel="bookmark">%s</a></h4>', get_permalink( $post ), the_title_attribute('echo=0'), apply_filters( 'pagelines_post_title_text', get_the_title() ) ); 496 else 497 $title = sprintf( '<h2 class="entry-title"><a href="%s" title="%s" rel="bookmark">%s</a></h2>', get_permalink( $post ), the_title_attribute('echo=0'), apply_filters( 'pagelines_post_title_text', get_the_title() ) ); 498 499 } else {$title = '';} 500 501 502 return apply_filters('pagelines_post_title_output', $title) . "\n"; 503 504 } 505 506 507 508 /** 509 * 510 * Gets the continue reading link after excerpts 511 * 512 * @package PageLines Framework 513 * @subpackage Functions Library 514 * @since 1.3.0 515 * 516 */ 517 function get_continue_reading_link($post_id){ 518 519 $link = sprintf( 520 '<a class="continue_reading_link" href="%s" title="%s %s">%s</a>', 521 get_permalink(), 522 __("View", 'pagelines'), 523 the_title_attribute(array('echo'=> 0)), 524 $this->continue_reading 525 ); 526 527 return apply_filters('continue_reading_link', $link); 528 } 529 530 531 /** 532 * 533 * @TODO document 534 * 535 */ 536 function pagelines_show_thumb($post = null, $location = null){ 537 538 if( function_exists('the_post_thumbnail') && has_post_thumbnail($post) ){ 539 540 // For Hook Parsing 541 if( is_admin() || ! get_option(PAGELINES_SETTINGS) ) return true; 542 543 if( $location == 'clip' && ploption('thumb_clip') ) return true; 544 545 if( !isset($location) ){ 546 // Thumb Page 547 if( is_single() && ploption('thumb_single') ) return true; 548 549 // Blog Page 550 elseif( is_home() && ploption('thumb_blog') ) return true; 551 552 // Search Page 553 elseif( is_search() && ploption('thumb_search') ) return true; 554 555 // Category Page 556 elseif( is_category() && ! is_date() && ploption('thumb_category') ) return true; 557 558 // Archive Page 559 elseif( ! is_category() && is_archive() && ploption('thumb_archive') ) return true; 560 561 else return false; 562 } else return false; 563 } else return false; 564 565 } 566 567 568 /** 569 * 570 * @TODO document 571 * 572 */ 573 function pagelines_show_excerpt( $post = null ){ 574 575 if( is_page() ) 576 return false; 577 578 // Thumb Page 579 if( is_single() && ploption('excerpt_single') ) 580 return true; 581 582 // Blog Page 583 elseif( is_home() && ploption('excerpt_blog') ) 584 return true; 585 586 // Search Page 587 elseif( is_search() && ploption('excerpt_search') ) 588 return true; 589 590 // Category Page 591 elseif( is_category() && ! is_date() && ploption('excerpt_category') ) 592 return true; 593 594 // Archive Page 595 elseif( ! is_category() && is_archive() && ploption('excerpt_archive') ) 596 return true; 597 else 598 return false; 599 } 600 601 602 /** 603 * 604 * @TODO document 605 * 606 */ 607 function pagelines_show_content($post = null){ 608 // For Hook Parsing 609 if( is_admin() ) 610 return true; 611 612 // show on single post pages only 613 if( is_page() || is_single() ) 614 return true; 615 616 // Blog Page 617 elseif( is_home() && ploption('content_blog') ) 618 return true; 619 620 // Search Page 621 elseif( is_search() && ploption('content_search') ) 622 return true; 623 624 // Category Page 625 elseif( is_category() && ploption('content_category') ) 626 return true; 627 628 // Archive Page 629 elseif( ! is_category() && is_archive() && ploption('content_archive') ) 630 return true; 631 632 else 633 return false; 634 635 } 636 637 /* 638 Show clip or full width post 639 */ 640 function pagelines_show_clip($count, $paged){ 641 642 if(!VPRO) 643 return false; 644 645 $archives = apply_filters( 'pagelines_full_width_archives', false ); 646 647 if( ( is_home() || $archives ) && ploption('blog_layout_mode') == 'magazine' && $count <= ploption('full_column_posts') && $paged == 0) 648 return false; 649 650 elseif(ploption('blog_layout_mode') != 'magazine') 651 return false; 652 653 elseif(is_page() || is_single()) 654 return false; 655 656 else 657 return true; 658 } 659 660 661 662 /** 663 * 664 * @TODO document 665 * 666 */ 667 function posts_404(){ 668 669 $head = ( is_search() ) ? sprintf(__('No results for "%s"', 'pagelines'), get_search_query()) : __('Nothing Found', 'pagelines'); 670 671 $subhead = ( is_search() ) ? __('Try another search?', 'pagelines') : __("Sorry, what you are looking for isn't here.", 'pagelines'); 672 673 $the_text = sprintf('<h2 class="center">%s</h2><p class="subhead center">%s</p>', $head, $subhead); 674 675 printf( '<section class="billboard">%s <div class="center fix">%s</div></section>', apply_filters('pagelines_posts_404', $the_text), pagelines_search_form( false )); 676 677 } 678 679 680 } 681 /* ------- END OF CLASS -------- */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Apr 6 23:00:27 2013 | Cross-referenced by PHPXref 0.7.1 |