Ticket #10667: searchapi.diff
| File searchapi.diff, 3.4 KB (added by , 16 years ago) |
|---|
-
wp-includes/query.php
1563 1563 * @return array List of posts. 1564 1564 */ 1565 1565 function &get_posts() { 1566 global $wpdb, $user_ID; 1566 global $wpdb, $user_ID, $wpsearch; 1567 1568 if ( $this->is_search ) { 1569 $wpsearch->init_search(); 1570 } 1567 1571 1568 1572 do_action_ref_array('pre_get_posts', array(&$this)); 1569 1573 … … 1739 1743 } 1740 1744 } 1741 1745 1742 // If a search pattern is specified, load the posts that match1743 if ( !empty($q['s']) ) {1744 // added slashes screw with quote grouping when done early, so done later1745 $q['s'] = stripslashes($q['s']);1746 if ( !empty($q['sentence']) ) {1747 $q['search_terms'] = array($q['s']);1748 } else {1749 preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches);1750 $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);1751 }1752 $n = !empty($q['exact']) ? '' : '%';1753 $searchand = '';1754 foreach( (array) $q['search_terms'] as $term) {1755 $term = addslashes_gpc($term);1756 $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";1757 $searchand = ' AND ';1758 }1759 $term = $wpdb->escape($q['s']);1760 if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )1761 $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";1762 1763 if ( !empty($search) ) {1764 $search = " AND ({$search}) ";1765 if ( !is_user_logged_in() )1766 $search .= " AND ($wpdb->posts.post_password = '') ";1767 }1768 }1769 1770 1746 // Category stuff 1771 1747 1772 1748 if ( empty($q['cat']) || ($q['cat'] == '0') || -
wp-settings.php
357 357 require (ABSPATH . WPINC . '/media.php'); 358 358 require (ABSPATH . WPINC . '/http.php'); 359 359 require (ABSPATH . WPINC . '/widgets.php'); 360 require (ABSPATH . WPINC . '/search.php'); 360 361 361 362 if ( !defined('WP_CONTENT_URL') ) 362 363 define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up -
wp-admin/includes/schema.php
163 163 PRIMARY KEY (umeta_id), 164 164 KEY user_id (user_id), 165 165 KEY meta_key (meta_key) 166 ) $charset_collate; 167 CREATE TABLE $wpdb->search_index ( 168 id bigint(20) NOT NULL auto_increment, 169 object bigint(20) NOT NULL, 170 title text NOT NULL, 171 content text NOT NULL, 172 post_date datetime NOT NULL, 173 parent bigint(20) NOT NULL, 174 categories text NOT NULL, 175 tags text NOT NULL, 176 author text NOT NULL, 177 type varchar(50) NOT NULL, 178 protected smallint(6) NOT NULL, 179 PRIMARY KEY (`id`), 180 FULLTEXT KEY `title` (`title`), 181 FULLTEXT KEY `content` (`content`), 182 FULLTEXT KEY `title_and_content` (`title`,`content`) 166 183 ) $charset_collate;"; 167 184 168 185 /** … … 305 322 'widget_rss' => array(), 306 323 307 324 // 2.8 308 'timezone_string' => '' 325 'timezone_string' => '', 326 327 // 2.9 328 'searchapi_custom_options' => '', 329 'searchapi_plugin' => '', 330 'searchapi_help' => '', 309 331 ); 310 332 311 333 // Set autoload to no for these options