WordPress.org

Make WordPress Core

Ticket #4964: comments-template.patch

File comments-template.patch, 1.0 KB (added by Viper007Bond, 7 years ago)

An even safer check (you know, like allow for 0 and stuff)

  • wp-includes/comment-template.php

     
    161161        return apply_filters('get_comments_number', $count); 
    162162} 
    163163 
    164 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 
     164function comments_number( $zero = false, $one = false, $more = false, $number = '' ) { 
    165165        global $id; 
    166         $number = get_comments_number($id); 
     166        if ( !is_numeric($number) ) $number = get_comments_number($id); 
    167167 
    168168        if ( $number > 1 ) 
    169169                $output = str_replace('%', $number, ( false === $more ) ? __('% Comments') : $more); 
    170         elseif ( $number == 0 ) 
     170        elseif ( $number == 1 ) 
     171                $output = ( false === $one ) ? __('1 Comment') : $one; 
     172        else // must be 0 or something out of range 
    171173                $output = ( false === $zero ) ? __('No Comments') : $zero; 
    172         else // must be one 
    173                 $output = ( false === $one ) ? __('1 Comment') : $one; 
    174174 
    175175        echo apply_filters('comments_number', $output, $number); 
    176176}