Skip to content

Commit 5fd8bed

Browse files
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
1 parent b394c9c commit 5fd8bed

File tree

22 files changed

+28
-28
lines changed

22 files changed

+28
-28
lines changed

src/wp-content/themes/twentyeleven/comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<?php if ( have_comments() ) : ?>
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. */
3737
__( 'One thought on &ldquo;%1$s&rdquo;', 'twentyeleven' ),

src/wp-content/themes/twentyeleven/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function twentyeleven_header_style() {
322322
$text_color = get_header_textcolor();
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
}
328328

@@ -386,7 +386,7 @@ function twentyeleven_admin_header_style() {
386386
}
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,
392392
#site-description {
@@ -724,7 +724,7 @@ function twentyeleven_comment( $comment, $args, $depth ) {
724724
<?php
725725
$avatar_size = 68;
726726

727-
if ( '0' != $comment->comment_parent ) {
727+
if ( '0' !== $comment->comment_parent ) {
728728
$avatar_size = 39;
729729
}
730730

@@ -756,7 +756,7 @@ function twentyeleven_comment( $comment, $args, $depth ) {
756756
}
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 />
762762
<?php endif; ?>

src/wp-content/themes/twentyeleven/image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
)
7171
);
7272
foreach ( $attachments as $k => $attachment ) {
73-
if ( $attachment->ID == $post->ID ) {
73+
if ( $attachment->ID === $post->ID ) {
7474
break;
7575
}
7676
}

src/wp-content/themes/twentyeleven/inc/theme-options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function twentyeleven_print_link_color_style() {
446446
$default_options = twentyeleven_get_default_theme_options();
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
}
452452
?>

src/wp-content/themes/twentyeleven/showcase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
while ( $featured->have_posts() ) :
155155
$featured->the_post();
156156
$counter_slider++;
157-
if ( 1 == $counter_slider ) {
157+
if ( 1 === $counter_slider ) {
158158
$class = ' class="active"';
159159
} else {
160160
$class = '';

src/wp-content/themes/twentyfourteen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ function twentyfourteen_the_attached_image() {
471471
// If there is more than 1 attachment in a gallery...
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;
477477
}

src/wp-content/themes/twentyfourteen/inc/custom-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function twentyfourteen_header_style() {
8282
}
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 {
8888
color: #<?php echo esc_attr( $text_color ); ?>;

src/wp-content/themes/twentyfourteen/inc/featured-content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public static function pre_get_posts( $query ) {
262262
public static function delete_post_tag( $tag_id ) {
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
}
268268

src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function html5_comment( $comment, $depth, $args ) {
3636
$comment_author_url = get_comment_author_url( $comment );
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;
4242
} else {
@@ -98,7 +98,7 @@ protected function html5_comment( $comment, $depth, $args ) {
9898
}
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; ?>
104104

src/wp-content/themes/twentynineteen/comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
_e( 'Leave a comment', 'twentynineteen' );
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() );
4141
} else {

0 commit comments

Comments
 (0)