From 5fd8bed76b2d102ce51f38245908fd3b6cc13441 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 24 Feb 2023 06:21:21 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@55420 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-content/themes/twentyeleven/comments.php | 2 +- src/wp-content/themes/twentyeleven/functions.php | 8 ++++---- src/wp-content/themes/twentyeleven/image.php | 2 +- src/wp-content/themes/twentyeleven/inc/theme-options.php | 2 +- src/wp-content/themes/twentyeleven/showcase.php | 2 +- src/wp-content/themes/twentyfourteen/functions.php | 2 +- .../themes/twentyfourteen/inc/custom-header.php | 2 +- .../themes/twentyfourteen/inc/featured-content.php | 2 +- .../classes/class-twentynineteen-walker-comment.php | 4 ++-- src/wp-content/themes/twentynineteen/comments.php | 2 +- src/wp-content/themes/twentyten/comments.php | 2 +- src/wp-content/themes/twentyten/functions.php | 2 +- src/wp-content/themes/twentyten/loop-attachment.php | 2 +- src/wp-content/themes/twentythirteen/comments.php | 2 +- src/wp-content/themes/twentythirteen/functions.php | 2 +- src/wp-content/themes/twentythirteen/image.php | 2 +- .../themes/twentythirteen/inc/custom-header.php | 4 ++-- src/wp-content/themes/twentytwelve/comments.php | 2 +- src/wp-content/themes/twentytwelve/functions.php | 2 +- src/wp-content/themes/twentytwelve/image.php | 2 +- src/wp-content/themes/twentytwelve/inc/custom-header.php | 2 +- src/wp-content/themes/twentytwenty/comments.php | 4 ++-- 22 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/wp-content/themes/twentyeleven/comments.php b/src/wp-content/themes/twentyeleven/comments.php index 102899645d..0787c43b22 100644 --- a/src/wp-content/themes/twentyeleven/comments.php +++ b/src/wp-content/themes/twentyeleven/comments.php @@ -31,7 +31,7 @@

