Echo post meta comments shortcode.
beans_post_meta_comments_shortcode( )
Return: (void)
Source
function beans_post_meta_comments_shortcode() {
global $post;
if ( post_password_required() || ! comments_open() ) {
return;
}
$comments_number = (int) get_comments_number( $post->ID );
if ( $comments_number < 1 ) {
$comment_text = beans_output( 'beans_post_meta_empty_comment_text', __( 'Leave a comment', 'tm-beans' ) );
} elseif ( 1 === $comments_number ) {
$comment_text = beans_output( 'beans_post_meta_comments_text_singular', __( '1 comment', 'tm-beans' ) );
} else {
$comment_text = beans_output( 'beans_post_meta_comments_text_plurial', __( '%s comments', 'tm-beans' ) );
}
beans_open_markup_e( 'beans_post_meta_comments', 'a', array(
'href' => get_comments_link(), // Automatically escaped.
) );
printf( $comment_text, (int) get_comments_number( $post->ID ) );
beans_close_markup_e( 'beans_post_meta_comments', 'a' );
}