WordPress.org

Making WordPress.org

Changeset 5973


Ignore:
Timestamp:
09/28/2017 07:11:32 PM (23 months ago)
Author:
coreymckrill
Message:

WordCamp Base: Make sure comment number comparison works as expected

From @sergeybiryukov:

get_comments_number() returns a numeric string, strictly comparing
it to an integer doesn't work as expected

This emulates Twenty Seventeen, which handles the comparison correctly.

Refs #3156

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-base/comments.php

    r5972 r5973  
    3434            <h3 id="comments-title">
    3535                <?php
    36                 if ( 1 === get_comments_number() ) {
    37                     printf(
    38                         /* translators: %s: post title */
    39                         esc_html_x( 'One Response to &ldquo;%s&rdquo;', 'comments title', 'wordcamporg' ),
    40                         '<span>' . get_the_title() . '</span>'
    41                     );
     36                $comments_number = get_comments_number();
     37                if ( '1' === $comments_number ) {
     38                    printf(
     39                        /* translators: %s: post title */
     40                        _x( 'One Response to &ldquo;%s&rdquo;', 'comments title', 'wordcamporg' ),
     41                        '<span>' . get_the_title() . '</span>'
     42                    );
    4243                } else {
    4344                    printf(
    4445                        /* translators: 1: number of comments, 2: post title */
    45                         esc_html( _nx( '%1$s Response to &ldquo;%2$s&rdquo;', '%1$s Responses to &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'wordcamporg' ) ),
    46                         number_format_i18n( get_comments_number() ),
     46                        _nx(
     47                            '%1$s Response to &ldquo;%2$s&rdquo;',
     48                            '%1$s Responses to &ldquo;%2$s&rdquo;',
     49                            $comments_number,
     50                            'comments title',
     51                            'wordcamporg'
     52                        ),
     53                        number_format_i18n( $comments_number ),
    4754                        '<span>' . get_the_title() . '</span>'
    4855                    );
Note: See TracChangeset for help on using the changeset viewer.