tags - so, place the read_more inside.
if ( ( \ski\string::ends_with( $text, '
' ) ) && ( !\ski\string::ends_with( $text, ' '.$tag.'' ) ) )
{
return substr_replace( $text, ' '.$tag.'', -4 );
}
// It might be an automatic excerpt - so do not fret.
else if ( \ski\string::ends_with( $text, $tag ) || \ski\string::ends_with( $text, $tag.'' ) )
{
return $text; // Intentionally do nothing more
}
// Making it here means we do the default action -
// append the tag to the summary.
return $text.' '.$tag;
}
/**
* There is no way to directly style the avatar - only this hook
* exists to make it so we apply Bootstrap's media object component.
*
* @link http://getbootstrap.com/components/#media
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar
* @return string Whichever HTML5 element attributes to assign
*/
function change_avatar_class( $class )
{
return str_replace( 'class=\'', 'class=\'media-object ', $class );
}
/**
* Changes the ellipses (or whatever WP provides) that is
* used as a link to view the full page/post.
*
* @param type $more The currently-set 'more' text supplied by WP
* @return string The desired markup
*/
function change_read_more( $more )
{
// OPTION: Display
$opt_display = get_theme_mod( 'bpq_opt_content_read_more', 1 );
if ( empty( $opt_display ) ) return '';
// Making it here means the 'read more' link can be changed.
return ' '.tag_read_more();
}
/**
* Displays a horizontal element that contains a number of links
* leading up to the current page/post.
*/
function display_breadcrumbs()
{
// OPTION: Breadcrumbs
$opt_display_breadcrumbs = get_theme_mod( 'bpq_opt_content_breadcrumbs', 0 );
if ( empty( $opt_display_breadcrumbs ) ) return;
// Put together the call to the template tag.
$args = array(
// TBD
);
echo tag_breadcrumbs( $args );
}
/**
* Displays the prev/next pair of controls to sift through pages/posts.
*
* @param string $id The ID attribute to give to the that contains the pagination.
*/
function display_comments()
{
// Simple - no parameters, yet.
echo tag_comments();
}
/**
* Displays the highlight section with info based on the kind of page
* currently being viewed - this element typically in a prominent area.
*
* @link http://themeshaper.com/2012/11/07/the-archive-template/
*/
function display_highlight()
{
// By the end of this function, we could potentially have
// two lines of text to display in the highlight area.
$text = '';
$subtext = '';
// Look at the settings of the current page and determine
// which kind of content will be displayed in this area.
// POPT: Header display type
$opt_header_type = \ski\post::get_opt( 'bpq_popt_header_type', 'title' ); // Note: Default must be 'title' to handle archives and similar
if ( $opt_header_type == 'slider' )
{
// POPT: Slider
$opt_slider = \ski\post::get_opt( 'bpq_popt_header_slider_list', '' );
if ( !empty( $opt_slider ) )
{
$text = do_shortcode( sprintf( '[rev_slider %s]', $opt_slider ) );
}
}
else if ( $opt_header_type == 'title' )
{
// The highlight text changes a bit based on which kind of page we are on.
if ( is_archive() )
{
if ( is_category() )
{
$text = __( 'Category Archives: ', 'bpq' ).single_cat_title( '', false );
$desc = category_description();
if ( !empty( $desc ) ) $subtext = apply_filters( 'category_archive_meta', $desc );
}
elseif ( is_tag() )
{
$text = __( 'Tag Archives: ', 'bpq' ).single_tag_title( '', false );
$desc = tag_description();
if ( !empty( $desc ) ) $subtext = apply_filters( 'tag_archive_meta', $desc );
}
elseif ( is_author() )
{
// The only way to get the author is to query the first post.
the_post();
$text =
__( 'Author Archives: ', 'bpq' ).
''.
get_the_author().
'';
// Since the first post was specially queued, start the posts
// over again so the loop does not miss the first one.
rewind_posts();
}
elseif ( is_tax() )
{
$tax_slug = get_query_var( 'taxonomy' );
$term_slug = get_query_var( 'term' );
$term_object = get_term_by( 'slug', $term_slug, $tax_slug );
if ( !empty( $term_object ) )
{
$tax_name = __( 'Archives', 'bpq' );
$term_name = $term_object->name;
$tax_object = get_taxonomy( $tax_slug );
if ( !empty( $tax_object ) ) $tax_name = $tax_object->labels->name;
$text = $tax_name.': '.$term_name;
}
else $text = __( 'Taxonomy Archives', 'bpq' );
}
elseif ( is_post_type_archive() ) $text = post_type_archive_title( '', false );
elseif ( is_day() ) $text = __( 'Daily Archives: ', 'bpq' ).''.get_the_date().'';
elseif ( is_month() ) $text = __( 'Monthly Archives: ', 'bpq' ).''.get_the_date( 'F Y' ).'';
elseif ( is_year() ) $text = __( 'Yearly Archives: ', 'bpq' ).''.get_the_date( 'Y' ).'';
else $text = __( 'Archives', 'bpq' );
}
elseif ( is_search() )
{
// Relay the number of results found.
global $wp_query;
$num_results = have_posts() ? $wp_query->found_posts : 0;
$text = sprintf( __( 'Searching for: %s', 'bpq' ), get_search_query() );
$subtext = sprintf( __( '%d results found', 'bpq' ), $num_results );
}
elseif ( is_page() || is_single() )
{
// The text should simply be the title of the page.
$text = get_the_title();
}
elseif ( is_404() )
{
// Something was not found.
$text = __( 'Missing?!', 'bpq' );
}
}
// OPTION: Highlight Alignment
$opt_align = get_theme_mod( 'bpq_opt_content_highlight_alignment', 'ml' );
// Put together the call to the template tag.
$args = array(
'text' => $text,
'subtext' => $subtext,
'align_class' => $opt_align,
'context_class' => $opt_header_type,
);
echo tag_highlight( $args );
}
/**
* Displays the prev/next pair of controls to sift through pages/posts.
*
* @param string $id Typically 'above' or 'below' to indicate where this pagination is being used relative to the post.
*/
function display_pagination( $where = 'xxx' )
{
// OPTION: Display
$default_display = array( 'above' => 0, 'below' => 1, 'xxx' => 0 );
$opt_display = get_theme_mod( 'bpq_opt_content_paging_'.$where, $default_display[$where] );
if ( empty( $opt_display ) ) return;
// Start the args here.
$tag_args =
array(
'id' => 'nav-pagination-'.$where,
);
// The pagination changes a bit based on which kind of page we are on.
if ( is_attachment() ) echo tag_pagination_attachment( $tag_args );
elseif ( is_single() ) echo tag_pagination_single( $tag_args );
else
{
// OPTION: Page train
$tag_args['train'] = get_theme_mod( 'bpq_opt_content_paging_train', 1 );
$tag_args['train_size'] = get_theme_mod( 'bpq_opt_content_paging_train_size', 2 );
$tag_args['train_align'] = get_theme_mod( 'bpq_opt_content_highlight_alignment', 'mc' ); // Match the train with the highlight
echo tag_pagination_archive( $tag_args );
}
}
/**
* Displays the post meta (author, tags, etc) with respect to Customizer options.
*/
function display_post_meta()
{
// Post meta only exists for posts - not pages, not other CPTs.
if ( get_post_type( get_the_ID() ) != 'post' ) return;
// OPTION: Display author
$opt_display_author = get_theme_mod( 'bpq_opt_content_display_author', 1 );
// OPTION: Display categories
$opt_display_categories = get_theme_mod( 'bpq_opt_content_display_categories', 1 );
// OPTION: Display comments
$opt_display_comments = get_theme_mod( 'bpq_opt_content_display_comments', 0 );
// OPTION: Display date
$opt_display_date = get_theme_mod( 'bpq_opt_content_display_date', 1 );
// OPTION: Display tags
$opt_display_tags = get_theme_mod( 'bpq_opt_content_display_tags', 1 );
// OPTION: Date archive type
$opt_date_archive_type = get_theme_mod( 'bpq_opt_content_date_archive_type', 'month' );
// Put together the call to the template tag.
$args = array(
'include_author' => $opt_display_author,
'include_categories' => $opt_display_categories,
'include_comments' => $opt_display_comments,
'include_date' => $opt_display_date,
'include_tags' => $opt_display_tags,
'date_archive_type' => $opt_date_archive_type
);
echo tag_post_meta( $args );
}
/**
* Removes sticky posts from the top of the main WP loop.
*
* @param object $query The query intended to drive the main WP loop.
*/
function remove_sticky_posts( $query )
{
// OPTION: Number of sticky sections
$opt_stickies = get_theme_mod( 'bpq_opt_content_stickies', 1 );
if ( !empty( $opt_stickies ) ) return $query;
// Making it here means that we can change the main WP loop.
$query->set( 'ignore_sticky_posts', true );
// Give the query back to WP to execute the loop query.
return $query;
}
/**
* This function determines if excerpts should be displayed or the
* full-blown post. The feed setting in the reading screen can
* help determine the preferece.
*
* @return boolean 'true' to show the excerpt; otherwise, 'false' to show the full-text
* @since 1.1
*/
function should_use_excerpt()
{
// Singles.
if ( is_single() ) return false;
// Pages.
else if ( is_page() ) return false;
// Making it here means we will reuse the reading feed setting.
return get_option( 'rss_use_excerpt' );
}
?>