]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/query.php
WordPress 4.4.2
[autoinstalls/wordpress.git] / wp-includes / query.php
index 9460d32450ba9cb0d2addf1105df4413da0f6058..b4aae270b22195f5478a03109a4723c69cef3d14 100644 (file)
@@ -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] );
-                               }
-                       }
                }
 
                /**