post_content;
if ( ! empty( $post_obj->post_excerpt ) ) {
$source_content = $post_obj->post_excerpt;
}
$source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content );
$trimmed_content = wp_trim_words( $source_content, $length, '...' );
return apply_filters( 'create_magazine_trim_content', $trimmed_content );
}
endif;
if ( ! function_exists( 'create_magazine_excerpt_more' ) && ! is_admin() ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* Create your own create_magazine_excerpt_more() function to override in a child theme.
*
* @since Create Magazine 1.0
*
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function create_magazine_excerpt_more() {
$link = sprintf( esc_html__( '%1$s %2$s %3$s','create-magazine' ), '' . esc_html__( 'Read More', 'create-magazine' ) . '', get_the_title( get_the_ID() ), ''
);
return ' ';//$link;
}
// add_filter( 'excerpt_more', 'create_magazine_excerpt_more' );
endif;
if ( ! function_exists( 'create_magazine_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*
* Create your own create_magazine_post_thumbnail() function to override in a child theme.
*
* @since Create Magazine 1.0
*/
function create_magazine_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
?>
the_title_attribute( 'echo=0' ), 'class' => 'img-responsive' ) );
}
?>
the_title_attribute( 'echo=0' ), 'class' => 'img-responsive' ) );
?>
''.esc_html__( ' Previous','create-magazine' ),
'next_text' => esc_html__( 'Next','create-magazine' ).' '
) );
}
endif;
if ( ! function_exists( 'create_magazine_archive_post_navigation' ) ) :
/**
* Displays an optional archive navigation
*
*
* Create your own create_magazine_archive_post_navigation() function to override in a child theme.
*
* @since Create Magazine 1.0
*/
function create_magazine_archive_post_navigation() {
$options = create_magazine_get_theme_options();
if ( ! $options['enable_pagination'] )
return;
if ( 'numeric' == $options['pagination_type'] ) {
echo paginate_links( array( 'type' => 'list', 'class' => 'read-more' ) );
} else {
the_posts_navigation( array(
'prev_text' => '' .esc_html__( ' Older Posts','create-magazine' ),
'next_text' => esc_html__( 'Newer Posts','create-magazine' ) . ''
) );
}
}
endif;
if ( ! function_exists( 'create_magazine_the_custom_logo' ) ) :
/**
* Displays the optional custom logo.
*
* Does nothing if the custom logo is not available.
*
* @since Create Magazine 1.0
*/
function create_magazine_the_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
endif;
if ( ! function_exists( 'create_magazine_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function create_magazine_posted_on() {
$time_string = '';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author_image = get_avatar( get_the_author_meta( 'ID' ), 50 );
$byline = ''. $author_image .''.esc_html__( 'Posted By', 'create-magazine' ).'' . esc_html( get_the_author() ) . '';
$posted_on = '' . $time_string . '';
echo ' ' . $byline . '' . $posted_on . ''; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'create_magazine_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function create_magazine_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'create-magazine' ) );
if ( $categories_list && create_magazine_categorized_blog() ) {
printf( '%1$s', $categories_list ); // WPCS: XSS OK.
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'create-magazine' ) );
if ( $tags_list ) {
printf( '%1$s', $tags_list ); // WPCS: XSS OK.
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
comments_popup_link( get_comments_number(), esc_html__( '1', 'create-magazine' ), esc_html__( '%', 'create-magazine' ) );
echo '';
}
edit_post_link(
sprintf(
/* translators: %s: Name of current post */
esc_html__( 'Edit %s', 'create-magazine' ),
the_title( '"', '"', false )
),
'',
''
);
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function create_magazine_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'create_magazine_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'create_magazine_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so create_magazine_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so create_magazine_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in create_magazine_categorized_blog.
*/
function create_magazine_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'create_magazine_categories' );
}
add_action( 'edit_category', 'create_magazine_category_transient_flusher' );
add_action( 'save_post', 'create_magazine_category_transient_flusher' );