Changeset 47808 for trunk/src/wp-includes/class-wp-query.php
- Timestamp:
- 05/16/2020 06:40:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r47635 r47808 805 805 $qv['attachment_id'] = absint( $qv['attachment_id'] ); 806 806 807 if ( ( '' != $qv['attachment'] ) || ! empty( $qv['attachment_id'] ) ) {807 if ( ( '' !== $qv['attachment'] ) || ! empty( $qv['attachment_id'] ) ) { 808 808 $this->is_single = true; 809 809 $this->is_attachment = true; 810 } elseif ( '' != $qv['name'] ) {810 } elseif ( '' !== $qv['name'] ) { 811 811 $this->is_single = true; 812 812 } elseif ( $qv['p'] ) { 813 813 $this->is_single = true; 814 } elseif ( '' != $qv['pagename'] || ! empty( $qv['page_id'] ) ) {814 } elseif ( '' !== $qv['pagename'] || ! empty( $qv['page_id'] ) ) { 815 815 $this->is_page = true; 816 816 $this->is_single = false; … … 880 880 } 881 881 882 if ( '' !=$qv['w'] ) {882 if ( $qv['w'] ) { 883 883 $this->is_date = true; 884 884 } … … 892 892 } 893 893 894 if ( isset( $tax_query['operator'] ) && 'NOT IN' != $tax_query['operator'] ) {894 if ( isset( $tax_query['operator'] ) && 'NOT IN' !== $tax_query['operator'] ) { 895 895 switch ( $tax_query['taxonomy'] ) { 896 896 case 'category': … … 913 913 } 914 914 915 if ( '' != $qv['author_name'] ) {915 if ( '' !== $qv['author_name'] ) { 916 916 $this->is_author = true; 917 917 } … … 972 972 973 973 // Correct `is_*` for 'page_on_front' and 'page_for_posts'. 974 if ( $this->is_home && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) {974 if ( $this->is_home && 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { 975 975 $_query = wp_parse_args( $this->query ); 976 976 // 'pagename' can be set and empty depending on matched rewrite rules. Ignore an empty 'pagename'. 977 if ( isset( $_query['pagename'] ) && '' == $_query['pagename'] ) {977 if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { 978 978 unset( $_query['pagename'] ); 979 979 } … … 993 993 } 994 994 995 if ( '' != $qv['pagename'] ) {995 if ( '' !== $qv['pagename'] ) { 996 996 $this->queried_object = get_page_by_path( $qv['pagename'] ); 997 997 998 if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) {998 if ( $this->queried_object && 'attachment' === $this->queried_object->post_type ) { 999 999 if ( preg_match( '/^[^%]*%(?:postname)%/', get_option( 'permalink_structure' ) ) ) { 1000 1000 // See if we also have a post with the same slug. … … 1104 1104 1105 1105 foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) { 1106 if ( 'post_tag' == $taxonomy ) {1106 if ( 'post_tag' === $taxonomy ) { 1107 1107 continue; // Handled further down in the $q['tag'] block. 1108 1108 } … … 1236 1236 // Tag stuff. 1237 1237 1238 if ( '' != $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) {1238 if ( '' !== $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) { 1239 1239 if ( strpos( $q['tag'], ',' ) !== false ) { 1240 1240 $tags = preg_split( '/[,\r\n\t ]+/', $q['tag'] ); … … 1994 1994 1995 1995 // If we've got a post_type AND it's not "any" post_type. 1996 if ( ! empty( $q['post_type'] ) && 'any' != $q['post_type'] ) {1996 if ( ! empty( $q['post_type'] ) && 'any' !== $q['post_type'] ) { 1997 1997 foreach ( (array) $q['post_type'] as $_post_type ) { 1998 1998 $ptype_obj = get_post_type_object( $_post_type ); … … 2021 2021 2022 2022 // Parameters related to 'post_name'. 2023 if ( '' != $q['name'] ) {2023 if ( '' !== $q['name'] ) { 2024 2024 $q['name'] = sanitize_title_for_query( $q['name'] ); 2025 2025 $where .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'"; 2026 } elseif ( '' != $q['pagename'] ) {2026 } elseif ( '' !== $q['pagename'] ) { 2027 2027 if ( isset( $this->queried_object_id ) ) { 2028 2028 $reqpage = $this->queried_object_id; 2029 2029 } else { 2030 if ( 'page' != $q['post_type'] ) {2030 if ( 'page' !== $q['post_type'] ) { 2031 2031 foreach ( (array) $q['post_type'] as $_post_type ) { 2032 2032 $ptype_obj = get_post_type_object( $_post_type ); … … 2052 2052 2053 2053 $page_for_posts = get_option( 'page_for_posts' ); 2054 if ( ( 'page' != get_option( 'show_on_front' ) ) || empty( $page_for_posts ) || ( $reqpage != $page_for_posts ) ) {2054 if ( ( 'page' !== get_option( 'show_on_front' ) ) || empty( $page_for_posts ) || ( $reqpage != $page_for_posts ) ) { 2055 2055 $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); 2056 2056 $q['name'] = $q['pagename']; 2057 2057 $where .= " AND ({$wpdb->posts}.ID = '$reqpage')"; 2058 2058 $reqpage_obj = get_post( $reqpage ); 2059 if ( is_object( $reqpage_obj ) && 'attachment' == $reqpage_obj->post_type ) {2059 if ( is_object( $reqpage_obj ) && 'attachment' === $reqpage_obj->post_type ) { 2060 2060 $this->is_attachment = true; 2061 2061 $post_type = 'attachment'; … … 2065 2065 } 2066 2066 } 2067 } elseif ( '' != $q['attachment'] ) {2067 } elseif ( '' !== $q['attachment'] ) { 2068 2068 $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) ); 2069 2069 $q['name'] = $q['attachment']; … … 2240 2240 // Author stuff for nice URLs. 2241 2241 2242 if ( '' != $q['author_name'] ) {2242 if ( '' !== $q['author_name'] ) { 2243 2243 if ( strpos( $q['author_name'], '/' ) !== false ) { 2244 2244 $q['author_name'] = explode( '/', $q['author_name'] ); … … 2286 2286 // MIME-Type stuff for attachment browsing. 2287 2287 2288 if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) {2288 if ( isset( $q['post_mime_type'] ) && '' !== $q['post_mime_type'] ) { 2289 2289 $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts ); 2290 2290 } … … 2321 2321 $orderby = "{$wpdb->posts}.post_date " . $q['order']; 2322 2322 } 2323 } elseif ( 'none' == $q['orderby'] ) {2323 } elseif ( 'none' === $q['orderby'] ) { 2324 2324 $orderby = ''; 2325 2325 } else { … … 2414 2414 } 2415 2415 2416 if ( 'any' == $post_type ) {2416 if ( 'any' === $post_type ) { 2417 2417 $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) ); 2418 2418 if ( empty( $in_search_post_types ) ) { … … 2469 2469 foreach ( get_post_stati() as $status ) { 2470 2470 if ( in_array( $status, $q_status, true ) ) { 2471 if ( 'private' == $status ) {2471 if ( 'private' === $status ) { 2472 2472 $p_status[] = "{$wpdb->posts}.post_status = '$status'"; 2473 2473 } else { … … 2478 2478 } 2479 2479 2480 if ( empty( $q['perm'] ) || 'readable' != $q['perm'] ) {2480 if ( empty( $q['perm'] ) || 'readable' !== $q['perm'] ) { 2481 2481 $r_status = array_merge( $r_status, $p_status ); 2482 2482 unset( $p_status ); … … 2487 2487 } 2488 2488 if ( ! empty( $r_status ) ) { 2489 if ( ! empty( $q['perm'] ) && 'editable' == $q['perm'] && ! current_user_can( $edit_others_cap ) ) {2489 if ( ! empty( $q['perm'] ) && 'editable' === $q['perm'] && ! current_user_can( $edit_others_cap ) ) { 2490 2490 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $r_status ) . '))'; 2491 2491 } else { … … 2494 2494 } 2495 2495 if ( ! empty( $p_status ) ) { 2496 if ( ! empty( $q['perm'] ) && 'readable' == $q['perm'] && ! current_user_can( $read_private_cap ) ) {2496 if ( ! empty( $q['perm'] ) && 'readable' === $q['perm'] && ! current_user_can( $read_private_cap ) ) { 2497 2497 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $p_status ) . '))'; 2498 2498 } else { … … 2516 2516 $public_states = get_post_stati( array( 'public' => true ) ); 2517 2517 foreach ( (array) $public_states as $state ) { 2518 if ( 'publish' == $state ) { // Publish is hard-coded above.2518 if ( 'publish' === $state ) { // Publish is hard-coded above. 2519 2519 continue; 2520 2520 } … … 2949 2949 $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); 2950 2950 2951 if ( 'ids' == $q['fields'] ) {2951 if ( 'ids' === $q['fields'] ) { 2952 2952 if ( null === $this->posts ) { 2953 2953 $this->posts = $wpdb->get_col( $this->request ); … … 2961 2961 } 2962 2962 2963 if ( 'id=>parent' == $q['fields'] ) {2963 if ( 'id=>parent' === $q['fields'] ) { 2964 2964 if ( null === $this->posts ) { 2965 2965 $this->posts = $wpdb->get_results( $this->request ); … … 2981 2981 2982 2982 if ( null === $this->posts ) { 2983 $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" == $fields && ! empty( $limits ) && $q['posts_per_page'] < 500 );2983 $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" === $fields && ! empty( $limits ) && $q['posts_per_page'] < 500 ); 2984 2984 2985 2985 /** … … 3094 3094 } else { 3095 3095 $this->is_preview = true; 3096 if ( 'future' != $status ) {3096 if ( 'future' !== $status ) { 3097 3097 $this->posts[0]->post_date = current_time( 'mysql' ); 3098 3098 } … … 3482 3482 3483 3483 if ( ! empty( $query['terms'] ) ) { 3484 if ( 'term_id' == $query['field'] ) {3484 if ( 'term_id' === $query['field'] ) { 3485 3485 $term = get_term( reset( $query['terms'] ), $matched_taxonomy ); 3486 3486 } else { … … 3877 3877 } 3878 3878 $qv = $this->get( 'feed' ); 3879 if ( 'feed' == $qv ) {3879 if ( 'feed' === $qv ) { 3880 3880 $qv = get_default_feed(); 3881 3881 } … … 3912 3912 public function is_front_page() { 3913 3913 // Most likely case. 3914 if ( 'posts' == get_option( 'show_on_front' ) && $this->is_home() ) {3914 if ( 'posts' === get_option( 'show_on_front' ) && $this->is_home() ) { 3915 3915 return true; 3916 } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) { 3916 } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) 3917 && $this->is_page( get_option( 'page_on_front' ) ) 3918 ) { 3917 3919 return true; 3918 3920 } else { … … 3955 3957 */ 3956 3958 public function is_privacy_policy() { 3957 if ( get_option( 'wp_page_for_privacy_policy' ) && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) ) { 3959 if ( get_option( 'wp_page_for_privacy_policy' ) 3960 && $this->is_page( get_option( 'wp_page_for_privacy_policy' ) ) 3961 ) { 3958 3962 return true; 3959 3963 } else {
Note: See TracChangeset
for help on using the changeset viewer.