Skip to content

Commit 9c42e15

Browse files
committed
$status shouldn't be loosely compared to true in wp_xmlrpc_server::wp_deleteComment().
`$initial` shouldn't be loosely compared to `true` in `get_calendar()`. `current_user_can()` shouldn't be loosely compared to `false` in `kses_init()` `$get_all` shouldn't be loosely compared to `true` in `get_blog_details()`. `is_array()` and `in_array()` shouldn't be loosely compared in `wpmu_validate_user_signup()`. `$result` should by strictly compared in `check_ajax_referer()`. `wp_verify_nonce()` should by strictly compared in `_show_post_preview()`. `is_user_logged_in()` should not be loosly compared against `false` in `wp-signup.php`. See #32444. git-svn-id: https://develop.svn.wordpress.org/trunk@32733 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6c8e2e1 commit 9c42e15

9 files changed

Lines changed: 20 additions & 18 deletions

File tree

src/wp-includes/class-wp-xmlrpc-server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3254,7 +3254,7 @@ public function wp_deleteComment($args) {
32543254

32553255
$status = wp_delete_comment( $comment_ID );
32563256

3257-
if ( true == $status ) {
3257+
if ( $status ) {
32583258
/**
32593259
* Fires after a comment has been successfully deleted via XML-RPC.
32603260
*

src/wp-includes/general-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ function get_calendar($initial = true, $echo = true) {
16451645
}
16461646

16471647
foreach ( $myweek as $wd ) {
1648-
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1648+
$day_name = $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
16491649
$wd = esc_attr($wd);
16501650
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
16511651
}

src/wp-includes/kses.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,9 @@ function kses_remove_filters() {
14611461
function kses_init() {
14621462
kses_remove_filters();
14631463

1464-
if (current_user_can('unfiltered_html') == false)
1464+
if ( ! current_user_can( 'unfiltered_html' ) ) {
14651465
kses_init_filters();
1466+
}
14661467
}
14671468

14681469
/**

src/wp-includes/ms-deprecated.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function get_most_active_blogs( $num = 10, $display = true ) {
210210
$most_active = $t;
211211
}
212212

213-
if ( $display == true ) {
213+
if ( $display ) {
214214
if ( is_array( $most_active ) ) {
215215
reset( $most_active );
216216
foreach ( (array) $most_active as $key => $details ) {
@@ -253,7 +253,7 @@ function wpmu_admin_do_redirect( $url = '' ) {
253253
wp_redirect( $ref );
254254
exit();
255255
}
256-
if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
256+
if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
257257
wp_redirect( $_SERVER['HTTP_REFERER'] );
258258
exit();
259259
}

src/wp-includes/ms-functions.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,11 @@ function wpmu_validate_user_signup($user_name, $user_email) {
481481
$errors->add('user_name', __( 'Please enter a username.' ) );
482482

483483
$illegal_names = get_site_option( 'illegal_names' );
484-
if ( is_array( $illegal_names ) == false ) {
484+
if ( ! is_array( $illegal_names ) ) {
485485
$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
486486
add_site_option( 'illegal_names', $illegal_names );
487487
}
488-
if ( in_array( $user_name, $illegal_names ) == true )
488+
if ( in_array( $user_name, $illegal_names ) )
489489
$errors->add('user_name', __( 'That username is not allowed.' ) );
490490

491491
if ( is_email_address_unsafe( $user_email ) )
@@ -505,10 +505,11 @@ function wpmu_validate_user_signup($user_name, $user_email) {
505505
$errors->add('user_email', __( 'Please enter a valid email address.' ) );
506506

507507
$limited_email_domains = get_site_option( 'limited_email_domains' );
508-
if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
508+
if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
509509
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
510-
if ( in_array( $emaildomain, $limited_email_domains ) == false )
510+
if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
511511
$errors->add('user_email', __('Sorry, that email address is not allowed!'));
512+
}
512513
}
513514

514515
// Check if the username has been used already.
@@ -627,7 +628,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
627628
if ( preg_match( '/[^a-z0-9]+/', $blogname ) )
628629
$errors->add('blogname', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
629630

630-
if ( in_array( $blogname, $illegal_names ) == true )
631+
if ( in_array( $blogname, $illegal_names ) )
631632
$errors->add('blogname', __( 'That name is not allowed.' ) );
632633

633634
if ( strlen( $blogname ) < 4 && !is_super_admin() )
@@ -673,7 +674,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
673674
$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
674675

675676
if ( username_exists( $blogname ) ) {
676-
if ( is_object( $user ) == false || ( is_object($user) && ( $user->user_login != $blogname ) ) )
677+
if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
677678
$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
678679
}
679680

@@ -1689,7 +1690,7 @@ function get_dirsize( $directory ) {
16891690
if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
16901691
return $dirsize[ $directory ][ 'size' ];
16911692

1692-
if ( false == is_array( $dirsize ) )
1693+
if ( ! is_array( $dirsize ) )
16931694
$dirsize = array();
16941695

16951696
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );

src/wp-includes/pluggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
11371137

11381138
$result = wp_verify_nonce( $nonce, $action );
11391139

1140-
if ( $die && false == $result ) {
1140+
if ( $die && false === $result ) {
11411141
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
11421142
wp_die( -1 );
11431143
else

src/wp-includes/revision.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ function _show_post_preview() {
522522
if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) {
523523
$id = (int) $_GET['preview_id'];
524524

525-
if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) )
525+
if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) )
526526
wp_die( __('You do not have permission to preview drafts.') );
527527

528528
add_filter('the_preview', '_set_preview');

src/wp-signup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
99

10-
if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
10+
if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) {
1111
wp_redirect( network_home_url() );
1212
die();
1313
}
@@ -700,9 +700,9 @@ function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $use
700700
do_action( 'preprocess_signup_form' );
701701
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
702702
signup_another_blog($newblogname);
703-
elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
703+
elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
704704
signup_user( $newblogname, $user_email );
705-
elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
705+
elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
706706
_e( 'Sorry, new registrations are not allowed at this time.' );
707707
else
708708
_e( 'You are logged in already. No need to register again!' );

tests/phpunit/tests/customize/setting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ function test_is_current_blog_previewed() {
379379
$post_value = rand_str();
380380
$this->manager->set_post_value( $name, $post_value );
381381
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
382-
$this->assertNull( $setting->is_current_blog_previewed() );
382+
$this->assertFalse( $setting->is_current_blog_previewed() );
383383
$setting->preview();
384384
$this->assertTrue( $setting->is_current_blog_previewed() );
385385

0 commit comments

Comments
 (0)