Make WordPress Core


Ignore:
Timestamp:
02/24/2023 06:21:21 AM (13 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in bundled themes' PHP files.

This addresses all the remaining WPCS warnings in bundled themes.

Includes using the correct type when checking the number of comments, as get_comments_number() returns a numeric string, not an integer.

Follow-up to [41285], [44562], [47941].

Props aristath, poena, afercia, SergeyBiryukov.
See #56791.

Location:
trunk/src/wp-content/themes
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyeleven/comments.php

    r51157 r55420  
    3232        <h2 id="comments-title">
    3333            <?php
    34             if ( 1 === get_comments_number() ) {
     34            if ( '1' === get_comments_number() ) {
    3535                printf(
    3636                    /* translators: %s: The post title. */
  • trunk/src/wp-content/themes/twentyeleven/functions.php

    r54492 r55420  
    323323
    324324        // If no custom options for text are set, let's bail.
    325         if ( HEADER_TEXTCOLOR == $text_color ) {
     325        if ( HEADER_TEXTCOLOR === $text_color ) {
    326326            return;
    327327        }
     
    387387        <?php
    388388        // If the user has set a custom color for the text, use that.
    389         if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
     389        if ( get_header_textcolor() !== HEADER_TEXTCOLOR ) :
    390390            ?>
    391391    #site-title a,
     
    725725                    $avatar_size = 68;
    726726
    727                     if ( '0' != $comment->comment_parent ) {
     727                    if ( '0' !== $comment->comment_parent ) {
    728728                        $avatar_size = 39;
    729729                    }
     
    757757                    ?>
    758758
    759                     <?php if ( '0' == $comment->comment_approved ) : ?>
     759                    <?php if ( '0' === $comment->comment_approved ) : ?>
    760760                    <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
    761761                    <br />
  • trunk/src/wp-content/themes/twentyeleven/image.php

    r49539 r55420  
    7171                );
    7272                foreach ( $attachments as $k => $attachment ) {
    73                     if ( $attachment->ID == $post->ID ) {
     73                    if ( $attachment->ID === $post->ID ) {
    7474                        break;
    7575                    }
  • trunk/src/wp-content/themes/twentyeleven/inc/theme-options.php

    r55414 r55420  
    447447
    448448    // Don't do anything if the current link color is the default.
    449     if ( $default_options['link_color'] == $link_color ) {
     449    if ( $default_options['link_color'] === $link_color ) {
    450450        return;
    451451    }
  • trunk/src/wp-content/themes/twentyeleven/showcase.php

    r54884 r55420  
    155155                                $featured->the_post();
    156156                                $counter_slider++;
    157                                 if ( 1 == $counter_slider ) {
     157                                if ( 1 === $counter_slider ) {
    158158                                    $class = ' class="active"';
    159159                                } else {
  • trunk/src/wp-content/themes/twentyfourteen/functions.php

    r55413 r55420  
    472472        if ( count( $attachment_ids ) > 1 ) {
    473473            foreach ( $attachment_ids as $idx => $attachment_id ) {
    474                 if ( $attachment_id == $post->ID ) {
     474                if ( $attachment_id === $post->ID ) {
    475475                    $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ];
    476476                    break;
  • trunk/src/wp-content/themes/twentyfourteen/inc/custom-header.php

    r51541 r55420  
    8383            <?php
    8484            // If the user has set a custom color for the text, use that.
    85         elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) :
     85        elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) :
    8686            ?>
    8787        .site-title a {
  • trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php

    r48121 r55420  
    263263        $settings = self::get_setting();
    264264
    265         if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) {
     265        if ( empty( $settings['tag-id'] ) || $tag_id !== $settings['tag-id'] ) {
    266266            return;
    267267        }
  • trunk/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php

    r54885 r55420  
    3737                        $comment_author     = get_comment_author( $comment );
    3838                        $avatar             = get_avatar( $comment, $args['avatar_size'] );
    39                         if ( 0 != $args['avatar_size'] ) {
     39                        if ( 0 !== (int) $args['avatar_size'] ) {
    4040                            if ( empty( $comment_author_url ) ) {
    4141                                echo $avatar;
     
    9999                    ?>
    100100
    101                     <?php if ( '0' == $comment->comment_approved ) : ?>
     101                    <?php if ( '0' === $comment->comment_approved ) : ?>
    102102                    <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p>
    103103                    <?php endif; ?>
  • trunk/src/wp-content/themes/twentynineteen/comments.php

    r52993 r55420  
    3636            }
    3737        } else {
    38             if ( '1' == $discussion->responses ) {
     38            if ( '1' === (string) $discussion->responses ) {
    3939                /* translators: %s: Post title. */
    4040                printf( _x( 'One reply on &ldquo;%s&rdquo;', 'comments title', 'twentynineteen' ), get_the_title() );
  • trunk/src/wp-content/themes/twentyten/comments.php

    r51157 r55420  
    3535            <h3 id="comments-title">
    3636            <?php
    37             if ( 1 === get_comments_number() ) {
     37            if ( '1' === get_comments_number() ) {
    3838                printf(
    3939                    /* translators: %s: The post title. */
  • trunk/src/wp-content/themes/twentyten/functions.php

    r54492 r55420  
    440440                ?>
    441441
    442                 <?php if ( '0' == $comment->comment_approved ) : ?>
     442                <?php if ( '0' === $comment->comment_approved ) : ?>
    443443            <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
    444444            <br />
  • trunk/src/wp-content/themes/twentyten/loop-attachment.php

    r54882 r55420  
    101101            );
    102102            foreach ( $attachments as $k => $attachment ) {
    103                 if ( $attachment->ID == $post->ID ) {
     103                if ( $attachment->ID === $post->ID ) {
    104104                    break;
    105105                }
  • trunk/src/wp-content/themes/twentythirteen/comments.php

    r55276 r55420  
    2424        <h2 class="comments-title">
    2525            <?php
    26             if ( 1 === get_comments_number() ) {
     26            if ( '1' === get_comments_number() ) {
    2727                printf(
    2828                    /* translators: %s: The post title. */
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r55413 r55420  
    653653        if ( count( $attachment_ids ) > 1 ) {
    654654            foreach ( $attachment_ids as $idx => $attachment_id ) {
    655                 if ( $attachment_id == $post->ID ) {
     655                if ( $attachment_id === $post->ID ) {
    656656                    $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ];
    657657                    break;
  • trunk/src/wp-content/themes/twentythirteen/image.php

    r51967 r55420  
    3131                    $published_text = '<span class="attachment-meta">' . $published_text . '</span>';
    3232                    $post_title     = get_the_title( $post->post_parent );
    33                     if ( empty( $post_title ) || 0 == $post->post_parent ) {
     33                    if ( empty( $post_title ) || 0 === $post->post_parent ) {
    3434                        $published_text = '<span class="attachment-meta"><time class="entry-date" datetime="%1$s">%2$s</time></span>';
    3535                    }
  • trunk/src/wp-content/themes/twentythirteen/inc/custom-header.php

    r47219 r55420  
    9191
    9292    // If no custom options for text are set, let's bail.
    93     if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) {
     93    if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) {
    9494        return;
    9595    }
     
    137137
    138138        // If the user has set a custom color for the text, use that.
    139         elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) :
     139        elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) :
    140140            ?>
    141141        .site-title,
  • trunk/src/wp-content/themes/twentytwelve/comments.php

    r51967 r55420  
    3030        <h2 class="comments-title">
    3131            <?php
    32             if ( 1 === get_comments_number() ) {
     32            if ( '1' === get_comments_number() ) {
    3333                printf(
    3434                    /* translators: %s: The post title. */
  • trunk/src/wp-content/themes/twentytwelve/functions.php

    r55277 r55420  
    462462                ?>
    463463
    464                 <?php if ( '0' == $comment->comment_approved ) : ?>
     464                <?php if ( '0' === $comment->comment_approved ) : ?>
    465465                <p class="comment-awaiting-moderation"><?php echo $moderation_note; ?></p>
    466466                <?php endif; ?>
  • trunk/src/wp-content/themes/twentytwelve/image.php

    r51967 r55420  
    7171            );
    7272            foreach ( $attachments as $k => $attachment ) :
    73                 if ( $attachment->ID == $post->ID ) {
     73                if ( $attachment->ID === $post->ID ) {
    7474                    break;
    7575                }
  • trunk/src/wp-content/themes/twentytwelve/inc/custom-header.php

    r47219 r55420  
    7272
    7373    // If no custom options for text are set, let's bail.
    74     if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) {
     74    if ( get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) {
    7575        return;
    7676    }
  • trunk/src/wp-content/themes/twentytwenty/comments.php

    r47941 r55420  
    2424
    2525        <?php
    26         $comments_number = absint( get_comments_number() );
     26        $comments_number = get_comments_number();
    2727        ?>
    2828
     
    3333            if ( ! have_comments() ) {
    3434                _e( 'Leave a comment', 'twentytwenty' );
    35             } elseif ( 1 === $comments_number ) {
     35            } elseif ( '1' === $comments_number ) {
    3636                /* translators: %s: Post title. */
    3737                printf( _x( 'One reply on &ldquo;%s&rdquo;', 'comments title', 'twentytwenty' ), get_the_title() );
Note: See TracChangeset for help on using the changeset viewer.