Coding Standards: Use Yoda conditions where appropriate.

See #49222.

git-svn-id: https://develop.svn.wordpress.org/trunk@47219 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-02-09 16:52:28 +00:00
parent 40ffe0ef06
commit 130751cda3
124 changed files with 554 additions and 554 deletions
+17 -17
View File
@@ -910,7 +910,7 @@ class WP_Query {
}
unset( $tax_query );
if ( empty( $qv['author'] ) || ( $qv['author'] == '0' ) ) {
if ( empty( $qv['author'] ) || ( '0' == $qv['author'] ) ) {
$this->is_author = false;
} else {
$this->is_author = true;
@@ -1017,25 +1017,25 @@ class WP_Query {
unset( $this->queried_object );
}
if ( 'page' == get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'page_for_posts' ) ) {
if ( 'page' === get_option( 'show_on_front' ) && isset( $this->queried_object_id ) && get_option( 'page_for_posts' ) == $this->queried_object_id ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
if ( isset( $this->queried_object_id ) && $this->queried_object_id == get_option( 'wp_page_for_privacy_policy' ) ) {
if ( isset( $this->queried_object_id ) && get_option( 'wp_page_for_privacy_policy' ) == $this->queried_object_id ) {
$this->is_privacy_policy = true;
}
}
if ( $qv['page_id'] ) {
if ( 'page' == get_option( 'show_on_front' ) && $qv['page_id'] == get_option( 'page_for_posts' ) ) {
if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == $qv['page_id'] ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
if ( $qv['page_id'] == get_option( 'wp_page_for_privacy_policy' ) ) {
if ( get_option( 'wp_page_for_privacy_policy' ) == $qv['page_id'] ) {
$this->is_privacy_policy = true;
}
}
@@ -1377,7 +1377,7 @@ class WP_Query {
foreach ( $q['search_terms'] as $term ) {
// If there is an $exclusion_prefix, terms prefixed with it should be excluded.
$exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) );
$exclude = $exclusion_prefix && ( substr( $term, 0, 1 ) === $exclusion_prefix );
if ( $exclude ) {
$like_op = 'NOT LIKE';
$andor_op = 'AND';
@@ -1861,11 +1861,11 @@ class WP_Query {
$q['showposts'] = (int) $q['showposts'];
$q['posts_per_page'] = $q['showposts'];
}
if ( ( isset( $q['posts_per_archive_page'] ) && $q['posts_per_archive_page'] != 0 ) && ( $this->is_archive || $this->is_search ) ) {
if ( ( isset( $q['posts_per_archive_page'] ) && 0 != $q['posts_per_archive_page'] ) && ( $this->is_archive || $this->is_search ) ) {
$q['posts_per_page'] = $q['posts_per_archive_page'];
}
if ( ! isset( $q['nopaging'] ) ) {
if ( $q['posts_per_page'] == -1 ) {
if ( -1 == $q['posts_per_page'] ) {
$q['nopaging'] = true;
} else {
$q['nopaging'] = false;
@@ -1884,15 +1884,15 @@ class WP_Query {
$q['posts_per_page'] = (int) $q['posts_per_page'];
if ( $q['posts_per_page'] < -1 ) {
$q['posts_per_page'] = abs( $q['posts_per_page'] );
} elseif ( $q['posts_per_page'] == 0 ) {
} elseif ( 0 == $q['posts_per_page'] ) {
$q['posts_per_page'] = 1;
}
if ( ! isset( $q['comments_per_page'] ) || $q['comments_per_page'] == 0 ) {
if ( ! isset( $q['comments_per_page'] ) || 0 == $q['comments_per_page'] ) {
$q['comments_per_page'] = get_option( 'comments_per_page' );
}
if ( $this->is_home && ( empty( $this->query ) || $q['preview'] == 'true' ) && ( 'page' == get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
if ( $this->is_home && ( empty( $this->query ) || 'true' === $q['preview'] ) && ( 'page' === get_option( 'show_on_front' ) ) && get_option( 'page_on_front' ) ) {
$this->is_page = true;
$this->is_home = false;
$q['page_id'] = get_option( 'page_on_front' );
@@ -2096,7 +2096,7 @@ class WP_Query {
}
if ( $q['page_id'] ) {
if ( ( 'page' != get_option( 'show_on_front' ) ) || ( $q['page_id'] != get_option( 'page_for_posts' ) ) ) {
if ( ( 'page' !== get_option( 'show_on_front' ) ) || ( get_option( 'page_for_posts' ) != $q['page_id'] ) ) {
$q['p'] = $q['page_id'];
$where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
}
@@ -2135,7 +2135,7 @@ class WP_Query {
$post_type = array();
$taxonomies = array_keys( $this->tax_query->queried_terms );
foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
$object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
if ( array_intersect( $taxonomies, $object_taxonomies ) ) {
$post_type[] = $pt;
}
@@ -2214,7 +2214,7 @@ class WP_Query {
// Author/user stuff.
if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
if ( ! empty( $q['author'] ) && '0' != $q['author'] ) {
$q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
$authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
foreach ( $authors as $author ) {
@@ -3290,7 +3290,7 @@ class WP_Query {
global $post;
$this->in_the_loop = true;
if ( $this->current_post == -1 ) { // Loop has just started.
if ( -1 == $this->current_post ) { // Loop has just started.
/**
* Fires once the loop is started.
*
@@ -3380,7 +3380,7 @@ class WP_Query {
$comment = $this->next_comment();
if ( $this->current_comment == 0 ) {
if ( 0 == $this->current_comment ) {
/**
* Fires once the comment loop is started.
*
@@ -4300,7 +4300,7 @@ class WP_Query {
* Force full post content when viewing the permalink for the $post,
* or when on an RSS feed. Otherwise respect the 'more' tag.
*/
if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) {
if ( get_queried_object_id() === $post->ID && ( $this->is_page() || $this->is_single() ) ) {
$more = 1;
} elseif ( $this->is_feed() ) {
$more = 1;