WordPress.org

Make WordPress Core

Ticket #19693: 19693.2.diff

File 19693.2.diff, 2.1 KB (added by SergeyBiryukov, 6 years ago)
  • wp-includes/canonical.php

     
    100100                }
    101101
    102102                if ( ! $redirect_url ) {
    103                         if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) {
     103                        if ( $redirect_url = apply_filters( 'redirect_guess_404_permalink', $requested_url ) ) {
    104104                                $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
    105105                        }
    106106                }
     
    489489        if ( get_query_var('name') ) {
    490490                $where = $wpdb->prepare("post_name LIKE %s", like_escape( get_query_var('name') ) . '%');
    491491
    492                 // if any of post_type, year, monthnum, or day are set, use them to refine the query
     492                // Use either an explicitly set post_type or search in all registered public post types
    493493                if ( get_query_var('post_type') )
    494                         $where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
     494                        $where .= $wpdb->prepare( " AND post_type = %s", get_query_var('post_type') );
     495                else
     496                        $where .= $wpdb->prepare( " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')" );
     497                // If any of year, monthnum, or day are set, use them to refine the query
    495498                if ( get_query_var('year') )
    496499                        $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
    497500                if ( get_query_var('monthnum') )
  • wp-includes/default-filters.php

     
    191191add_filter( 'pings_open',               '_close_comments_for_old_post', 10, 2 );
    192192add_filter( 'editable_slug',            'urldecode'                           );
    193193add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'        );
     194add_filter( 'redirect_guess_404_permalink', 'redirect_guess_404_permalink'    );
    194195
    195196// Actions
    196197add_action( 'wp_head',             'wp_enqueue_scripts',              1     );