Make WordPress Core

Ticket #42423: patch-42423-b.diff

File patch-42423-b.diff, 956 bytes (added by DaveFX, 6 years ago)

Improved version of patch, now passing received parameters through $wpdb->prepare

  • wp-includes/canonical.php

    diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php
    index 36ff320..ca164f1 100644
    a b function redirect_guess_404_permalink() { 
    665665
    666666                // if any of post_type, year, monthnum, or day are set, use them to refine the query
    667667                if ( get_query_var( 'post_type' ) ) {
    668                         $where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
     668                        if ( is_array( get_query_var( 'post_type' ) ) ) {
     669                                $post_types = array();
     670                                foreach ( get_query_var( 'post_type' ) as $post_type ) {
     671                                        $post_types[] = $wpdb->prepare( '%s', $post_type );
     672                                }
     673                                $where .= " AND post_type IN (" . implode( ", ", $post_types ) . ")";
     674                        } else {
     675                                $where .= $wpdb->prepare( " AND post_type = %s", get_query_var( 'post_type' ) );
     676                        }
    669677                } else {
    670678                        $where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
    671679                }