From a08fd6ff6fe321b2e3fe8ae5967066c32543f4a2 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Sun, 18 Oct 2020 23:23:05 +0000 Subject: [PATCH] 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 --- wp-includes/canonical.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 6a74ac2d43..167b5cf562 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -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 ) ) ) . "')"; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 6761fc8e36..d7c160dd9a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.