Version Description
Download this release
Release Info
Developer | dancameron |
Plugin | Search Everything |
Version | 6.2 |
Comparing to | |
See all releases |
Code changes from version 6.1.7 to 6.2
- readme.txt +7 -4
- search-everything.php +112 -75
- views/options.php +30 -3
readme.txt
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: dancameron, sproutventure, ericlebail
|
3 |
Donate link: http://www.amazon.com/wishlist/3EM84J7FVHE6S
|
4 |
-
Tags: search, tag search, category search, category exclusion, comment search, page search, admin, seo
|
5 |
Requires at least: 2.3
|
6 |
Tested up to: 2.8
|
7 |
-
Stable tag: 6.
|
8 |
|
9 |
-
Increases Wordpress' default search functionality through an options panel. Options include searching pages, excerpts, attachments, drafts, comments and custom fields (metadata).
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
Search Everything increases the ability of the default Wordpress Search, options included:
|
14 |
|
|
|
15 |
* Search Every Page
|
16 |
* Search Every Tag
|
17 |
* Search Every Category
|
@@ -25,6 +26,7 @@ Search Everything increases the ability of the default Wordpress Search, options
|
|
25 |
* Exclude Posts from search
|
26 |
* Exclude Categories from search
|
27 |
|
|
|
28 |
* 6.1.7 - Major Posts Exclude and Category Exclude Bug fix.
|
29 |
* 6.1.6 - Sym link fix.
|
30 |
* 6.1.5 - Major Exclude Bug fix.
|
@@ -37,6 +39,7 @@ Search Everything increases the ability of the default Wordpress Search, options
|
|
37 |
|
38 |
== Update Log ==
|
39 |
|
|
|
40 |
* 6.1.7 - Major Posts Exclude and Category Exclude Bug fix.
|
41 |
* 6.1.6 - Sym link fix.
|
42 |
* 6.1.5 - Major Exclude Bug fix.
|
@@ -92,7 +95,7 @@ Read the installation guide.
|
|
92 |
|
93 |
== Help ==
|
94 |
|
95 |
-
I do need help with this plugin. If you can possibly do my day job and take my girls to the park I would appreciate it; otherwise contribute your fixes and suggestions to me in the forums or through the contact form on my site.
|
96 |
|
97 |
|
98 |
== Support ==
|
1 |
=== Plugin Name ===
|
2 |
Contributors: dancameron, sproutventure, ericlebail
|
3 |
Donate link: http://www.amazon.com/wishlist/3EM84J7FVHE6S
|
4 |
+
Tags: search, search highlight, tag search, category search, category exclusion, comment search, page search, admin, seo, post filter
|
5 |
Requires at least: 2.3
|
6 |
Tested up to: 2.8
|
7 |
+
Stable tag: 6.2
|
8 |
|
9 |
+
Increases Wordpress' default search functionality through an options panel. Options include search highlight, searching pages, excerpts, attachments, drafts, comments and custom fields (metadata).
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
Search Everything increases the ability of the default Wordpress Search, options included:
|
14 |
|
15 |
+
* Search Highlighting
|
16 |
* Search Every Page
|
17 |
* Search Every Tag
|
18 |
* Search Every Category
|
26 |
* Exclude Posts from search
|
27 |
* Exclude Categories from search
|
28 |
|
29 |
+
* 6.2 - Search Highlighting options. Fix when searching with '.
|
30 |
* 6.1.7 - Major Posts Exclude and Category Exclude Bug fix.
|
31 |
* 6.1.6 - Sym link fix.
|
32 |
* 6.1.5 - Major Exclude Bug fix.
|
39 |
|
40 |
== Update Log ==
|
41 |
|
42 |
+
* 6.2 - Search Highlighting options. Fix when searching with '.
|
43 |
* 6.1.7 - Major Posts Exclude and Category Exclude Bug fix.
|
44 |
* 6.1.6 - Sym link fix.
|
45 |
* 6.1.5 - Major Exclude Bug fix.
|
95 |
|
96 |
== Help ==
|
97 |
|
98 |
+
I do need help with this plugin. If you can possibly do my day job and take my girls and newborn son to the park I would appreciate it; otherwise contribute your fixes and suggestions to me in the forums or through the contact form on my site.
|
99 |
|
100 |
|
101 |
== Support ==
|
search-everything.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Search Everything
|
4 |
-
Plugin URI: https://redmine.sproutventure.com/projects/show/search-everything
|
5 |
-
Description: Adds search functionality without modifying template pages: Activate, Configure and Search. Options Include: search pages, excerpts, attachments, drafts, comments, tags and custom fields (metadata). Also offers the ability to exclude specific pages and posts. Does not search password-protected content.
|
6 |
-
Version: 6.
|
7 |
-
Author: Dan Cameron of Sprout Venture
|
8 |
-
Author URI: http://sproutventure.com/
|
9 |
-
*/
|
10 |
|
11 |
/*
|
12 |
-
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
13 |
|
14 |
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15 |
-
*/
|
16 |
|
17 |
if ( !defined('WP_CONTENT_DIR') )
|
18 |
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
19 |
|
20 |
if (!defined('DIRECTORY_SEPARATOR'))
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
}
|
27 |
define('SE_ABSPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
28 |
|
@@ -104,22 +104,30 @@ Class SearchEverything {
|
|
104 |
add_filter('posts_join', array(&$this, 'se_exclude_categories_join'));
|
105 |
$this->se_log("searching excluding categories");
|
106 |
}
|
107 |
-
|
108 |
if ("Yes" == $this->options['se_use_authors'])
|
109 |
{
|
110 |
add_filter('posts_where', array(&$this, 'se_search_authors'));
|
111 |
add_filter('posts_join', array(&$this, 'se_search_authors_join'));
|
112 |
$this->se_log("searching authors");
|
113 |
}
|
114 |
-
|
115 |
add_filter('posts_where', array(&$this, 'se_search_where'));
|
116 |
-
|
117 |
add_filter('posts_where', array(&$this, 'se_no_revisions'));
|
118 |
|
119 |
add_filter('posts_request', array(&$this, 'se_distinct'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
|
122 |
-
|
123 |
// creates the list of search keywords from the 's' parameters.
|
124 |
function se_get_search_terms()
|
125 |
{
|
@@ -135,7 +143,7 @@ Class SearchEverything {
|
|
135 |
if ($sentence)
|
136 |
{
|
137 |
$search_terms = array($s);
|
138 |
-
|
139 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
|
140 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
141 |
}
|
@@ -203,7 +211,7 @@ Class SearchEverything {
|
|
203 |
}
|
204 |
return $where;
|
205 |
}
|
206 |
-
|
207 |
// Logs search into a file
|
208 |
function se_log($msg)
|
209 |
{
|
@@ -250,7 +258,7 @@ Class SearchEverything {
|
|
250 |
if ('Yes' == $this->options['se_approved_pages_only'])
|
251 |
{
|
252 |
$where = str_replace('post_type = \'post\' AND ', 'post_password = \'\' AND ', $where);
|
253 |
-
|
254 |
$where = str_replace('post_type = \'post\' AND ', '', $where);
|
255 |
}
|
256 |
}
|
@@ -266,7 +274,7 @@ Class SearchEverything {
|
|
266 |
$search_terms = $this->se_get_search_terms();
|
267 |
$exact = $wp_query->query_vars['exact'];
|
268 |
$search = '';
|
269 |
-
|
270 |
if ( !empty($search_terms) ) {
|
271 |
// Building search query
|
272 |
$n = ($exact) ? '' : '%';
|
@@ -276,19 +284,19 @@ Class SearchEverything {
|
|
276 |
$search .= "{$searchand}($wpdb->posts.post_excerpt LIKE '{$n}{$term}{$n}')";
|
277 |
$searchand = ' AND ';
|
278 |
}
|
279 |
-
$
|
280 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
281 |
{
|
282 |
-
$search = "($search) OR ($wpdb->posts.post_excerpt LIKE '{$n}{$
|
283 |
}
|
284 |
if ( !empty($search) )
|
285 |
-
|
286 |
}
|
287 |
$this->se_log("excerpt where: ".$where);
|
288 |
return $search;
|
289 |
}
|
290 |
-
|
291 |
-
|
292 |
//search drafts
|
293 |
function se_search_draft_posts($where)
|
294 |
{
|
@@ -337,12 +345,12 @@ Class SearchEverything {
|
|
337 |
}
|
338 |
$searchand = ' AND ';
|
339 |
}
|
340 |
-
$
|
341 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
342 |
{
|
343 |
if ($this->wp_ver23)
|
344 |
{
|
345 |
-
$searchContent = "($searchContent) OR (cmt.comment_content LIKE '{$n}{$
|
346 |
}
|
347 |
}
|
348 |
$search = $searchContent;
|
@@ -359,12 +367,12 @@ Class SearchEverything {
|
|
359 |
}
|
360 |
$searchand = ' AND ';
|
361 |
}
|
362 |
-
$
|
363 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
364 |
{
|
365 |
if ($this->wp_ver23)
|
366 |
{
|
367 |
-
$comment_author = "($comment_author) OR (cmt.comment_author LIKE '{$n}{$
|
368 |
}
|
369 |
}
|
370 |
$search = "($search) OR ($comment_author)";
|
@@ -389,7 +397,7 @@ Class SearchEverything {
|
|
389 |
$search_terms = $this->se_get_search_terms();
|
390 |
$exact = $wp_query->query_vars['exact'];
|
391 |
$search = '';
|
392 |
-
|
393 |
if ( !empty($search_terms) ) {
|
394 |
// Building search query
|
395 |
$n = ($exact) ? '' : '%';
|
@@ -399,25 +407,25 @@ Class SearchEverything {
|
|
399 |
if ($this->wp_ver23)
|
400 |
{
|
401 |
$search .= "{$searchand}(m.meta_value LIKE '{$n}{$term}{$n}')";
|
402 |
-
|
403 |
-
|
404 |
}
|
405 |
$searchand = ' AND ';
|
406 |
}
|
407 |
-
$
|
408 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
409 |
{
|
410 |
if ($this->wp_ver23)
|
411 |
{
|
412 |
-
$search = "($search) OR (m.meta_value LIKE '{$n}{$
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
}
|
417 |
-
|
418 |
if ( !empty($search) )
|
419 |
$search = " OR ({$search}) ";
|
420 |
-
|
421 |
}
|
422 |
$this->se_log("meta where: ".$where);
|
423 |
return $search;
|
@@ -431,7 +439,7 @@ Class SearchEverything {
|
|
431 |
$search_terms = $this->se_get_search_terms();
|
432 |
$exact = $wp_query->query_vars['exact'];
|
433 |
$search = '';
|
434 |
-
|
435 |
if ( !empty($search_terms) )
|
436 |
{
|
437 |
// Building search query
|
@@ -446,12 +454,12 @@ Class SearchEverything {
|
|
446 |
}
|
447 |
$searchand = ' AND ';
|
448 |
}
|
449 |
-
$
|
450 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
451 |
{
|
452 |
if ($this->wp_ver23)
|
453 |
{
|
454 |
-
$search = "($search) OR (tter.name LIKE '{$n}{$
|
455 |
}
|
456 |
}
|
457 |
if ( !empty($search) )
|
@@ -482,13 +490,12 @@ Class SearchEverything {
|
|
482 |
$searchSlug .= "{$searchand}(tter.slug LIKE '{$n}".sanitize_title_with_dashes($term)."{$n}')";
|
483 |
$searchand = ' AND ';
|
484 |
}
|
485 |
-
$term = $wpdb->escape($s);
|
486 |
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $s )
|
487 |
{
|
488 |
$searchSlug = "($searchSlug) OR (tter.slug LIKE '{$n}".sanitize_title_with_dashes($s)."{$n}')";
|
489 |
}
|
490 |
if ( !empty($searchSlug) )
|
491 |
-
|
492 |
|
493 |
// Building search query for categories description.
|
494 |
$searchand = '';
|
@@ -499,13 +506,13 @@ Class SearchEverything {
|
|
499 |
$searchDesc .= "{$searchand}(ttax.description LIKE '{$n}{$term}{$n}')";
|
500 |
$searchand = ' AND ';
|
501 |
}
|
502 |
-
$
|
503 |
-
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $
|
504 |
{
|
505 |
-
$searchDesc = "($searchDesc) OR (ttax.description LIKE '{$n}{$
|
506 |
}
|
507 |
if ( !empty($searchDesc) )
|
508 |
-
|
509 |
}
|
510 |
$this->se_log("categories where: ".$where);
|
511 |
return $search;
|
@@ -522,7 +529,7 @@ Class SearchEverything {
|
|
522 |
if ($excludedPostList != '')
|
523 |
{
|
524 |
$excl_list = implode(',', explode(',',$excludedPostList));
|
525 |
-
$excludeQuery = ' AND (ID NOT IN ( '.$excl_list.' ))';
|
526 |
}
|
527 |
$this->se_log("ex posts where: ".$excludeQuery);
|
528 |
}
|
@@ -565,7 +572,7 @@ Class SearchEverything {
|
|
565 |
if ($this->wp_ver23)
|
566 |
{
|
567 |
$join .= " LEFT JOIN $wpdb->term_relationships AS crel ON ($wpdb->posts.ID = crel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ctax ON (ctax.taxonomy = 'category' AND crel.term_taxonomy_id = ctax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS cter ON (ctax.term_id = cter.term_id) ";
|
568 |
-
|
569 |
$join .= "LEFT JOIN $wpdb->post2cat AS c ON $wpdb->posts.ID = c.post_id";
|
570 |
}
|
571 |
}
|
@@ -583,23 +590,23 @@ Class SearchEverything {
|
|
583 |
if ($this->wp_ver23)
|
584 |
{
|
585 |
$join .= " LEFT JOIN $wpdb->comments AS cmt ON ( cmt.comment_post_ID = ID ) ";
|
586 |
-
|
587 |
} else {
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
}
|
595 |
-
$join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
|
596 |
}
|
597 |
-
|
598 |
}
|
|
|
|
|
599 |
$this->se_log("comments join: ".$join);
|
600 |
return $join;
|
601 |
}
|
602 |
-
|
603 |
//join for searching authors
|
604 |
function se_search_authors($where)
|
605 |
{
|
@@ -612,7 +619,7 @@ Class SearchEverything {
|
|
612 |
$where = preg_replace("/\bor\b/i",$or." OR",$where,1);
|
613 |
$this->se_log("user where: ".$where);
|
614 |
return $where;
|
615 |
-
|
616 |
|
617 |
|
618 |
function se_search_authors_join($join)
|
@@ -626,7 +633,7 @@ Class SearchEverything {
|
|
626 |
$this->se_log("authors join: ".$join);
|
627 |
return $join;
|
628 |
}
|
629 |
-
|
630 |
//join for searching metadata
|
631 |
function se_search_metadata_join($join)
|
632 |
{
|
@@ -636,9 +643,9 @@ Class SearchEverything {
|
|
636 |
{
|
637 |
|
638 |
if ($this->wp_ver23)
|
639 |
-
|
640 |
else
|
641 |
-
|
642 |
}
|
643 |
$this->se_log("metadata join: ".$join);
|
644 |
return $join;
|
@@ -664,15 +671,45 @@ Class SearchEverything {
|
|
664 |
$on[] = "ttax.taxonomy = 'post_tag'";
|
665 |
}
|
666 |
|
667 |
-
|
668 |
-
|
669 |
|
670 |
-
|
671 |
}
|
672 |
$this->se_log("tags join: ".$join);
|
673 |
return $join;
|
674 |
}
|
675 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
} // END
|
677 |
|
678 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Search Everything
|
4 |
+
Plugin URI: https://redmine.sproutventure.com/projects/show/search-everything
|
5 |
+
Description: Adds search functionality without modifying any template pages: Activate, Configure and Search. Options Include: search highlight, search pages, excerpts, attachments, drafts, comments, tags and custom fields (metadata). Also offers the ability to exclude specific pages and posts. Does not search password-protected content.
|
6 |
+
Version: 6.2
|
7 |
+
Author: Dan Cameron of Sprout Venture
|
8 |
+
Author URI: http://sproutventure.com/
|
9 |
+
*/
|
10 |
|
11 |
/*
|
12 |
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
13 |
|
14 |
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15 |
+
*/
|
16 |
|
17 |
if ( !defined('WP_CONTENT_DIR') )
|
18 |
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
19 |
|
20 |
if (!defined('DIRECTORY_SEPARATOR'))
|
21 |
{
|
22 |
+
if (strpos(php_uname('s'), 'Win') !== false )
|
23 |
+
define('DIRECTORY_SEPARATOR', '\\');
|
24 |
+
else
|
25 |
+
define('DIRECTORY_SEPARATOR', '/');
|
26 |
}
|
27 |
define('SE_ABSPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
28 |
|
104 |
add_filter('posts_join', array(&$this, 'se_exclude_categories_join'));
|
105 |
$this->se_log("searching excluding categories");
|
106 |
}
|
107 |
+
|
108 |
if ("Yes" == $this->options['se_use_authors'])
|
109 |
{
|
110 |
add_filter('posts_where', array(&$this, 'se_search_authors'));
|
111 |
add_filter('posts_join', array(&$this, 'se_search_authors_join'));
|
112 |
$this->se_log("searching authors");
|
113 |
}
|
114 |
+
|
115 |
add_filter('posts_where', array(&$this, 'se_search_where'));
|
116 |
+
|
117 |
add_filter('posts_where', array(&$this, 'se_no_revisions'));
|
118 |
|
119 |
add_filter('posts_request', array(&$this, 'se_distinct'));
|
120 |
+
|
121 |
+
// Highlight content
|
122 |
+
if("Yes" == $this->options['se_use_highlight'])
|
123 |
+
{
|
124 |
+
add_filter('the_content', array(&$this,'se_postfilter'));
|
125 |
+
add_filter('the_title', array(&$this,'se_postfilter'));
|
126 |
+
add_filter('the_excerpt', array(&$this,'se_postfilter'));
|
127 |
+
}
|
128 |
}
|
129 |
|
130 |
+
|
131 |
// creates the list of search keywords from the 's' parameters.
|
132 |
function se_get_search_terms()
|
133 |
{
|
143 |
if ($sentence)
|
144 |
{
|
145 |
$search_terms = array($s);
|
146 |
+
} else {
|
147 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
|
148 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
149 |
}
|
211 |
}
|
212 |
return $where;
|
213 |
}
|
214 |
+
|
215 |
// Logs search into a file
|
216 |
function se_log($msg)
|
217 |
{
|
258 |
if ('Yes' == $this->options['se_approved_pages_only'])
|
259 |
{
|
260 |
$where = str_replace('post_type = \'post\' AND ', 'post_password = \'\' AND ', $where);
|
261 |
+
} else { // < v 2.1
|
262 |
$where = str_replace('post_type = \'post\' AND ', '', $where);
|
263 |
}
|
264 |
}
|
274 |
$search_terms = $this->se_get_search_terms();
|
275 |
$exact = $wp_query->query_vars['exact'];
|
276 |
$search = '';
|
277 |
+
|
278 |
if ( !empty($search_terms) ) {
|
279 |
// Building search query
|
280 |
$n = ($exact) ? '' : '%';
|
284 |
$search .= "{$searchand}($wpdb->posts.post_excerpt LIKE '{$n}{$term}{$n}')";
|
285 |
$searchand = ' AND ';
|
286 |
}
|
287 |
+
$sentence_term = $wpdb->escape($s);
|
288 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
|
289 |
{
|
290 |
+
$search = "($search) OR ($wpdb->posts.post_excerpt LIKE '{$n}{$sentence_term}{$n}')";
|
291 |
}
|
292 |
if ( !empty($search) )
|
293 |
+
$search = " OR ({$search}) ";
|
294 |
}
|
295 |
$this->se_log("excerpt where: ".$where);
|
296 |
return $search;
|
297 |
}
|
298 |
+
|
299 |
+
|
300 |
//search drafts
|
301 |
function se_search_draft_posts($where)
|
302 |
{
|
345 |
}
|
346 |
$searchand = ' AND ';
|
347 |
}
|
348 |
+
$sentense_term = $wpdb->escape($s);
|
349 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentense_term )
|
350 |
{
|
351 |
if ($this->wp_ver23)
|
352 |
{
|
353 |
+
$searchContent = "($searchContent) OR (cmt.comment_content LIKE '{$n}{$sentense_term}{$n}')";
|
354 |
}
|
355 |
}
|
356 |
$search = $searchContent;
|
367 |
}
|
368 |
$searchand = ' AND ';
|
369 |
}
|
370 |
+
$sentence_term = $wpdb->escape($s);
|
371 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
|
372 |
{
|
373 |
if ($this->wp_ver23)
|
374 |
{
|
375 |
+
$comment_author = "($comment_author) OR (cmt.comment_author LIKE '{$n}{$sentence_term}{$n}')";
|
376 |
}
|
377 |
}
|
378 |
$search = "($search) OR ($comment_author)";
|
397 |
$search_terms = $this->se_get_search_terms();
|
398 |
$exact = $wp_query->query_vars['exact'];
|
399 |
$search = '';
|
400 |
+
|
401 |
if ( !empty($search_terms) ) {
|
402 |
// Building search query
|
403 |
$n = ($exact) ? '' : '%';
|
407 |
if ($this->wp_ver23)
|
408 |
{
|
409 |
$search .= "{$searchand}(m.meta_value LIKE '{$n}{$term}{$n}')";
|
410 |
+
} else {
|
411 |
+
$search .= "{$searchand}(meta_value LIKE '{$n}{$term}{$n}')";
|
412 |
}
|
413 |
$searchand = ' AND ';
|
414 |
}
|
415 |
+
$sentence_term = $wpdb->escape($s);
|
416 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
|
417 |
{
|
418 |
if ($this->wp_ver23)
|
419 |
{
|
420 |
+
$search = "($search) OR (m.meta_value LIKE '{$n}{$sentence_term}{$n}')";
|
421 |
+
} else {
|
422 |
+
$search = "($search) OR (meta_value LIKE '{$n}{$sentence_term}{$n}')";
|
423 |
+
}
|
424 |
}
|
425 |
+
|
426 |
if ( !empty($search) )
|
427 |
$search = " OR ({$search}) ";
|
428 |
+
|
429 |
}
|
430 |
$this->se_log("meta where: ".$where);
|
431 |
return $search;
|
439 |
$search_terms = $this->se_get_search_terms();
|
440 |
$exact = $wp_query->query_vars['exact'];
|
441 |
$search = '';
|
442 |
+
|
443 |
if ( !empty($search_terms) )
|
444 |
{
|
445 |
// Building search query
|
454 |
}
|
455 |
$searchand = ' AND ';
|
456 |
}
|
457 |
+
$sentence_term = $wpdb->escape($s);
|
458 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
|
459 |
{
|
460 |
if ($this->wp_ver23)
|
461 |
{
|
462 |
+
$search = "($search) OR (tter.name LIKE '{$n}{$sentence_term}{$n}')";
|
463 |
}
|
464 |
}
|
465 |
if ( !empty($search) )
|
490 |
$searchSlug .= "{$searchand}(tter.slug LIKE '{$n}".sanitize_title_with_dashes($term)."{$n}')";
|
491 |
$searchand = ' AND ';
|
492 |
}
|
|
|
493 |
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $s )
|
494 |
{
|
495 |
$searchSlug = "($searchSlug) OR (tter.slug LIKE '{$n}".sanitize_title_with_dashes($s)."{$n}')";
|
496 |
}
|
497 |
if ( !empty($searchSlug) )
|
498 |
+
$search = " OR ({$searchSlug}) ";
|
499 |
|
500 |
// Building search query for categories description.
|
501 |
$searchand = '';
|
506 |
$searchDesc .= "{$searchand}(ttax.description LIKE '{$n}{$term}{$n}')";
|
507 |
$searchand = ' AND ';
|
508 |
}
|
509 |
+
$sentence_term = $wpdb->escape($s);
|
510 |
+
if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
|
511 |
{
|
512 |
+
$searchDesc = "($searchDesc) OR (ttax.description LIKE '{$n}{$sentence_term}{$n}')";
|
513 |
}
|
514 |
if ( !empty($searchDesc) )
|
515 |
+
$search = $search." OR ({$searchDesc}) ";
|
516 |
}
|
517 |
$this->se_log("categories where: ".$where);
|
518 |
return $search;
|
529 |
if ($excludedPostList != '')
|
530 |
{
|
531 |
$excl_list = implode(',', explode(',',$excludedPostList));
|
532 |
+
$excludeQuery = ' AND ('.$wpdb->posts.'.ID NOT IN ( '.$excl_list.' ))';
|
533 |
}
|
534 |
$this->se_log("ex posts where: ".$excludeQuery);
|
535 |
}
|
572 |
if ($this->wp_ver23)
|
573 |
{
|
574 |
$join .= " LEFT JOIN $wpdb->term_relationships AS crel ON ($wpdb->posts.ID = crel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ctax ON (ctax.taxonomy = 'category' AND crel.term_taxonomy_id = ctax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS cter ON (ctax.term_id = cter.term_id) ";
|
575 |
+
} else {
|
576 |
$join .= "LEFT JOIN $wpdb->post2cat AS c ON $wpdb->posts.ID = c.post_id";
|
577 |
}
|
578 |
}
|
590 |
if ($this->wp_ver23)
|
591 |
{
|
592 |
$join .= " LEFT JOIN $wpdb->comments AS cmt ON ( cmt.comment_post_ID = ID ) ";
|
593 |
+
|
594 |
} else {
|
595 |
+
|
596 |
+
if ('Yes' == $this->options['se_approved_comments_only'])
|
597 |
+
{
|
598 |
+
$comment_approved = " AND comment_approved = '1'";
|
599 |
+
} else {
|
600 |
+
$comment_approved = '';
|
|
|
|
|
601 |
}
|
602 |
+
$join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
|
603 |
}
|
604 |
+
|
605 |
+
}
|
606 |
$this->se_log("comments join: ".$join);
|
607 |
return $join;
|
608 |
}
|
609 |
+
|
610 |
//join for searching authors
|
611 |
function se_search_authors($where)
|
612 |
{
|
619 |
$where = preg_replace("/\bor\b/i",$or." OR",$where,1);
|
620 |
$this->se_log("user where: ".$where);
|
621 |
return $where;
|
622 |
+
}
|
623 |
|
624 |
|
625 |
function se_search_authors_join($join)
|
633 |
$this->se_log("authors join: ".$join);
|
634 |
return $join;
|
635 |
}
|
636 |
+
|
637 |
//join for searching metadata
|
638 |
function se_search_metadata_join($join)
|
639 |
{
|
643 |
{
|
644 |
|
645 |
if ($this->wp_ver23)
|
646 |
+
$join .= " LEFT JOIN $wpdb->postmeta AS m ON ($wpdb->posts.ID = m.post_id) ";
|
647 |
else
|
648 |
+
$join .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
|
649 |
}
|
650 |
$this->se_log("metadata join: ".$join);
|
651 |
return $join;
|
671 |
$on[] = "ttax.taxonomy = 'post_tag'";
|
672 |
}
|
673 |
|
674 |
+
// build our final string
|
675 |
+
$on = ' ( ' . implode( ' OR ', $on ) . ' ) ';
|
676 |
|
677 |
+
$join .= " LEFT JOIN $wpdb->term_relationships AS trel ON ($wpdb->posts.ID = trel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ttax ON ( " . $on . " AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS tter ON (ttax.term_id = tter.term_id) ";
|
678 |
}
|
679 |
$this->se_log("tags join: ".$join);
|
680 |
return $join;
|
681 |
}
|
682 |
|
683 |
+
// Highlight the searched terms into Title, excerpt and content
|
684 |
+
// in the search result page.
|
685 |
+
function se_postfilter($postcontent)
|
686 |
+
{
|
687 |
+
global $wp_query, $wpdb;
|
688 |
+
$s = $wp_query->query_vars['s'];
|
689 |
+
// highlighting
|
690 |
+
if (is_search() && $s != '')
|
691 |
+
{
|
692 |
+
$highlight_color = $this->options['se_highlight_color'];
|
693 |
+
$highlight_style = $this->options['se_highlight_style'];
|
694 |
+
$search_terms = $this->se_get_search_terms();
|
695 |
+
foreach ( $search_terms as $term )
|
696 |
+
{
|
697 |
+
if ($highlight_color != '')
|
698 |
+
$postcontent = preg_replace(
|
699 |
+
'"('.$term.')"i'
|
700 |
+
, '<span class="search-everything-highlight-color" style="background-color:'.$highlight_color.'">$1</span>'
|
701 |
+
, $postcontent
|
702 |
+
);
|
703 |
+
else
|
704 |
+
$postcontent = preg_replace(
|
705 |
+
'"('.$term.')"i'
|
706 |
+
, '<span class="search-everything-highlight" style="'.$highlight_style.'">$1</span>'
|
707 |
+
, $postcontent
|
708 |
+
);
|
709 |
+
}
|
710 |
+
}
|
711 |
+
return $postcontent;
|
712 |
+
}
|
713 |
} // END
|
714 |
|
715 |
?>
|
views/options.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
Class se_admin {
|
4 |
|
5 |
-
var $version = '6.
|
6 |
|
7 |
function se_admin() {
|
8 |
|
@@ -42,7 +42,10 @@ Class se_admin {
|
|
42 |
'se_use_attachment_search' => $_POST["search_attachments"],
|
43 |
'se_use_authors' => $_POST["search_authors"],
|
44 |
'se_use_cmt_authors' => $_POST["search_cmt_authors"],
|
45 |
-
'se_use_metadata_search' => $_POST["search_metadata"]
|
|
|
|
|
|
|
46 |
|
47 |
);
|
48 |
|
@@ -216,6 +219,23 @@ Class se_admin {
|
|
216 |
<br/><small></small>
|
217 |
</td>
|
218 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
</table>
|
221 |
<table style="margin-bottom: 20px;"></table>
|
@@ -242,7 +262,14 @@ Class se_admin {
|
|
242 |
<br/><small><?php _e('Comma separated category IDs (example: 1, 4)','SearchEverything'); ?></small>
|
243 |
</td>
|
244 |
</tr>
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
</table>
|
247 |
|
248 |
|
2 |
|
3 |
Class se_admin {
|
4 |
|
5 |
+
var $version = '6.2';
|
6 |
|
7 |
function se_admin() {
|
8 |
|
42 |
'se_use_attachment_search' => $_POST["search_attachments"],
|
43 |
'se_use_authors' => $_POST["search_authors"],
|
44 |
'se_use_cmt_authors' => $_POST["search_cmt_authors"],
|
45 |
+
'se_use_metadata_search' => $_POST["search_metadata"],
|
46 |
+
'se_use_highlight' => $_POST["search_highlight"],
|
47 |
+
'se_highlight_color' => $_POST["highlight_color"],
|
48 |
+
'se_highlight_style' => $_POST["highlight_style"]
|
49 |
|
50 |
);
|
51 |
|
219 |
<br/><small></small>
|
220 |
</td>
|
221 |
</tr>
|
222 |
+
<tr class="mainrow">
|
223 |
+
<td class="titledesc"><?php _e('Highlight Search Terms','SearchEverything'); ?>:</td>
|
224 |
+
<td class="forminp">
|
225 |
+
<select id="search_highlight" name="search_highlight">
|
226 |
+
<option<?php if ($options['se_use_highlight'] == 'No') { echo ' selected="selected"'; } ?>> </option>
|
227 |
+
<option<?php if ($options['se_use_highlight'] == 'Yes') { echo ' selected="selected"'; } ?>><?php _e('Yes', 'SearchEverything'); ?></option>
|
228 |
+
</select>
|
229 |
+
<br/><small></small>
|
230 |
+
</td>
|
231 |
+
</tr>
|
232 |
+
<tr class="mainrow">
|
233 |
+
<td class="titledesc"> <?php _e('Highlight Background Color','SearchEverything'); ?>:</td>
|
234 |
+
<td class="forminp">
|
235 |
+
<input type="text" id="highlight_color" name="highlight_color" value="<?php echo $options['se_highlight_color'];?>" />
|
236 |
+
<br/><small><?php _e('Examples:<br/>\'#FFF984\' or \'red\'','SearchEverything'); ?></small>
|
237 |
+
</td>
|
238 |
+
</tr>
|
239 |
|
240 |
</table>
|
241 |
<table style="margin-bottom: 20px;"></table>
|
262 |
<br/><small><?php _e('Comma separated category IDs (example: 1, 4)','SearchEverything'); ?></small>
|
263 |
</td>
|
264 |
</tr>
|
265 |
+
<tr class="mainrow">
|
266 |
+
<td class="titledesc"><?php _e('Full Highlight Style','SearchEverything'); ?>:</td>
|
267 |
+
<td class="forminp">
|
268 |
+
<small><?php _e('Important: \'Highlight Background Color\' must be blank to use this advanced styling.', 'SearchEverything') ?></small><br/>
|
269 |
+
<input type="text" id="highlight_style" name="highlight_style" value="<?php echo $options['se_highlight_style'];?>" />
|
270 |
+
<br/><small><?php _e('Example:<br/>background-color: #FFF984; font-weight: bold; color: #000; padding: 0 1px;','SearchEverything'); ?></small>
|
271 |
+
</td>
|
272 |
+
</tr>
|
273 |
</table>
|
274 |
|
275 |
|