Changeset 57645 for trunk/src/wp-includes/canonical.php
- Timestamp:
- 02/16/2024 11:32:48 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/canonical.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r57357 r57645 950 950 951 951 if ( get_query_var( 'name' ) ) { 952 $publicly_viewable_statuses = array_filter( get_post_stati(), 'is_post_status_viewable' ); 953 $publicly_viewable_post_types = array_filter( get_post_types( array( 'exclude_from_search' => false ) ), 'is_post_type_viewable' ); 954 952 955 /** 953 956 * Filters whether to perform a strict guess for a 404 redirect. … … 970 973 if ( get_query_var( 'post_type' ) ) { 971 974 if ( is_array( get_query_var( 'post_type' ) ) ) { 975 $post_types = array_intersect( get_query_var( 'post_type' ), $publicly_viewable_post_types ); 976 if ( empty( $post_types ) ) { 977 return false; 978 } 972 979 $where .= " AND post_type IN ('" . join( "', '", esc_sql( get_query_var( 'post_type' ) ) ) . "')"; 973 980 } else { 981 if ( ! in_array( get_query_var( 'post_type' ), $publicly_viewable_post_types, true ) ) { 982 return false; 983 } 974 984 $where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) ); 975 985 } 976 986 } else { 977 $where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true )) ) . "')";987 $where .= " AND post_type IN ('" . implode( "', '", esc_sql( $publicly_viewable_post_types ) ) . "')"; 978 988 } 979 989 … … 988 998 } 989 999 990 $publicly_viewable_statuses = array_filter( get_post_stati(), 'is_post_status_viewable' );991 1000 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 992 1001 $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", esc_sql( $publicly_viewable_statuses ) ) . "')" );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)