Ticket #16022: 16022.diff
| File 16022.diff, 2.1 KB (added by greuben, 2 years ago) |
|---|
-
wp-includes/query.php
1731 1731 'operator' => 'NOT IN', 1732 1732 ); 1733 1733 } 1734 1735 // Search 1736 if( !empty( $q['s'] ) ){ 1737 if ( !empty($q['sentence']) ) { 1738 $q['search_terms'] = array($q['s']); 1739 } else { 1740 preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches); 1741 $q['search_terms'] = array_map('_search_terms_tidy', $matches[0]); 1742 } 1743 1744 $tax_query[] = array( 1745 'taxonomy' => 'post_tag', 1746 'terms' => $q['search_terms'], 1747 'field' => 'name', 1748 ); 1749 1750 $this->is_category = $this->is_tag = false; 1751 $this->is_search = true; 1752 } 1734 1753 1735 1754 $this->tax_query = new WP_Tax_Query( $tax_query ); 1736 1755 } … … 2034 2053 $where = " AND {$wpdb->posts}.ID = " . $q['page_id']; 2035 2054 } 2036 2055 } 2056 2057 // Taxonomies 2058 $this->parse_tax_query( $q ); 2037 2059 2060 $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' ); 2061 2062 $join .= $clauses['join']; 2063 $where .= $clauses['where']; 2064 2038 2065 // If a search pattern is specified, load the posts that match 2039 2066 if ( !empty($q['s']) ) { 2040 2067 // added slashes screw with quote grouping when done early, so done later … … 2057 2084 $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')"; 2058 2085 2059 2086 if ( !empty($search) ) { 2060 $search = " AND ({$search}) "; 2087 if( empty( $clauses['where'] ) ) 2088 $search = " AND ({$search}) "; 2089 else 2090 $search = " OR ({$search}) "; 2061 2091 if ( !is_user_logged_in() ) 2062 2092 $search .= " AND ($wpdb->posts.post_password = '') "; 2063 2093 } … … 2066 2096 // Allow plugins to contextually add/remove/modify the search section of the database query 2067 2097 $search = apply_filters_ref_array('posts_search', array( $search, &$this ) ); 2068 2098 2069 // Taxonomies2070 $this->parse_tax_query( $q );2071 2072 $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' );2073 2074 $join .= $clauses['join'];2075 $where .= $clauses['where'];2076 2077 2099 if ( $this->is_tax ) { 2078 2100 if ( empty($post_type) ) { 2079 2101 $post_type = 'any';
