Canonical: Support multiple post types in `redirect_guess_404_permalink()`.

Prevent `redirect_guess_404_permalink()` from throwing a notice when multiple post types are included in the `post_type` query.

Props junaidbhura.
Fixes #43056.


Built from https://develop.svn.wordpress.org/trunk@49200


git-svn-id: http://core.svn.wordpress.org/trunk@48962 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2020-10-18 23:23:05 +00:00
parent 2716cc8048
commit a08fd6ff6f
2 changed files with 7 additions and 2 deletions

View File

@ -895,7 +895,12 @@ function redirect_guess_404_permalink() {
// If any of post_type, year, monthnum, or day are set, use them to refine the query.
if ( get_query_var( 'post_type' ) ) {
$where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
if ( is_array( get_query_var( 'post_type' ) ) ) {
// phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
$where .= " AND post_type IN ('" . join( "', '", esc_sql( get_query_var( 'post_type' ) ) ) . "')";
} else {
$where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
}
} else {
$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49199';
$wp_version = '5.6-alpha-49200';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.