#site-title a, #site-description { @@ -724,7 +724,7 @@ if ( ! function_exists( 'twentyeleven_comment' ) ) : comment_parent ) { + if ( '0' !== $comment->comment_parent ) { $avatar_size = 39; } @@ -756,7 +756,7 @@ if ( ! function_exists( 'twentyeleven_comment' ) ) : } ?> - comment_approved ) : ?> + comment_approved ) : ?>
diff --git a/src/wp-content/themes/twentyeleven/image.php b/src/wp-content/themes/twentyeleven/image.php index 097ff19cc3..a727ea147a 100644 --- a/src/wp-content/themes/twentyeleven/image.php +++ b/src/wp-content/themes/twentyeleven/image.php @@ -70,7 +70,7 @@ get_header(); ?> ) ); foreach ( $attachments as $k => $attachment ) { - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } } diff --git a/src/wp-content/themes/twentyeleven/inc/theme-options.php b/src/wp-content/themes/twentyeleven/inc/theme-options.php index 816fa93fbb..c40768bcac 100644 --- a/src/wp-content/themes/twentyeleven/inc/theme-options.php +++ b/src/wp-content/themes/twentyeleven/inc/theme-options.php @@ -446,7 +446,7 @@ function twentyeleven_print_link_color_style() { $default_options = twentyeleven_get_default_theme_options(); // Don't do anything if the current link color is the default. - if ( $default_options['link_color'] == $link_color ) { + if ( $default_options['link_color'] === $link_color ) { return; } ?> diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index 7bcf05df9f..a51d53e100 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -154,7 +154,7 @@ get_header(); ?> while ( $featured->have_posts() ) : $featured->the_post(); $counter_slider++; - if ( 1 == $counter_slider ) { + if ( 1 === $counter_slider ) { $class = ' class="active"'; } else { $class = ''; diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php index ff42a06798..91c65384ae 100644 --- a/src/wp-content/themes/twentyfourteen/functions.php +++ b/src/wp-content/themes/twentyfourteen/functions.php @@ -471,7 +471,7 @@ if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) : // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $idx => $attachment_id ) { - if ( $attachment_id == $post->ID ) { + if ( $attachment_id === $post->ID ) { $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } diff --git a/src/wp-content/themes/twentyfourteen/inc/custom-header.php b/src/wp-content/themes/twentyfourteen/inc/custom-header.php index dc34e0244e..d6692dbb41 100644 --- a/src/wp-content/themes/twentyfourteen/inc/custom-header.php +++ b/src/wp-content/themes/twentyfourteen/inc/custom-header.php @@ -82,7 +82,7 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) : } .site-title a { color: #; diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php index da8b76f715..ed7c661c42 100644 --- a/src/wp-content/themes/twentyfourteen/inc/featured-content.php +++ b/src/wp-content/themes/twentyfourteen/inc/featured-content.php @@ -262,7 +262,7 @@ class Featured_Content { public static function delete_post_tag( $tag_id ) { $settings = self::get_setting(); - if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) { + if ( empty( $settings['tag-id'] ) || $tag_id !== $settings['tag-id'] ) { return; } diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php index f501de695a..3ab2c4bf29 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php @@ -36,7 +36,7 @@ class TwentyNineteen_Walker_Comment extends Walker_Comment { $comment_author_url = get_comment_author_url( $comment ); $comment_author = get_comment_author( $comment ); $avatar = get_avatar( $comment, $args['avatar_size'] ); - if ( 0 != $args['avatar_size'] ) { + if ( 0 !== (int) $args['avatar_size'] ) { if ( empty( $comment_author_url ) ) { echo $avatar; } else { @@ -98,7 +98,7 @@ class TwentyNineteen_Walker_Comment extends Walker_Comment { } ?> - comment_approved ) : ?> + comment_approved ) : ?>

diff --git a/src/wp-content/themes/twentynineteen/comments.php b/src/wp-content/themes/twentynineteen/comments.php index 9ef3fd6acc..5e734d417e 100644 --- a/src/wp-content/themes/twentynineteen/comments.php +++ b/src/wp-content/themes/twentynineteen/comments.php @@ -35,7 +35,7 @@ $discussion = twentynineteen_get_discussion_data(); _e( 'Leave a comment', 'twentynineteen' ); } } else { - if ( '1' == $discussion->responses ) { + if ( '1' === (string) $discussion->responses ) { /* translators: %s: Post title. */ printf( _x( 'One reply on “%s”', 'comments title', 'twentynineteen' ), get_the_title() ); } else { diff --git a/src/wp-content/themes/twentyten/comments.php b/src/wp-content/themes/twentyten/comments.php index 31425239d0..64bf700b8d 100644 --- a/src/wp-content/themes/twentyten/comments.php +++ b/src/wp-content/themes/twentyten/comments.php @@ -34,7 +34,7 @@

- comment_approved ) : ?> + comment_approved ) : ?>
diff --git a/src/wp-content/themes/twentyten/loop-attachment.php b/src/wp-content/themes/twentyten/loop-attachment.php index d3f6eb4871..007b5aa036 100644 --- a/src/wp-content/themes/twentyten/loop-attachment.php +++ b/src/wp-content/themes/twentyten/loop-attachment.php @@ -100,7 +100,7 @@ if ( have_posts() ) { ) ); foreach ( $attachments as $k => $attachment ) { - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } } diff --git a/src/wp-content/themes/twentythirteen/comments.php b/src/wp-content/themes/twentythirteen/comments.php index e4906bf700..15d0968256 100644 --- a/src/wp-content/themes/twentythirteen/comments.php +++ b/src/wp-content/themes/twentythirteen/comments.php @@ -23,7 +23,7 @@ if ( post_password_required() ) {

1 ) { foreach ( $attachment_ids as $idx => $attachment_id ) { - if ( $attachment_id == $post->ID ) { + if ( $attachment_id === $post->ID ) { $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } diff --git a/src/wp-content/themes/twentythirteen/image.php b/src/wp-content/themes/twentythirteen/image.php index 886eb225bf..26ca20a094 100644 --- a/src/wp-content/themes/twentythirteen/image.php +++ b/src/wp-content/themes/twentythirteen/image.php @@ -30,7 +30,7 @@ get_header(); ?> $published_text = __( 'Published on in %5$s', 'twentythirteen' ); $published_text = '' . $published_text . ''; $post_title = get_the_title( $post->post_parent ); - if ( empty( $post_title ) || 0 == $post->post_parent ) { + if ( empty( $post_title ) || 0 === $post->post_parent ) { $published_text = ''; } diff --git a/src/wp-content/themes/twentythirteen/inc/custom-header.php b/src/wp-content/themes/twentythirteen/inc/custom-header.php index 7bbb50ec35..b87eaa058f 100644 --- a/src/wp-content/themes/twentythirteen/inc/custom-header.php +++ b/src/wp-content/themes/twentythirteen/inc/custom-header.php @@ -90,7 +90,7 @@ function twentythirteen_header_style() { $text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. - if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) { + if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) { return; } @@ -136,7 +136,7 @@ function twentythirteen_header_style() { endif; // If the user has set a custom color for the text, use that. - elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) : + elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) : ?> .site-title, .site-description { diff --git a/src/wp-content/themes/twentytwelve/comments.php b/src/wp-content/themes/twentytwelve/comments.php index 4fea7d574a..a7aa3f21a5 100644 --- a/src/wp-content/themes/twentytwelve/comments.php +++ b/src/wp-content/themes/twentytwelve/comments.php @@ -29,7 +29,7 @@ if ( post_password_required() ) {

- comment_approved ) : ?> + comment_approved ) : ?>

diff --git a/src/wp-content/themes/twentytwelve/image.php b/src/wp-content/themes/twentytwelve/image.php index 8958092c87..ffdde2c00d 100644 --- a/src/wp-content/themes/twentytwelve/image.php +++ b/src/wp-content/themes/twentytwelve/image.php @@ -70,7 +70,7 @@ get_header(); ?> ) ); foreach ( $attachments as $k => $attachment ) : - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } endforeach; diff --git a/src/wp-content/themes/twentytwelve/inc/custom-header.php b/src/wp-content/themes/twentytwelve/inc/custom-header.php index 693883ca7a..84b3556c24 100644 --- a/src/wp-content/themes/twentytwelve/inc/custom-header.php +++ b/src/wp-content/themes/twentytwelve/inc/custom-header.php @@ -71,7 +71,7 @@ function twentytwelve_header_style() { $text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. - if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) { + if ( get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) { return; } diff --git a/src/wp-content/themes/twentytwenty/comments.php b/src/wp-content/themes/twentytwenty/comments.php index 2bee32644d..91a3198eed 100644 --- a/src/wp-content/themes/twentytwenty/comments.php +++ b/src/wp-content/themes/twentytwenty/comments.php @@ -23,7 +23,7 @@ if ( $comments ) {
@@ -32,7 +32,7 @@ if ( $comments ) {