File: /home/zeusxp5/zenoxpressalongside.net/wp-content/themes/zxldfw-tcompanyllcMain/functions/posts.php
<?php
// Display Older / Newer Posts Links
if ( ! function_exists( 'webcom_content_nav' ) ) :
function webcom_content_nav( $html_id ) {
global $wp_query;
$html_id = esc_attr( $html_id );
if ( $wp_query->max_num_pages > 1 ) : ?>
<nav id="<?php echo $html_id; ?>" class="blog-navigation" role="navigation">
<h3 class="assistive-text">Post navigation</h3>
<div class="nav-previous"><?php next_posts_link( '<span class="meta-nav"><i class="fa fa-arrow-left" aria-hidden="true"></i></span> Older posts' ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts <span class="meta-nav"><i class="fa fa-arrow-right" aria-hidden="true"></i></span>' ); ?></div>
</nav>
<?php endif;
}
endif;
// Creates Post Entry Meta at bottom of each Post
if ( ! function_exists( 'webcom_entry_meta' ) ) :
function webcom_entry_meta() {
$categories_list = get_the_category_list( ', ' );
$tag_list = get_the_tag_list( '', ', ' );
$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( 'View all posts by %s', get_the_author() ) ),
get_the_author()
);
// 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
$utility_text = 'This entry was posted';
if( $categories_list )
$utility_text .= ' in %1$s';
if( $tag_list )
$utility_text .= ' and tagged %2$s';
$utility_text .= ' on %3$s';
if(!user_can(get_the_author_meta('ID'), 'manage_network'))
$utility_text .= ' <span class="by-author">by %4$s</span>';
$utility_text .= '.';
printf(
$utility_text,
$categories_list, // 1
$tag_list, // 2
$date, // 3
$author // 4
);
}
endif;
/**
* Creates a custom excerpt from the content of a post.
*
* If the excerpt has been set for the post, the excerpt will be shown along with the read more link.
*
* If no excerpt has been set, the content will be used. The content will be formated to have
* shortcodes and some HTML removed.
*
* @param array $args {
*
* @type int $limit Number of words to be returned.
* @type string $more_text What to append to trimmed content. Default ….
* @type bool $more_link_text Text to be used inside the read more link. Default 'Continue reading'.
* }
*/
if ( ! function_exists( 'webcom_post_loop_summary' ) ) {
function webcom_post_loop_summary( $args ) {
$defaults = array(
'word_limit' => 55,
'char_limit' => false,
'more_text' => '…',
'more_link_text' => 'Continue reading',
);
$args = wp_parse_args( $args, $defaults );
if ( has_excerpt() ) {
//the_excerpt();
echo apply_filters( 'the_excerpt', get_the_excerpt() );
} else {
$allowed_tags = wp_kses_allowed_html( 'excerpt' );
// Get the raw content for the current post.
$post_content = get_post();
$post_content = $post_content->post_content;
$post_content = strip_shortcodes( $post_content );
$post_content = str_replace(']]>', ']]>', $post_content);
$post_content = str_replace( array( '<!--more-->', '<!--nextpage-->' ), '', $post_content ); // Remove more and nextpage tags.
if ( false !== $args['char_limit'] ) {
$post_content = wp_strip_all_tags( $post_content ); // Strip all HTML from content.
$post_content = substr( $post_content, 0, $args['char_limit'] ); // trims text to a certain number of words.
} else {
// https://core.trac.wordpress.org/ticket/29533
$post_content = wp_kses( $post_content, $allowed_tags ); // Strip HTML from content.
$post_content = htmlentities( $post_content ); // Convert characters to HTML entities, so wp_trim_words dosn't remove them.
$post_content = wp_trim_words( $post_content, $args['word_limit'], '' ); // trims text to a certain number of words.
$post_content = html_entity_decode( $post_content ); // Convert all HTML entities to their applicable characters.
$post_content = force_balance_tags( $post_content ); // Balances HTML tags inside a string.
}
$post_content = wpautop( $post_content . $args['more_text'] ); // Add P tags to the summary.
echo $post_content;
}
if ( ! ( '' === $args['more_link_text'] || false === $args['more_link_text'] ) ) {
echo '<p><a href="' . get_the_permalink() . '" class="more-link">' . $args['more_link_text'] . '</a></p>';
}
}
}