<?php
class AAMHCPostsCategory extends PageLinesPosts {
/**
* Load Loop
*
* Loads the content using WP's standard output functions, if no posts exists the framework's 404 page is loaded instead.
*
* @uses get_article
* @uses posts_404
*
* @since 2.0.0
*/
function load_loop(){
$cat_posts = new WP_Query();
$cat_posts->query('showposts=5&category_name=' . ploption('aamhc_post_loop_categories', $this->oset));
if( $cat_posts->have_posts() ) { while ( $cat_posts->have_posts() ) : $cat_posts->the_post();
$this->get_article($cat_posts);
if($this->count > get_option('posts_per_page')) break; endwhile;
// Read more stories link
$ps = new PageLines_ShortCodes();
$atts = array();
$atts['size'] = 'large';
echo '<div class="view-more-stories">' . $ps->pl_button_shortcode($atts, 'View More Stories') . '</div>';
}
else
$this->posts_404();
}
/**
* Get Article (Overloaded)
*
* Builds the post being displayed by the load_loop function adding clip formatting as required as well as relevant post classes
*
* @uses pagelines_show_clip
* @uses post_header
* @uses post_entry
*
* @internal uses filter 'pagelines_get_article_post_classes'
* @internal uses filter 'pageliens_get_article_output'
*/
function get_article($cat_posts){ /*global $wp_query;
global $post; */
/* clip handling */
$clip = false; //( $this->pagelines_show_clip( $this->count, $this->paged ) ) ? true : false;
$format = ( $clip ) ? 'clip' : 'feature';
$clip_row_start = ( $this->clipcount % 2 == 0 ) ? true : false;
$clip_right = ( ( $this->clipcount+1 ) % 2 == 0 ) ? true : false;
$clip_row_end = ( $clip_right || $this->count == $this->post_count ) ? true : false;
$post_type_class = ( $clip ) ? ( $clip_right ? 'clip clip-right' : 'clip' ) : 'fpost';
// Only show 3 posts initially. More can be shown by clicking 'read more stories'
$show_hide_class = ($this->count <= 3) ? 'post-displayed' : 'post-hidden';
$pagelines_post_classes = apply_filters( 'pagelines_get_article_post_classes', sprintf( '%s post-number-%s %s', $post_type_class, $this->count, $show_hide_class ) );
$post_classes = join( ' ', get_post_class( $pagelines_post_classes ) );
// Need post-nothumb on article so we can set a different height for post excerpts that have no thumbnail
$post_classes .= ( ! has_post_thumbnail() ) ? ' post-nothumb ' : '';
$wrap_start = ( $clip && $clip_row_start ) ? sprintf( '<div class="clip_box fix">' ) : '';
$wrap_end = ( $clip && $clip_row_end ) ? sprintf( '</div>' ) : '';
$post_args = array(
'header' => $this->post_header( $format ),
'entry' => $this->post_entry($cat_posts),
'classes' => $post_classes,
'pad-class' => ( $clip ) ? 'hentry-pad blocks' : 'hentry-pad',
'wrap-start' => $wrap_start,
'wrap-end' => $wrap_end,
'format' => $format,
'count' => $this->count
);
$post_args['markup-start'] = sprintf(
'%s<article class="%s" id="post-%s"><div class="%s">',
$post_args['wrap-start'],
$post_args['classes'],
$cat_posts->post->ID,
$post_args['pad-class']
);
$post_args['markup-end'] = sprintf(
'</div></article>%s',
$post_args['wrap-end']
);
$original = join(array(
$post_args['markup-start'],
$post_args['header'],
$post_args['entry'],
$post_args['markup-end']
));
echo apply_filters( 'pagelines_get_article_output', $original, $post, $post_args );
// Remove [...] from excerpt
// add_filter('pagelines_excerpt', 'trim_excerpt');
// Count the clips
if( $clip )
$this->clipcount++;
// Count the posts
$this->count++;
}
/**
* SJC - Overloaded this and emptied it as we dont want to show full content on category pages.
*
* @uses pagelines_show_content
* @internal uses filter 'pagelines_post_entry'
*
* @return mixed|string|void
*/
function post_entry($cat_posts){ /*
$id = $cat_posts->post->ID;
$excerpt_mode = ploption( 'excerpt_mode_full' );
if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && is_single() && $this->pagelines_show_thumb( $id ) )
$thumb = $this->post_thumbnail_markup( $excerpt_mode );
else
$thumb = '';
$post_entry = sprintf( '<div class="entry_wrap fix"><div class="entry_content">%s%s</div></div>', $thumb, $this->post_content() );
return apply_filters( 'pagelines_post_entry', $post_entry );
*/
}
/**
* Post Header
*
* Creates the post header information adding classes as required for clipped format and thumbnails images as required
*
* @param string $format
*
* @uses pagelines_get_post_metabar
* @uses pagelines_get_post_title
* @uses pagelines_show_content
* @uses pagelines_show_excerpt
* @uses pagelines_show_thumb
* @uses ploption() for excerpt mode
* @uses post_excerpt_markup
* @uses post_thumbnail_markup
*
* @internal uses filter 'pagelines_post_header'
*
* @return mixed|string|void
*/
function post_header( $format = '', $cat_posts ){
//global $post;
$id = get_the_ID();
$excerpt_mode = ( $format == 'clip' ) ? ploption( 'excerpt_mode_clip' ) : ploption( 'excerpt_mode_full' );
$thumb = ( has_post_thumbnail($cat_posts->post->ID)) ? $this->post_thumbnail_markup( $excerpt_mode, $format ) : '';
$excerpt_thumb = ( $thumb && ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) ) ? '' : $thumb;
$excerpt = $this->post_excerpt_markup( $excerpt_mode, $excerpt_thumb, $cat_posts );
$classes = 'post-meta fix ';
$classes .= ( ! has_post_thumbnail($cat_posts->post->ID) ) ? 'post-nothumb ' : '';
$classes .= 'post-nocontent ';
// Swapped the post title and meta bar to suit AAMHC template
$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 ) );
// Add share bar to bottom of excerpt
$share = PageLinesShareBar::get_shares();
$share_bar = sprintf('<div class="meta-share">%s</div>', $share );
if( ( $excerpt_mode == 'left-excerpt' || $excerpt_mode == 'right-excerpt' ) && ! is_single() ) { $post_header = sprintf( '<section class="%s"><section class="bd post-header fix" >%s %s%s%s</section></section>', $classes, $title, $thumb, $excerpt, $share_bar );
}
elseif( $excerpt_mode == 'top' ) { $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s%s</section></section>',$classes, $thumb, $title, $excerpt, $share_bar );
}
elseif( $excerpt_mode == 'left' ) { $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 );
}
else { $post_header = sprintf( '<section class="%s">%s<section class="bd post-header fix" >%s %s%s</section></section>',$classes, '', $title, $excerpt, $share_bar );
}
return apply_filters( 'pagelines_post_header', $post_header, $format );
}
/**
* Get post excerpt and markup
*
* @since 2.0.0
*
* @return string the excerpt markup
*/
function post_excerpt_markup( $mode = '', $thumbnail = '', $cat_posts ) {
ob_start();
pagelines_register_hook( 'pagelines_loop_before_excerpt', 'theloop' ); // Hook
add_filter('get_the_excerpt', 'excerpt_ellipse');
// 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.
if($mode == 'left-excerpt' || $mode == 'right-excerpt')
printf( '<aside class="post-excerpt">%s %s</aside>', $thumbnail, string_limit_words( get_the_content(), 35) );
else
printf( '<aside class="post-excerpt">%s</aside>', string_limit_words( get_the_content(), 35) );
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 );
pagelines_register_hook( 'pagelines_loop_after_excerpt', 'theloop' ); // Hook
$pagelines_excerpt = ob_get_clean();
return apply_filters('pagelines_excerpt', $pagelines_excerpt);
}
function pagelines_get_post_metabar( $format = '', $cat_posts ) {
$metabar = '';
$before = '<em>';
$after = '</em>';
/* if ( is_page() )
return; // don't do post-info on pages */
// Convert categories to upper case
/*$ps = new PageLines_ShortCodes();
$categories = strtoupper($ps->pagelines_post_categories_shortcode('')); */
if( $format == 'clip'){
$metabar = ( pagelines_option( 'metabar_clip' ) )
? $before . pagelines_option( 'metabar_clip' ) . $after
: sprintf( '%s%s [post_date] %s [post_author_posts_link] [post_edit]%s', $before, __('On','pagelines'), __('By','pagelines'), $after );
} else {
$metabar = ( pagelines_option( 'metabar_standard' ) )
? $before . pagelines_option( 'metabar_standard' ) . $after
: sprintf( '%s%s [post_author_posts_link] %s [post_date] · [post_comments] · %s %s [post_edit]%s', $before, __('By','pagelines'), $categories, __('On','pagelines'), __('In','pagelines'), $after);
}
return sprintf( '<div class="metabar"><div class="metabar-pad">%s</div></div>', apply_filters('pagelines_post_metabar', $metabar, $format) );
}
function add_social_share( $input, $format ){
if ( ! class_exists( 'PageLinesShareBar' ) || $format == 'clip' )
return $input;
global $post;
$share = PageLinesShareBar::get_shares();
$meta_share = sprintf( '<div class="meta-share">%s</div>', $share );
return $input.$meta_share;
}
}