Skip to content

Commit 130751c

Browse files
Coding Standards: Use Yoda conditions where appropriate.
See #49222. git-svn-id: https://develop.svn.wordpress.org/trunk@47219 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 40ffe0e commit 130751c

124 files changed

Lines changed: 554 additions & 554 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/wp-admin/admin-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,6 @@
288288
*/
289289
do_action( 'all_admin_notices' );
290290

291-
if ( $parent_file == 'options-general.php' ) {
291+
if ( 'options-general.php' === $parent_file ) {
292292
require ABSPATH . 'wp-admin/options-head.php';
293293
}

src/wp-admin/comment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
}
102102

103103
// No need to re-approve/re-trash/re-spam a comment.
104-
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
104+
if ( str_replace( '1', 'approve', $comment->comment_approved ) == $action ) {
105105
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
106106
die();
107107
}
@@ -137,7 +137,7 @@
137137
break;
138138
}
139139

140-
if ( $comment->comment_approved != '0' ) { // If not unapproved.
140+
if ( '0' != $comment->comment_approved ) { // If not unapproved.
141141
$message = '';
142142
switch ( $comment->comment_approved ) {
143143
case '1':

src/wp-admin/edit-comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
$doaction = 'delete';
3232
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
3333
$comment_ids = $_REQUEST['delete_comments'];
34-
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
34+
$doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
3535
} elseif ( isset( $_REQUEST['ids'] ) ) {
3636
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
3737
} elseif ( wp_get_referer() ) {

src/wp-admin/edit-form-advanced.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
7777
$action = isset( $action ) ? $action : '';
7878

79-
if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
79+
if ( get_option( 'page_for_posts' ) == $post_ID && empty( $post->post_content ) ) {
8080
add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
8181
remove_post_type_support( $post_type, 'editor' );
8282
}
@@ -534,7 +534,7 @@
534534
if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
535535
$shortlink = wp_get_shortlink( $post->ID, 'post' );
536536

537-
if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
537+
if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
538538
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
539539
}
540540
}

src/wp-admin/includes/ajax-actions.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function wp_ajax_ajax_tag_search() {
149149
* Require $term_search_min_chars chars for matching (default: 2)
150150
* ensure it's a non-negative, non-zero integer.
151151
*/
152-
if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ) {
152+
if ( ( 0 == $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) {
153153
wp_die();
154154
}
155155

@@ -295,14 +295,14 @@ function wp_ajax_autocomplete_user() {
295295
$id = get_current_blog_id();
296296
}
297297

298-
$include_blog_users = ( $type == 'search' ? get_users(
298+
$include_blog_users = ( 'search' === $type ? get_users(
299299
array(
300300
'blog_id' => $id,
301301
'fields' => 'ID',
302302
)
303303
) : array() );
304304

305-
$exclude_blog_users = ( $type == 'add' ? get_users(
305+
$exclude_blog_users = ( 'add' === $type ? get_users(
306306
array(
307307
'blog_id' => $id,
308308
'fields' => 'ID',
@@ -391,7 +391,7 @@ function wp_ajax_dashboard_widgets() {
391391
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
392392

393393
$pagenow = $_GET['pagenow'];
394-
if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) {
394+
if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) {
395395
set_current_screen( $pagenow );
396396
}
397397

@@ -573,7 +573,7 @@ function _wp_ajax_add_hierarchical_term() {
573573
$parent = 0;
574574
}
575575

576-
if ( $taxonomy->name == 'category' ) {
576+
if ( 'category' === $taxonomy->name ) {
577577
$post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array();
578578
} else {
579579
$post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array();
@@ -717,7 +717,7 @@ function wp_ajax_delete_comment() {
717717
$r = wp_untrash_comment( $comment );
718718

719719
// Undo trash, not in trash.
720-
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
720+
if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) {
721721
$delta = 1;
722722
}
723723
} elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
@@ -734,7 +734,7 @@ function wp_ajax_delete_comment() {
734734
$r = wp_unspam_comment( $comment );
735735

736736
// Undo spam, not in spam.
737-
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
737+
if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) {
738738
$delta = 1;
739739
}
740740
} elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
@@ -1318,7 +1318,7 @@ function wp_ajax_replyto_comment( $action ) {
13181318
if ( ! empty( $_POST['approve_parent'] ) ) {
13191319
$parent = get_comment( $comment_parent );
13201320

1321-
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
1321+
if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_ID ) {
13221322
if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
13231323
wp_die( -1 );
13241324
}
@@ -1549,7 +1549,7 @@ function wp_ajax_add_meta() {
15491549
}
15501550

15511551
// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
1552-
if ( $post->post_status == 'auto-draft' ) {
1552+
if ( 'auto-draft' === $post->post_status ) {
15531553
$post_data = array();
15541554
$post_data['action'] = 'draft'; // Warning fix.
15551555
$post_data['post_ID'] = $pid;
@@ -1720,7 +1720,7 @@ function wp_ajax_closed_postboxes() {
17201720

17211721
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
17221722

1723-
if ( $page != sanitize_key( $page ) ) {
1723+
if ( sanitize_key( $page ) != $page ) {
17241724
wp_die( 0 );
17251725
}
17261726

@@ -1751,7 +1751,7 @@ function wp_ajax_hidden_columns() {
17511751
check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
17521752
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
17531753

1754-
if ( $page != sanitize_key( $page ) ) {
1754+
if ( sanitize_key( $page ) != $page ) {
17551755
wp_die( 0 );
17561756
}
17571757

@@ -1900,13 +1900,13 @@ function wp_ajax_meta_box_order() {
19001900
$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
19011901
$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
19021902

1903-
if ( $page_columns != 'auto' ) {
1903+
if ( 'auto' !== $page_columns ) {
19041904
$page_columns = (int) $page_columns;
19051905
}
19061906

19071907
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
19081908

1909-
if ( $page != sanitize_key( $page ) ) {
1909+
if ( sanitize_key( $page ) != $page ) {
19101910
wp_die( 0 );
19111911
}
19121912

@@ -2003,7 +2003,7 @@ function wp_ajax_inline_save() {
20032003
/* translators: %s: User's display name. */
20042004
$msg_template = __( 'Saving is disabled: %s is currently editing this post.' );
20052005

2006-
if ( $_POST['post_type'] == 'page' ) {
2006+
if ( 'page' === $_POST['post_type'] ) {
20072007
/* translators: %s: User's display name. */
20082008
$msg_template = __( 'Saving is disabled: %s is currently editing this page.' );
20092009
}
@@ -2067,7 +2067,7 @@ function wp_ajax_inline_save() {
20672067

20682068
$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
20692069

2070-
$mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list';
2070+
$mode = 'excerpt' === $_POST['post_view'] ? 'excerpt' : 'list';
20712071

20722072
$level = 0;
20732073
if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) {
@@ -2639,7 +2639,7 @@ function wp_ajax_set_post_thumbnail() {
26392639
check_ajax_referer( "set_post_thumbnail-$post_ID" );
26402640
}
26412641

2642-
if ( $thumbnail_id == '-1' ) {
2642+
if ( '-1' == $thumbnail_id ) {
26432643
if ( delete_post_thumbnail( $post_ID ) ) {
26442644
$return = _wp_post_thumbnail_html( null, $post_ID );
26452645
$json ? wp_send_json_success( $return ) : wp_die( $return );
@@ -2819,7 +2819,7 @@ function wp_ajax_wp_remove_post_lock() {
28192819

28202820
$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
28212821

2822-
if ( $active_lock[1] != get_current_user_id() ) {
2822+
if ( get_current_user_id() != $active_lock[1] ) {
28232823
wp_die( 0 );
28242824
}
28252825

@@ -2844,7 +2844,7 @@ function wp_ajax_wp_remove_post_lock() {
28442844
function wp_ajax_dismiss_wp_pointer() {
28452845
$pointer = $_POST['pointer'];
28462846

2847-
if ( $pointer != sanitize_key( $pointer ) ) {
2847+
if ( sanitize_key( $pointer ) != $pointer ) {
28482848
wp_die( 0 );
28492849
}
28502850

@@ -3022,7 +3022,7 @@ function wp_ajax_save_attachment() {
30223022

30233023
if ( isset( $changes['alt'] ) ) {
30243024
$alt = wp_unslash( $changes['alt'] );
3025-
if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
3025+
if ( get_post_meta( $id, '_wp_attachment_image_alt', true ) !== $alt ) {
30263026
$alt = wp_strip_all_tags( $alt, true );
30273027
update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
30283028
}
@@ -3816,7 +3816,7 @@ function wp_ajax_destroy_sessions() {
38163816

38173817
$sessions = WP_Session_Tokens::get_instance( $user->ID );
38183818

3819-
if ( $user->ID === get_current_user_id() ) {
3819+
if ( get_current_user_id() === $user->ID ) {
38203820
$sessions->destroy_others( wp_get_session_token() );
38213821
$message = __( 'You are now logged out everywhere else.' );
38223822
} else {

src/wp-admin/includes/class-core-upgrader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function upgrade( $current, $args = array() ) {
7878
$this->upgrade_strings();
7979

8080
// Is an update available?
81-
if ( ! isset( $current->response ) || $current->response == 'latest' ) {
81+
if ( ! isset( $current->response ) || 'latest' === $current->response ) {
8282
return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
8383
}
8484

src/wp-admin/includes/class-custom-image-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public function step_2() {
812812

813813
// If flexible height isn't supported and the image is the exact right size.
814814
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' )
815-
&& $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) {
815+
&& get_theme_support( 'custom-header', 'width' ) == $width && get_theme_support( 'custom-header', 'height' ) == $height ) {
816816
// Add the metadata.
817817
if ( file_exists( $file ) ) {
818818
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );

src/wp-admin/includes/class-plugin-installer-skin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ public function after() {
8989
unset( $install_actions['activate_plugin'] );
9090
}
9191

92-
if ( 'import' == $from ) {
92+
if ( 'import' === $from ) {
9393
$install_actions['importers_page'] = sprintf(
9494
'<a href="%s" target="_parent">%s</a>',
9595
admin_url( 'import.php' ),
9696
__( 'Return to Importers' )
9797
);
98-
} elseif ( $this->type == 'web' ) {
98+
} elseif ( 'web' === $this->type ) {
9999
$install_actions['plugins_page'] = sprintf(
100100
'<a href="%s" target="_parent">%s</a>',
101101
self_admin_url( 'plugin-install.php' ),
102102
__( 'Return to Plugin Installer' )
103103
);
104-
} elseif ( 'upload' == $this->type && 'plugins' == $from ) {
104+
} elseif ( 'upload' === $this->type && 'plugins' === $from ) {
105105
$install_actions['plugins_page'] = sprintf(
106106
'<a href="%s">%s</a>',
107107
self_admin_url( 'plugin-install.php' ),

src/wp-admin/includes/class-theme-installer-skin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function after() {
114114
);
115115
}
116116

117-
if ( $this->type == 'web' ) {
117+
if ( 'web' === $this->type ) {
118118
$install_actions['themes_page'] = sprintf(
119119
'<a href="%s" target="_parent">%s</a>',
120120
self_admin_url( 'theme-install.php' ),

src/wp-admin/includes/class-theme-upgrader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function bulk_upgrade( $themes, $args = array() ) {
367367
*/
368368
$maintenance = ( is_multisite() && ! empty( $themes ) );
369369
foreach ( $themes as $theme ) {
370-
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
370+
$maintenance = $maintenance || get_stylesheet() === $theme || get_template() === $theme;
371371
}
372372
if ( $maintenance ) {
373373
$this->maintenance_mode( true );
@@ -539,7 +539,7 @@ public function current_before( $return, $theme ) {
539539

540540
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
541541

542-
if ( $theme != get_stylesheet() ) { // If not current.
542+
if ( get_stylesheet() !== $theme ) { // If not current.
543543
return $return;
544544
}
545545

@@ -570,12 +570,12 @@ public function current_after( $return, $theme ) {
570570

571571
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
572572

573-
if ( $theme != get_stylesheet() ) { // If not current.
573+
if ( get_stylesheet() !== $theme ) { // If not current.
574574
return $return;
575575
}
576576

577577
// Ensure stylesheet name hasn't changed after the upgrade:
578-
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
578+
if ( get_stylesheet() === $theme && $theme != $this->result['destination_name'] ) {
579579
wp_clean_themes_cache();
580580
$stylesheet = $this->result['destination_name'];
581581
switch_theme( $stylesheet );

0 commit comments

Comments
 (0)