New Paste

 

Recent Pastes

Administrate




PageLines PasteBin.

PasteID: 2rz
Pasted by JHume, 2012-10-03 23:06:15 GMT
Expires Never
Paste size 11.36 Kb
Toggle Expand   Wrap   Raw
Copy Contents   Copy URL
 
  1. <?php
  2. class AAMHCPostsCategory extends PageLinesPosts     {
  3.  
  4.        /**
  5.      * Load Loop
  6.      *
  7.      * Loads the content using WP's standard output functions, if no posts exists the framework's 404 page is loaded instead.
  8.      *
  9.      * @uses    get_article
  10.      * @uses    posts_404
  11.      *
  12.      * @since   2.0.0
  13.      */
  14.     function load_loop(){
  15.  
  16.         $cat_posts = new WP_Query();
  17.  
  18.         $cat_posts->query('showposts=5&category_name=' . ploption('aamhc_post_loop_categories', $this->oset));
  19.  
  20.         if( $cat_posts->have_posts() ) {
  21.             while ( $cat_posts->have_posts() ) : $cat_posts->the_post();
  22.                     $this->get_article($cat_posts);
  23.                     if($this->count > get_option('posts_per_page')) break;
  24.             endwhile;
  25.  
  26.             // Read more stories link
  27.             $ps = new PageLines_ShortCodes();
  28.             $atts = array();
  29.             $atts['size'] = 'large';
  30.             echo '<div class="view-more-stories">' . $ps->pl_button_shortcode($atts, 'View More Stories') . '</div>';
  31.         }
  32.         else
  33.             $this->posts_404();
  34.  
  35.     }
  36.  
  37.     /**
  38.      * Get Article (Overloaded)
  39.      *
  40.      * Builds the post being displayed by the load_loop function adding clip formatting as required as well as relevant post classes
  41.      *
  42.      * @uses    pagelines_show_clip
  43.      * @uses    post_header
  44.      * @uses    post_entry
  45.      *
  46.      * @internal uses filter 'pagelines_get_article_post_classes'
  47.      * @internal uses filter 'pageliens_get_article_output'
  48.      */
  49.     function get_article($cat_posts){
  50.         /*global $wp_query;
  51.         global $post; */
  52.  
  53.         /* clip handling */
  54.         $clip = false; //( $this->pagelines_show_clip( $this->count, $this->paged ) ) ? true : false;
  55.  
  56.         $format = ( $clip ) ? 'clip' : 'feature';
  57.         $clip_row_start = ( $this->clipcount % 2 == 0 ) ? true : false;
  58.         $clip_right = ( ( $this->clipcount+1 ) % 2 == 0 ) ? true : false;
  59.         $clip_row_end = ( $clip_right || $this->count == $this->post_count ) ? true : false;
  60.  
  61.         $post_type_class = ( $clip ) ? ( $clip_right ? 'clip clip-right' : 'clip' ) : 'fpost';
  62.  
  63.         // Only show 3 posts initially.  More can be shown by clicking 'read more stories'
  64.         $show_hide_class = ($this->count <= 3) ? 'post-displayed' : 'post-hidden';
  65.         $pagelines_post_classes = apply_filters( 'pagelines_get_article_post_classes', sprintf( '%s post-number-%s %s', $post_type_class, $this->count, $show_hide_class ) );
  66.  
  67.         $post_classes = join( ' ', get_post_class( $pagelines_post_classes ) );
  68.  
  69.         // Need post-nothumb on article so we can set a different height for post excerpts that have no thumbnail
  70.         $post_classes .= ( ! has_post_thumbnail() ) ? ' post-nothumb ' : '';
  71.  
  72.         $wrap_start = ( $clip && $clip_row_start ) ? sprintf( '<div class="clip_box fix">' ) : '';
  73.         $wrap_end = ( $clip && $clip_row_end ) ? sprintf( '</div>' ) : '';
  74.  
  75.         $post_args = array(
  76.             'header'		=> $this->post_header( $format ),
  77.             'entry'			=> $this->post_entry($cat_posts),
  78.             'classes'		=> $post_classes,
  79.             'pad-class'		=> ( $clip ) ? 'hentry-pad blocks' : 'hentry-pad',
  80.             'wrap-start'	=> $wrap_start,
  81.             'wrap-end'		=> $wrap_end,
  82.             'format'		=> $format,
  83.             'count'			=> $this->count
  84.         );
  85.  
  86.         $post_args['markup-start'] = sprintf(
  87.             '%s<article class="%s" id="post-%s"><div class="%s">',
  88.             $post_args['wrap-start'],
  89.             $post_args['classes'],
  90.             $cat_posts->post->ID,
  91.             $post_args['pad-class']
  92.         );
  93.  
  94.         $post_args['markup-end'] = sprintf(
  95.             '</div></article>%s',
  96.             $post_args['wrap-end']
  97.         );
  98.  
  99.         $original = join(array(
  100.             $post_args['markup-start'],
  101.             $post_args['header'],
  102.             $post_args['entry'],
  103.             $post_args['markup-end']
  104.         ));
  105.  
  106.         echo apply_filters( 'pagelines_get_article_output', $original, $post, $post_args );
  107.  
  108.         // Remove [...] from excerpt
  109.         // add_filter('pagelines_excerpt', 'trim_excerpt');
  110.  
  111.         // Count the clips
  112.         if( $clip )
  113.             $this->clipcount++;
  114.  
  115.         // Count the posts
  116.         $this->count++;
  117.     }
  118.  
  119.  
  120.  
  121.  
  122.     /**
  123.      * SJC - Overloaded this and emptied it as we dont want to show full content on category pages.
  124.      *
  125.      * @uses    pagelines_show_content
  126.      * @internal uses filter 'pagelines_post_entry'
  127.      *
  128.      * @return  mixed|string|void
  129.      */
  130.     function post_entry($cat_posts){
  131.         /*
  132.         $id = $cat_posts->post->ID;
  133.  
  134.             $excerpt_mode = ploption( 'excerpt_mode_full' );
  135.  
  136.  
  137.             if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && is_single() && $this->pagelines_show_thumb( $id ) )
  138.                 $thumb = $this->post_thumbnail_markup( $excerpt_mode );
  139.             else
  140.                 $thumb = '';
  141.  
  142.             $post_entry = sprintf( '<div class="entry_wrap fix"><div class="entry_content">%s%s</div></div>', $thumb, $this->post_content() );
  143.  
  144.             return apply_filters( 'pagelines_post_entry', $post_entry );
  145.         */
  146.     }
  147.  
  148.  
  149.     /**
  150.      * Post Header
  151.      *
  152.      * Creates the post header information adding classes as required for clipped format and thumbnails images as required
  153.      *
  154.      * @param   string $format
  155.      *
  156.      * @uses    pagelines_get_post_metabar
  157.      * @uses    pagelines_get_post_title
  158.      * @uses    pagelines_show_content
  159.      * @uses    pagelines_show_excerpt
  160.      * @uses    pagelines_show_thumb
  161.      * @uses    ploption() for excerpt mode
  162.      * @uses    post_excerpt_markup
  163.      * @uses    post_thumbnail_markup
  164.      *
  165.      * @internal uses filter 'pagelines_post_header'
  166.      *
  167.      * @return  mixed|string|void
  168.      */
  169.     function post_header( $format = '', $cat_posts ){
  170.  
  171.             //global $post;
  172.  
  173.             $id = get_the_ID();
  174.  
  175.             $excerpt_mode = ( $format == 'clip' ) ? ploption( 'excerpt_mode_clip' ) : ploption( 'excerpt_mode_full' );
  176.             $thumb = ( has_post_thumbnail($cat_posts->post->ID)) ? $this->post_thumbnail_markup( $excerpt_mode, $format ) : '';
  177.  
  178.             $excerpt_thumb = ( $thumb && ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) ) ? '' : $thumb;
  179.  
  180.             $excerpt = $this->post_excerpt_markup( $excerpt_mode, $excerpt_thumb, $cat_posts );
  181.  
  182.             $classes = 'post-meta fix ';
  183.             $classes .= ( ! has_post_thumbnail($cat_posts->post->ID) ) ? 'post-nothumb ' : '';
  184.             $classes .=  'post-nocontent ';
  185.  
  186.             // Swapped the post title and meta bar to suit AAMHC template
  187.             $title = sprintf( '<section class="bd post-title-section fix">%s<hgroup class="post-title fix">%s</hgroup></section>', $this->pagelines_get_post_metabar( $format ), $this->pagelines_get_post_title( $format ) );
  188.  
  189.             // Add share bar to bottom of excerpt
  190.             $share = PageLinesShareBar::get_shares();
  191.             $share_bar = sprintf('<div class="meta-share">%s</div>', $share );
  192.  
  193.             if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && ! is_single() ) {
  194.                 $post_header = sprintf( '<section class="%s"><section class="bd post-header fix" >%s %s%s%s</section></section>', $classes, $title, $thumb, $excerpt, $share_bar );
  195.             }
  196.             elseif( $excerpt_mode == 'top' ) {
  197.                 $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s%s</section></section>',$classes, $thumb, $title, $excerpt, $share_bar );
  198.             }
  199.             elseif( $excerpt_mode == 'left' ) {
  200.                 $post_header = sprintf( '<section class="%s media">%s<section class="bd post-header fix" >%s %s%s</section></section>', $classes, $thumb, $title, $excerpt, $share_bar );
  201.             }
  202.             else {
  203.                 $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s%s</section></section>',$classes, '', $title, $excerpt, $share_bar );
  204.             }
  205.  
  206.             return apply_filters( 'pagelines_post_header', $post_header, $format );
  207.  
  208.     }
  209.  
  210.  
  211.     /**
  212.      * Get post excerpt and markup
  213.      *
  214.      * @since 2.0.0
  215.      *
  216.      * @return string the excerpt markup
  217.      */
  218.     function post_excerpt_markup( $mode = '', $thumbnail = '',  $cat_posts ) {
  219.  
  220.         ob_start();
  221.  
  222.         pagelines_register_hook( 'pagelines_loop_before_excerpt', 'theloop' ); // Hook
  223.  
  224.         add_filter('get_the_excerpt', 'excerpt_ellipse');
  225.  
  226.         // Use get_the_content for excerpt then truncate the length. We can get a number larger than the standard excerpt this way, if we wish.
  227.         if($mode == 'left-excerpt' || $mode == 'right-excerpt')
  228.             printf( '<aside class="post-excerpt">%s %s</aside>', $thumbnail, string_limit_words( get_the_content(), 35) );
  229.         else
  230.             printf( '<aside class="post-excerpt">%s</aside>', string_limit_words( get_the_content(), 35) );
  231.  
  232.  
  233.  
  234.             echo '<a class="continue_reading_link" title="' . get_the_title($cat_posts->post->ID) . '" href="' . get_permalink($cat_posts->post->ID) .'">Read Full Article ></a>';// $this->get_continue_reading_link( $cat_posts->post->ID );
  235.  
  236.  
  237.  
  238.  
  239.         pagelines_register_hook( 'pagelines_loop_after_excerpt', 'theloop' ); // Hook
  240.  
  241.         $pagelines_excerpt = ob_get_clean();
  242.  
  243.         return apply_filters('pagelines_excerpt', $pagelines_excerpt);
  244.  
  245.     }
  246.  
  247.  
  248.     function pagelines_get_post_metabar( $format = '', $cat_posts ) {
  249.  
  250.         $metabar = '';
  251.         $before = '<em>';
  252.         $after = '</em>';
  253.        /* if ( is_page() )
  254.             return; // don't do post-info on pages  */
  255.  
  256.         // Convert categories to upper case
  257.         /*$ps = new PageLines_ShortCodes();
  258.         $categories = strtoupper($ps->pagelines_post_categories_shortcode(''));  */
  259.  
  260.         if( $format == 'clip'){
  261.  
  262.             $metabar = ( pagelines_option( 'metabar_clip' ) )
  263.                 ? $before . pagelines_option( 'metabar_clip' ) . $after
  264.                 : sprintf( '%s%s [post_date] %s [post_author_posts_link] [post_edit]%s', $before, __('On','pagelines'), __('By','pagelines'), $after );
  265.  
  266.         } else {
  267.  
  268.             $metabar = ( pagelines_option( 'metabar_standard' ) )
  269.                 ? $before . pagelines_option( 'metabar_standard' ) . $after
  270.                 : sprintf( '%s%s [post_author_posts_link] %s [post_date] &middot; [post_comments] &middot; %s %s [post_edit]%s', $before, __('By','pagelines'), $categories, __('On','pagelines'), __('In','pagelines'), $after);
  271.  
  272.         }
  273.  
  274.         return sprintf( '<div class="metabar"><div class="metabar-pad">%s</div></div>', apply_filters('pagelines_post_metabar', $metabar, $format) );
  275.  
  276.     }
  277.  
  278.     function add_social_share( $input, $format ){
  279.  
  280.         if ( ! class_exists( 'PageLinesShareBar' ) || $format == 'clip' )
  281.             return $input;
  282.         global $post;
  283.  
  284.         $share = PageLinesShareBar::get_shares();
  285.         $meta_share = sprintf( '<div class="meta-share">%s</div>', $share );
  286.  
  287.         return $input.$meta_share;
  288.     }
  289. }
 
 
 

 
 
 
 
 
Written by Xan Manning, 2010.
YOU NEED FLASH!