%2$s';
if ( is_single() ) {
$time_string = sprintf(
$time_string, esc_attr( get_the_date( 'c' ) ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) )
);
$posted_on = sprintf( /* translators: link to post date */
esc_html_x( '%s ago', 'post date', 'blogito' ), '' . $time_string . ''
);
$byline = sprintf( /* translators: link to author page */
esc_html_x( ' by %s', 'post author', 'blogito' ), '' . esc_html( get_the_author() ) . ''
);
echo '' . $posted_on . ' ' . $byline . ''; // WPCS: XSS OK.
} else {
$time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_attr( get_the_date() ) );
$posted_on = sprintf( /* translators: link to post date */
esc_html_x( '%s ', 'post date', 'blogito' ), '' . $time_string . ''
);
echo '' . $posted_on . ''; // WPCS: XSS OK.
}
}
endif;
if ( ! function_exists( 'blogito_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function blogito_entry_footer() {
blogito_jetpack_sharing();
// Hide category and tag text for pages.
if ( is_single() && 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'blogito' ) );
if ( $tags_list ) { /* translators: related tag list */
printf( '' . esc_html__( 'Tagged: %1$s', 'blogito' ) . '', $tags_list ); // WPCS: XSS OK.
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
comments_popup_link( '', ' 1', '' . esc_html__( ' %', 'blogito' ) ) . '';
echo '';
}
edit_post_link( esc_html__( 'Edit', 'blogito' ), '', '' );
}
endif;
if ( ! function_exists( 'blogito_categorized_blog' ) ) :
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function blogito_categorized_blog() {
$all_the_cool_cats = get_transient( 'blogito_categories' );
if ( ! $all_the_cool_cats ) {
// 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( 'blogito_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so blogito_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so blogito_categorized_blog should return false.
return false;
}
}
endif;
/**
* Flush out the transients used in blogito_categorized_blog.
*/
function blogito_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'blogito_categories' );
}
add_action( 'edit_category', 'blogito_category_transient_flusher' );
add_action( 'save_post', 'blogito_category_transient_flusher' );
if ( ! function_exists( 'blogito_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since blogito 1.0
* @param type $comment comment.
* @param type $args comment args.
* @param type $depth comments depth.
*/
function blogito_comment( $comment, $args, $depth ) {
// $GLOBALS['comment'] = $comment;
?>
',
);
return $fields;
}
add_filter( 'comment_form_default_fields', 'blogito_comments_fields' );
endif;
/**
* Gets the excerpt using the post ID outside the loop.
*
* @author Withers David
* @link http://uplifted.net/programming/wordpress-get-the-excerpt-automatically-using-the-post-id-outside-of-the-loop/
* @param int $post_id WP post ID.
* @return string
*/
function blogito_get_excerpt_by_id( $post_id ) {
$the_post = get_post( $post_id ); // Gets post ID.
$the_excerpt = $the_post->post_content; // Gets post_content to be used as a basis for the excerpt.
$excerpt_length = 35; // Sets excerpt length by word count.
$the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); // Strips tags and images.
$words = explode( ' ', $the_excerpt, $excerpt_length + 1 );
if ( count( $words ) > $excerpt_length ) :
array_pop( $words );
array_push( $words, '...' );
$the_excerpt = implode( ' ', $words );
endif;
$the_excerpt = '
' . $the_excerpt . '
';
return $the_excerpt;
}
if ( ! function_exists( 'blogito_custom_popular_posts_html_list' ) ) :
/**
* Builds custom HTML
*
* With this function, I can alter WPP's HTML output from my theme's functions.php.
* This way, the modification is permanent even if the plugin gets updated.
*
* @param array $mostpopular WPP mostpopular.
* @param array $instance WPP instance.
* @return string
*/
function blogito_custom_popular_posts_html_list( $mostpopular, $instance ) {
$output = '
' . '
', 'email' => '' . '
', 'url' => '' . '