mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Add a function, get_comments_number_text()
, that returns instead of echoing. comments_number()
wraps it.
Props kapeels, nbachiyski. Fixes #10177. Built from https://develop.svn.wordpress.org/trunk@28912 git-svn-id: http://core.svn.wordpress.org/trunk@28711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f7ac459a61
commit
21864a98d0
@ -713,18 +713,31 @@ function get_comments_number( $post_id = 0 ) {
|
|||||||
* @param string $deprecated Not used.
|
* @param string $deprecated Not used.
|
||||||
*/
|
*/
|
||||||
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
||||||
if ( !empty( $deprecated ) )
|
if ( ! empty( $deprecated ) ) {
|
||||||
_deprecated_argument( __FUNCTION__, '1.3' );
|
_deprecated_argument( __FUNCTION__, '1.3' );
|
||||||
|
}
|
||||||
|
echo get_comments_number_text( $zero, $one, $more );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the language string for the number of comments the current post has.
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
*
|
||||||
|
* @param string $zero Optional. Text for no comments. Default false.
|
||||||
|
* @param string $one Optional. Text for one comment. Default false.
|
||||||
|
* @param string $more Optional. Text for more than one comment. Default false.
|
||||||
|
*/
|
||||||
|
function get_comments_number_text( $zero = false, $one = false, $more = false ) {
|
||||||
$number = get_comments_number();
|
$number = get_comments_number();
|
||||||
|
|
||||||
if ( $number > 1 )
|
if ( $number > 1 ) {
|
||||||
$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
|
$output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments' ) : $more );
|
||||||
elseif ( $number == 0 )
|
} elseif ( $number == 0 ) {
|
||||||
$output = ( false === $zero ) ? __('No Comments') : $zero;
|
$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
|
||||||
else // must be one
|
} else { // must be one
|
||||||
$output = ( false === $one ) ? __('1 Comment') : $one;
|
$output = ( false === $one ) ? __( '1 Comment' ) : $one;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Filter the comments count for display.
|
* Filter the comments count for display.
|
||||||
*
|
*
|
||||||
@ -736,7 +749,7 @@ function comments_number( $zero = false, $one = false, $more = false, $deprecate
|
|||||||
* is equal to 0, 1, or 1+.
|
* is equal to 0, 1, or 1+.
|
||||||
* @param int $number The number of post comments.
|
* @param int $number The number of post comments.
|
||||||
*/
|
*/
|
||||||
echo apply_filters( 'comments_number', $output, $number );
|
return apply_filters( 'comments_number', $output, $number );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user