Version Description
Download this release
Release Info
Developer | dancameron |
Plugin | Search Everything |
Version | 6.9 |
Comparing to | |
See all releases |
Code changes from version 6.8.2 to 6.9
- readme.txt +1 -1
- search-everything.php +44 -41
- views/options.php +2 -8
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://bit.ly/plugin-donations
|
|
4 |
Tags: search, search highlight, tag search, category search, category exclusion, comment search, page search, admin, seo, post filter
|
5 |
Requires at least: 3
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 6.
|
8 |
|
9 |
Increases Wordpress' default search functionality in three easy steps.
|
10 |
|
4 |
Tags: search, search highlight, tag search, category search, category exclusion, comment search, page search, admin, seo, post filter
|
5 |
Requires at least: 3
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 6.9
|
8 |
|
9 |
Increases Wordpress' default search functionality in three easy steps.
|
10 |
|
search-everything.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Search Everything
|
4 |
Plugin URI: https://github.com/sproutventure/search-everything-wordpress-plugin/
|
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.
|
7 |
Author: Dan Cameron of Sprout Venture
|
8 |
Author URI: http://sproutventure.com/
|
9 |
*/
|
@@ -43,7 +43,7 @@ Class SearchEverything {
|
|
43 |
$this->wp_ver25 = ($wp_version >= '2.5');
|
44 |
$this->wp_ver28 = ($wp_version >= '2.8');
|
45 |
$this->options = get_option('se_options');
|
46 |
-
|
47 |
if (is_admin()) {
|
48 |
include ( SE_ABSPATH . 'views/options.php' );
|
49 |
$SEAdmin = new se_admin();
|
@@ -52,20 +52,20 @@ Class SearchEverything {
|
|
52 |
if ("Yes" == $this->options['se_use_tag_search'] || "Yes" == $this->options['se_use_category_search'] || "Yes" == $this->options['se_use_tax_search'])
|
53 |
{
|
54 |
add_filter('posts_join', array(&$this, 'se_terms_join'));
|
55 |
-
if ("Yes" == $this->options['se_use_tag_search'])
|
56 |
{
|
57 |
$this->se_log("searching tags");
|
58 |
-
}
|
59 |
-
if ("Yes" == $this->options['se_use_category_search'])
|
60 |
{
|
61 |
$this->se_log("searching categories");
|
62 |
}
|
63 |
-
if ("Yes" == $this->options['se_use_tax_search'])
|
64 |
{
|
65 |
$this->se_log("searching custom taxonomies");
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
if ("Yes" == $this->options['se_use_page_search'])
|
70 |
{
|
71 |
add_filter('posts_where', array(&$this, 'se_search_pages'));
|
@@ -121,7 +121,7 @@ Class SearchEverything {
|
|
121 |
|
122 |
if ("Yes" == $this->options['se_use_authors'])
|
123 |
{
|
124 |
-
|
125 |
add_filter('posts_join', array(&$this, 'se_search_authors_join'));
|
126 |
$this->se_log("searching authors");
|
127 |
}
|
@@ -131,9 +131,9 @@ Class SearchEverything {
|
|
131 |
add_filter('posts_where', array(&$this, 'se_no_revisions'));
|
132 |
|
133 |
add_filter('posts_request', array(&$this, 'se_distinct'));
|
134 |
-
|
135 |
add_filter('posts_where', array(&$this, 'se_no_future'));
|
136 |
-
|
137 |
// Highlight content
|
138 |
if("Yes" == $this->options['se_use_highlight'])
|
139 |
{
|
@@ -151,7 +151,7 @@ Class SearchEverything {
|
|
151 |
$s = $wp_query->query_vars['s'];
|
152 |
$sentence = $wp_query->query_vars['sentence'];
|
153 |
$search_terms = array();
|
154 |
-
|
155 |
if ( !empty($s) )
|
156 |
{
|
157 |
// added slashes screw with quote grouping when done early, so done later
|
@@ -216,28 +216,31 @@ Class SearchEverything {
|
|
216 |
return $where;
|
217 |
}
|
218 |
// search for terms in default locations like title and content
|
219 |
-
// replacing the old search terms seems to be the best way to
|
220 |
// avoid issue with multiple terms
|
221 |
function se_search_default(){
|
222 |
-
|
223 |
global $wp_query, $wpdb;
|
224 |
|
225 |
$n = ($wp_query->query_vars['exact']) ? '' : '%';
|
226 |
$search = '';
|
227 |
-
|
228 |
$terms = $this->se_get_search_terms();
|
229 |
-
|
230 |
-
// build sentence version first
|
231 |
-
$sentance = $wpdb->escape($wp_query->query_vars['s']);
|
232 |
-
$search = "($wpdb->posts.post_title LIKE '{$n}{$sentance}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$sentance}{$n}')";
|
233 |
// if it's not a sentance add other terms
|
234 |
-
|
|
|
235 |
foreach($terms as $term){
|
236 |
$search .= $seperator;
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
}
|
|
|
241 |
return $search;
|
242 |
}
|
243 |
|
@@ -270,7 +273,7 @@ Class SearchEverything {
|
|
270 |
}
|
271 |
return $where;
|
272 |
}
|
273 |
-
|
274 |
// Logs search into a file
|
275 |
function se_log($msg)
|
276 |
{
|
@@ -366,7 +369,7 @@ Class SearchEverything {
|
|
366 |
if(!$this->wp_ver28)
|
367 |
{
|
368 |
$where = str_replace(" AND (post_status = 'publish'", " AND ((post_status = 'publish' OR post_status = 'draft')", $where);
|
369 |
-
}
|
370 |
else
|
371 |
{
|
372 |
$where = str_replace(" AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft'", $where);
|
@@ -386,19 +389,19 @@ Class SearchEverything {
|
|
386 |
$where = str_replace('"', '\'', $where);
|
387 |
if(!$this->wp_ver28)
|
388 |
{
|
389 |
-
$where = str_replace(" AND (post_status = 'publish'", " AND (post_status = 'publish' OR
|
390 |
-
$where = str_replace("AND
|
391 |
}
|
392 |
else
|
393 |
{
|
394 |
-
$where = str_replace(" AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.
|
395 |
-
$where = str_replace("AND $wpdb->posts.
|
396 |
}
|
397 |
}
|
398 |
$this->se_log("attachments where: ".$where);
|
399 |
return $where;
|
400 |
}
|
401 |
-
|
402 |
// create the comments data query
|
403 |
function se_build_search_comments()
|
404 |
{
|
@@ -464,7 +467,7 @@ Class SearchEverything {
|
|
464 |
$this->se_log("comments sql: ".$search);
|
465 |
return $search;
|
466 |
}
|
467 |
-
|
468 |
// Build the author search
|
469 |
function se_search_authors()
|
470 |
{
|
@@ -473,7 +476,7 @@ Class SearchEverything {
|
|
473 |
$search_terms = $this->se_get_search_terms();
|
474 |
$exact = $wp_query->query_vars['exact'];
|
475 |
$search = '';
|
476 |
-
|
477 |
if ( !empty($search_terms) ) {
|
478 |
// Building search query
|
479 |
$n = ($exact) ? '' : '%';
|
@@ -500,16 +503,16 @@ Class SearchEverything {
|
|
500 |
}
|
501 |
|
502 |
|
503 |
-
|
504 |
if ( !empty($search) )
|
505 |
$search = " OR ({$search}) ";
|
506 |
-
|
507 |
}
|
508 |
-
|
509 |
$this->se_log("user where: ".$search);
|
510 |
return $search;
|
511 |
}
|
512 |
-
|
513 |
// create the search meta data query
|
514 |
function se_build_search_metadata()
|
515 |
{
|
@@ -543,10 +546,10 @@ Class SearchEverything {
|
|
543 |
$search = "($search) OR (meta_value LIKE '{$n}{$sentence_term}{$n}')";
|
544 |
}
|
545 |
}
|
546 |
-
|
547 |
if ( !empty($search) )
|
548 |
$search = " OR ({$search}) ";
|
549 |
-
|
550 |
}
|
551 |
$this->se_log("meta where: ".$search);
|
552 |
return $search;
|
@@ -711,7 +714,7 @@ Class SearchEverything {
|
|
711 |
if ($this->wp_ver23)
|
712 |
{
|
713 |
$join .= " LEFT JOIN $wpdb->comments AS cmt ON ( cmt.comment_post_ID = $wpdb->posts.ID ) ";
|
714 |
-
|
715 |
} else {
|
716 |
|
717 |
if ('Yes' == $this->options['se_approved_comments_only'])
|
@@ -722,7 +725,7 @@ Class SearchEverything {
|
|
722 |
}
|
723 |
$join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
|
724 |
}
|
725 |
-
|
726 |
}
|
727 |
$this->se_log("comments join: ".$join);
|
728 |
return $join;
|
@@ -779,10 +782,10 @@ Class SearchEverything {
|
|
779 |
$on[] = "ttax.taxonomy = 'post_tag'";
|
780 |
}
|
781 |
// if we're searching custom taxonomies
|
782 |
-
if ( $this->options['se_use_tax_search'] )
|
783 |
{
|
784 |
$all_taxonomies = get_object_taxonomies('post');
|
785 |
-
foreach ($all_taxonomies as $taxonomy)
|
786 |
{
|
787 |
if ($taxonomy == 'post_tag' || $taxonomy == 'category')
|
788 |
continue;
|
@@ -815,7 +818,7 @@ Class SearchEverything {
|
|
815 |
if (preg_match('/\>/', $term))
|
816 |
continue; //don't try to highlight this one
|
817 |
$term = preg_quote($term);
|
818 |
-
|
819 |
if ($highlight_color != '')
|
820 |
$postcontent = preg_replace(
|
821 |
'"(?<!\<)(?<!\w)(\pL*'.$term.'\pL*)(?!\w|[^<>]*>)"i'
|
3 |
Plugin Name: Search Everything
|
4 |
Plugin URI: https://github.com/sproutventure/search-everything-wordpress-plugin/
|
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.9
|
7 |
Author: Dan Cameron of Sprout Venture
|
8 |
Author URI: http://sproutventure.com/
|
9 |
*/
|
43 |
$this->wp_ver25 = ($wp_version >= '2.5');
|
44 |
$this->wp_ver28 = ($wp_version >= '2.8');
|
45 |
$this->options = get_option('se_options');
|
46 |
+
|
47 |
if (is_admin()) {
|
48 |
include ( SE_ABSPATH . 'views/options.php' );
|
49 |
$SEAdmin = new se_admin();
|
52 |
if ("Yes" == $this->options['se_use_tag_search'] || "Yes" == $this->options['se_use_category_search'] || "Yes" == $this->options['se_use_tax_search'])
|
53 |
{
|
54 |
add_filter('posts_join', array(&$this, 'se_terms_join'));
|
55 |
+
if ("Yes" == $this->options['se_use_tag_search'])
|
56 |
{
|
57 |
$this->se_log("searching tags");
|
58 |
+
}
|
59 |
+
if ("Yes" == $this->options['se_use_category_search'])
|
60 |
{
|
61 |
$this->se_log("searching categories");
|
62 |
}
|
63 |
+
if ("Yes" == $this->options['se_use_tax_search'])
|
64 |
{
|
65 |
$this->se_log("searching custom taxonomies");
|
66 |
}
|
67 |
}
|
68 |
+
|
69 |
if ("Yes" == $this->options['se_use_page_search'])
|
70 |
{
|
71 |
add_filter('posts_where', array(&$this, 'se_search_pages'));
|
121 |
|
122 |
if ("Yes" == $this->options['se_use_authors'])
|
123 |
{
|
124 |
+
|
125 |
add_filter('posts_join', array(&$this, 'se_search_authors_join'));
|
126 |
$this->se_log("searching authors");
|
127 |
}
|
131 |
add_filter('posts_where', array(&$this, 'se_no_revisions'));
|
132 |
|
133 |
add_filter('posts_request', array(&$this, 'se_distinct'));
|
134 |
+
|
135 |
add_filter('posts_where', array(&$this, 'se_no_future'));
|
136 |
+
|
137 |
// Highlight content
|
138 |
if("Yes" == $this->options['se_use_highlight'])
|
139 |
{
|
151 |
$s = $wp_query->query_vars['s'];
|
152 |
$sentence = $wp_query->query_vars['sentence'];
|
153 |
$search_terms = array();
|
154 |
+
|
155 |
if ( !empty($s) )
|
156 |
{
|
157 |
// added slashes screw with quote grouping when done early, so done later
|
216 |
return $where;
|
217 |
}
|
218 |
// search for terms in default locations like title and content
|
219 |
+
// replacing the old search terms seems to be the best way to
|
220 |
// avoid issue with multiple terms
|
221 |
function se_search_default(){
|
222 |
+
|
223 |
global $wp_query, $wpdb;
|
224 |
|
225 |
$n = ($wp_query->query_vars['exact']) ? '' : '%';
|
226 |
$search = '';
|
227 |
+
//$seperator = ' OR ';
|
228 |
$terms = $this->se_get_search_terms();
|
229 |
+
|
|
|
|
|
|
|
230 |
// if it's not a sentance add other terms
|
231 |
+
$search .= '(';
|
232 |
+
if(!$wp_query->query_vars['sentence'] && count($terms) > 1){
|
233 |
foreach($terms as $term){
|
234 |
$search .= $seperator;
|
235 |
+
|
236 |
+
|
237 |
+
$search .= sprintf("((%s.post_title LIKE '%s%s%s') OR (%s.post_content LIKE '%s%s%s'))", $wpdb->posts, $n, $term, $n, $wpdb->posts, $n, $term, $n);
|
238 |
+
|
239 |
+
|
240 |
+
$seperator = ' AND ';
|
241 |
}
|
242 |
}
|
243 |
+
$search .= ')';
|
244 |
return $search;
|
245 |
}
|
246 |
|
273 |
}
|
274 |
return $where;
|
275 |
}
|
276 |
+
|
277 |
// Logs search into a file
|
278 |
function se_log($msg)
|
279 |
{
|
369 |
if(!$this->wp_ver28)
|
370 |
{
|
371 |
$where = str_replace(" AND (post_status = 'publish'", " AND ((post_status = 'publish' OR post_status = 'draft')", $where);
|
372 |
+
}
|
373 |
else
|
374 |
{
|
375 |
$where = str_replace(" AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft'", $where);
|
389 |
$where = str_replace('"', '\'', $where);
|
390 |
if(!$this->wp_ver28)
|
391 |
{
|
392 |
+
$where = str_replace(" AND (post_status = 'publish'", " AND (post_status = 'publish' OR post_type = 'attachment'", $where);
|
393 |
+
$where = str_replace("AND post_type != 'attachment'","",$where);
|
394 |
}
|
395 |
else
|
396 |
{
|
397 |
+
$where = str_replace(" AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_type = 'attachment'", $where);
|
398 |
+
$where = str_replace("AND $wpdb->posts.post_type != 'attachment'","",$where);
|
399 |
}
|
400 |
}
|
401 |
$this->se_log("attachments where: ".$where);
|
402 |
return $where;
|
403 |
}
|
404 |
+
|
405 |
// create the comments data query
|
406 |
function se_build_search_comments()
|
407 |
{
|
467 |
$this->se_log("comments sql: ".$search);
|
468 |
return $search;
|
469 |
}
|
470 |
+
|
471 |
// Build the author search
|
472 |
function se_search_authors()
|
473 |
{
|
476 |
$search_terms = $this->se_get_search_terms();
|
477 |
$exact = $wp_query->query_vars['exact'];
|
478 |
$search = '';
|
479 |
+
|
480 |
if ( !empty($search_terms) ) {
|
481 |
// Building search query
|
482 |
$n = ($exact) ? '' : '%';
|
503 |
}
|
504 |
|
505 |
|
506 |
+
|
507 |
if ( !empty($search) )
|
508 |
$search = " OR ({$search}) ";
|
509 |
+
|
510 |
}
|
511 |
+
|
512 |
$this->se_log("user where: ".$search);
|
513 |
return $search;
|
514 |
}
|
515 |
+
|
516 |
// create the search meta data query
|
517 |
function se_build_search_metadata()
|
518 |
{
|
546 |
$search = "($search) OR (meta_value LIKE '{$n}{$sentence_term}{$n}')";
|
547 |
}
|
548 |
}
|
549 |
+
|
550 |
if ( !empty($search) )
|
551 |
$search = " OR ({$search}) ";
|
552 |
+
|
553 |
}
|
554 |
$this->se_log("meta where: ".$search);
|
555 |
return $search;
|
714 |
if ($this->wp_ver23)
|
715 |
{
|
716 |
$join .= " LEFT JOIN $wpdb->comments AS cmt ON ( cmt.comment_post_ID = $wpdb->posts.ID ) ";
|
717 |
+
|
718 |
} else {
|
719 |
|
720 |
if ('Yes' == $this->options['se_approved_comments_only'])
|
725 |
}
|
726 |
$join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
|
727 |
}
|
728 |
+
|
729 |
}
|
730 |
$this->se_log("comments join: ".$join);
|
731 |
return $join;
|
782 |
$on[] = "ttax.taxonomy = 'post_tag'";
|
783 |
}
|
784 |
// if we're searching custom taxonomies
|
785 |
+
if ( $this->options['se_use_tax_search'] )
|
786 |
{
|
787 |
$all_taxonomies = get_object_taxonomies('post');
|
788 |
+
foreach ($all_taxonomies as $taxonomy)
|
789 |
{
|
790 |
if ($taxonomy == 'post_tag' || $taxonomy == 'category')
|
791 |
continue;
|
818 |
if (preg_match('/\>/', $term))
|
819 |
continue; //don't try to highlight this one
|
820 |
$term = preg_quote($term);
|
821 |
+
|
822 |
if ($highlight_color != '')
|
823 |
$postcontent = preg_replace(
|
824 |
'"(?<!\<)(?<!\w)(\pL*'.$term.'\pL*)(?!\w|[^<>]*>)"i'
|
views/options.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
Class se_admin {
|
4 |
|
5 |
-
var $version = '6.
|
6 |
|
7 |
function se_admin() {
|
8 |
|
@@ -353,13 +353,7 @@ Class se_admin {
|
|
353 |
</td>
|
354 |
<td>
|
355 |
<ul class="SE_lists">
|
356 |
-
<li><a href="
|
357 |
-
<li><a href="#">Gary Traffanstedt</a> (<a href="https://core.sproutventure.com/projects/search-everything/issues" target="blank">#43</a>)</li>
|
358 |
-
<li><a href="http://codium.co.nz" target="blank">Matias Gertel</a></li>
|
359 |
-
<li><a href="http://striderweb.com/" target="blank">Stephen Rider</a></li>
|
360 |
-
<li><a href="http://chrismeller.com/" target="blank">Chris Meller</a></li>
|
361 |
-
<li><a href="http://kinrowan.net/" target="blank">Cori Schlegel</a></li>
|
362 |
-
<li><?php _e('and many more...', 'SearchEverything'); ?><a href="https://core.sproutventure.com/projects/search-everything/issues" target="blank"><?php _e('how about you?', 'SearchEverything'); ?></a></li>
|
363 |
</ul>
|
364 |
</td>
|
365 |
<td>
|
2 |
|
3 |
Class se_admin {
|
4 |
|
5 |
+
var $version = '6.9';
|
6 |
|
7 |
function se_admin() {
|
8 |
|
353 |
</td>
|
354 |
<td>
|
355 |
<ul class="SE_lists">
|
356 |
+
<li><a href="https://github.com/ninnypants"><strong>EricLe Bail</strong></a></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
</ul>
|
358 |
</td>
|
359 |
<td>
|