onetone_get_comments_number_str

Modifies WordPress's built-in comments_number() function to return string instead of echo.

Description

onetone_get_comments_number_str( (constant) $zero = false, (constant) $one = false, (constant) $more = false, (string) $deprecated = '' ); 

Parameters (4)

0. $zero — Optional. (constant) => false
The zero.
1. $one — Optional. (constant) => false
The one.
2. $more — Optional. (constant) => false
The more.
3. $deprecated — Optional. (string) => ''
The deprecated.

Usage

  1. if ( !function_exists( 'onetone_get_comments_number_str' ) ) { 
  2. require_once '/includes/theme-functions.php'; 
  3.  
  4. // The zero. 
  5. $zero = false; 
  6.  
  7. // The one. 
  8. $one = false; 
  9.  
  10. // The more. 
  11. $more = false; 
  12.  
  13. // The deprecated. 
  14. $deprecated = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = onetone_get_comments_number_str($zero, $one, $more, $deprecated); 
  18.  

Defined (1)

The function is defined in the following location(s).

/includes/theme-functions.php  
  1. function onetone_get_comments_number_str( $zero = false, $one = false, $more = false, $deprecated = '' ) { 
  2.  
  3. if ( !empty( $deprecated ) ) 
  4. _deprecated_argument( __FUNCTION__, '1.3' ); 
  5.  
  6. $number = get_comments_number(); 
  7.  
  8. if ( $number > 1 ) 
  9. $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments', 'onetone') : $more); 
  10. elseif ( $number == 0 ) 
  11. $output = ( false === $zero ) ? __('No Comments', 'onetone') : $zero; 
  12. else // must be one 
  13. $output = ( false === $one ) ? __('1 Comment', 'onetone') : $one; 
  14.  
  15. return apply_filters('comments_number', $output, $number);