X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9441756a895fb4fdc4bcf20e0d228cef622663ca..0459461f9ea42e0b090759ff6fe5f48360bef750:/wp-includes/query.php diff --git a/wp-includes/query.php b/wp-includes/query.php index 9460d324..b4aae270 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2300,7 +2300,7 @@ class WP_Query { $like = '%' . $wpdb->esc_like( $q['s'] ) . '%'; } - $search_orderby = '(CASE '; + $search_orderby = ''; // sentence match in 'post_title' if ( $like ) { @@ -2321,7 +2321,10 @@ class WP_Query { if ( $like ) { $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_content LIKE %s THEN 4 ", $like ); } - $search_orderby .= 'ELSE 5 END)'; + + if ( $search_orderby ) { + $search_orderby = '(CASE ' . $search_orderby . 'ELSE 5 END)'; + } } else { // single word or sentence search $search_orderby = reset( $q['search_orderby_title'] ) . ' DESC'; @@ -4981,16 +4984,11 @@ class WP_Query { * * @global WP_Query $wp_query Global WP_Query instance. * @global wpdb $wpdb WordPress database abstraction object. - * @global WP_Rewrite $wp_rewrite WordPress rewrite component. */ function wp_old_slug_redirect() { - global $wp_query, $wp_rewrite; - - if ( get_queried_object() ) { - return; - } + global $wp_query; - if ( '' !== $wp_query->query_vars['name'] ) : + if ( is_404() && '' !== $wp_query->query_vars['name'] ) : global $wpdb; // Guess the current post_type based on the query vars. @@ -5032,19 +5030,10 @@ function wp_old_slug_redirect() { $link = get_permalink( $id ); - if ( is_feed() ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'feed' ); - } elseif ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) { + if ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) { $link = user_trailingslashit( trailingslashit( $link ) . 'page/' . $GLOBALS['wp_query']->query_vars['paged'] ); } elseif( is_embed() ) { $link = user_trailingslashit( trailingslashit( $link ) . 'embed' ); - } elseif ( is_404() ) { - // Add rewrite endpoints if necessary. - foreach ( $wp_rewrite->endpoints as $endpoint ) { - if ( $endpoint[2] && false !== get_query_var( $endpoint[2], false ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . $endpoint[1] ); - } - } } /**