Search Everything - Version 6.8

Version Description

Download this release

Release Info

Developer dancameron
Plugin Icon wp plugin Search Everything
Version 6.8
Comparing to
See all releases

Code changes from version 6.7 to 6.8

Files changed (4) hide show
  1. README.markdown +1 -0
  2. readme.txt +6 -6
  3. search-everything.php +47 -13
  4. views/options.php +0 -3
README.markdown CHANGED
@@ -16,6 +16,7 @@ What it does:
16
  Search Everything increases the ability of the default Wordpress Search, options included:
17
 
18
  * Search Highlighting
 
19
  * Search Every Page
20
  * Search Every Tag
21
  * Search Custom Taxonomies ( new )
16
  Search Everything increases the ability of the default Wordpress Search, options included:
17
 
18
  * Search Highlighting
19
+ * Search By Author
20
  * Search Every Page
21
  * Search Every Tag
22
  * Search Custom Taxonomies ( new )
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: dancameron, sproutventure
3
  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: 2.1
6
  Tested up to: 3.3
7
- Stable tag: 6.7
8
 
9
  Increases Wordpress' default search functionality in three easy steps.
10
 
@@ -56,11 +56,11 @@ Read the installation guide.
56
 
57
  = Where is feature x? =
58
 
59
- [Github Issues](https://github.com/sproutventure/search-everything-wordpress-plugin/issues "Github Issues") Label it as a "feature-request"
60
 
61
  = It *still* doesn't work (and you're certain there's a bug) =
62
 
63
- [Github Issues](https://github.com/sproutventure/search-everything-wordpress-plugin/issues "Github Issues")
64
 
65
  = What Translations are included? =
66
 
@@ -90,8 +90,8 @@ Read the installation guide.
90
 
91
  == Help ==
92
 
93
- Fork this plugin on github and send me requests to commit your changes upstream.
94
 
95
  == Support ==
96
 
97
- Use the WordPress forums.
2
  Contributors: dancameron, sproutventure
3
  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
8
 
9
  Increases Wordpress' default search functionality in three easy steps.
10
 
56
 
57
  = Where is feature x? =
58
 
59
+ [github Issues](https://github.com/sproutventure/search-everything-wordpress-plugin/issues "Github Issues"). Label it as a "feature-request"
60
 
61
  = It *still* doesn't work (and you're certain there's a bug) =
62
 
63
+ [github Issues](https://github.com/sproutventure/search-everything-wordpress-plugin/issues "Github Issues")
64
 
65
  = What Translations are included? =
66
 
90
 
91
  == Help ==
92
 
93
+ Send me your pull requests on [github](https://github.com/sproutventure/search-everything-wordpress-plugin "github")
94
 
95
  == Support ==
96
 
97
+ [github Issues](https://github.com/sproutventure/search-everything-wordpress-plugin/issues "Github Issues")
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
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();
@@ -106,6 +106,8 @@ Class SearchEverything {
106
  $this->se_log("searching metadata");
107
  }
108
 
 
 
109
  if ($this->options['se_exclude_posts_list'] != '')
110
  {
111
  $this->se_log("searching excluding posts");
@@ -117,9 +119,9 @@ Class SearchEverything {
117
  $this->se_log("searching excluding categories");
118
  }
119
 
120
- if ("Yes" == $this->options['se_use_authors'] && !$this->wp_ver28)// Need some help getting this back into the mix
121
  {
122
- add_filter('posts_where', array(&$this, 'se_search_authors'));
123
  add_filter('posts_join', array(&$this, 'se_search_authors_join'));
124
  $this->se_log("searching authors");
125
  }
@@ -159,6 +161,7 @@ Class SearchEverything {
159
  $search_terms = array($s);
160
  } else {
161
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
 
162
  $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
163
  }
164
  }
@@ -169,7 +172,7 @@ Class SearchEverything {
169
  function se_search_where($where)
170
  {
171
  global $wp_query, $wpdb;
172
- $searchQuery = '';
173
 
174
  //add filters based upon option settings
175
  if ("Yes" == $this->options['se_use_tag_search'])
@@ -192,9 +195,13 @@ Class SearchEverything {
192
  {
193
  $searchQuery .= $this->se_build_search_comments();
194
  }
 
 
 
 
195
  if ($searchQuery != '')
196
  {
197
- $where = str_replace( ")))", ")$searchQuery))", $where );
198
 
199
  }
200
  if ($this->options['se_exclude_posts_list'] != '')
@@ -209,6 +216,31 @@ Class SearchEverything {
209
  $this->se_log("global where: ".$where);
210
  return $where;
211
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
  // Exclude post revisions
214
  function se_no_revisions($where)
@@ -220,7 +252,7 @@ Class SearchEverything {
220
  {
221
  $where = 'AND (' . substr($where, strpos($where, 'AND')+3) . ") AND $wpdb->posts.post_type != 'revision'";
222
  }
223
- $where = 'AND (' . substr($where, strpos($where, 'AND')+3) . ') AND post_type != \'revision\'';
224
  }
225
  return $where;
226
  }
@@ -435,7 +467,7 @@ Class SearchEverything {
435
  }
436
 
437
  // Build the author search
438
- function se_search_authors($where)
439
  {
440
  global $wp_query, $wpdb;
441
  $s = $wp_query->query_vars['s'];
@@ -446,7 +478,7 @@ Class SearchEverything {
446
  if ( !empty($search_terms) ) {
447
  // Building search query
448
  $n = ($exact) ? '' : '%';
449
- $searchand = '';
450
  foreach($search_terms as $term) {
451
  $term = addslashes_gpc($term);
452
  if ($this->wp_ver23)
@@ -455,18 +487,20 @@ Class SearchEverything {
455
  } else {
456
  $search .= "{$searchand}(u.display_name LIKE '{$n}{$term}{$n}')";
457
  }
458
- $searchand = ' AND ';
459
  }
460
  $sentence_term = $wpdb->escape($s);
461
  if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
462
  {
463
  if ($this->wp_ver23)
464
  {
465
- $search = "($search) OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
466
  } else {
467
- $search = "($search) OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
468
  }
469
  }
 
 
470
 
471
  if ( !empty($search) )
472
  $search = " OR ({$search}) ";
@@ -703,7 +737,7 @@ Class SearchEverything {
703
 
704
  if (!empty($wp_query->query_vars['s']))
705
  {
706
- $join .= " LEFT JOIN $wpdb->users AS u ON ($wpdb->posts.ID = u.ID) ";
707
  }
708
  $this->se_log("authors join: ".$join);
709
  return $join;
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.8
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();
106
  $this->se_log("searching metadata");
107
  }
108
 
109
+
110
+
111
  if ($this->options['se_exclude_posts_list'] != '')
112
  {
113
  $this->se_log("searching excluding posts");
119
  $this->se_log("searching excluding categories");
120
  }
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
  }
161
  $search_terms = array($s);
162
  } else {
163
  preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
164
+ echo '<!--'.var_export($matches, true).'-->'."\n\n";
165
  $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
166
  }
167
  }
172
  function se_search_where($where)
173
  {
174
  global $wp_query, $wpdb;
175
+ $searchQuery = $this->se_search_default();
176
 
177
  //add filters based upon option settings
178
  if ("Yes" == $this->options['se_use_tag_search'])
195
  {
196
  $searchQuery .= $this->se_build_search_comments();
197
  }
198
+ if ("Yes" == $this->options['se_use_authors'])
199
+ {
200
+ $searchQuery .= $this->se_search_authors();
201
+ }
202
  if ($searchQuery != '')
203
  {
204
+ $where = preg_replace('#\(\(\(.*?\)\)\)#', '(('.$searchQuery.'))', $where);
205
 
206
  }
207
  if ($this->options['se_exclude_posts_list'] != '')
216
  $this->se_log("global where: ".$where);
217
  return $where;
218
  }
219
+ // search for terms in default locations like title and content
220
+ // replacing the old search terms seems to be the best way to
221
+ // avoid issue with multiple terms
222
+ function se_search_default(){
223
+
224
+ global $wp_query, $wpdb;
225
+
226
+ $n = ($wp_query->query_vars['exact']) ? '' : '%';
227
+ $search = '';
228
+ $seperator = ' OR ';
229
+ $terms = $this->se_get_search_terms();
230
+
231
+ // build sentence version first
232
+ $sentance = $wpdb->escape($wp_query->query_vars['s']);
233
+ $search = "($wpdb->posts.post_title LIKE '{$n}{$sentance}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$sentance}{$n}')";
234
+ // if it's not a sentance add other terms
235
+ if(!$wp_query->query_vars['sentence'] && count($terms) > 1 && $terms[0] != $sentence){
236
+ foreach($terms as $term){
237
+ $search .= $seperator;
238
+ $search .= "($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
239
+ $seperator = ' OR ';
240
+ }
241
+ }
242
+ return $search;
243
+ }
244
 
245
  // Exclude post revisions
246
  function se_no_revisions($where)
252
  {
253
  $where = 'AND (' . substr($where, strpos($where, 'AND')+3) . ") AND $wpdb->posts.post_type != 'revision'";
254
  }
255
+ $where = ' AND (' . substr($where, strpos($where, 'AND')+3) . ') AND post_type != \'revision\'';
256
  }
257
  return $where;
258
  }
467
  }
468
 
469
  // Build the author search
470
+ function se_search_authors()
471
  {
472
  global $wp_query, $wpdb;
473
  $s = $wp_query->query_vars['s'];
478
  if ( !empty($search_terms) ) {
479
  // Building search query
480
  $n = ($exact) ? '' : '%';
481
+ $searchor = '';
482
  foreach($search_terms as $term) {
483
  $term = addslashes_gpc($term);
484
  if ($this->wp_ver23)
487
  } else {
488
  $search .= "{$searchand}(u.display_name LIKE '{$n}{$term}{$n}')";
489
  }
490
+ $searchand = ' OR ';
491
  }
492
  $sentence_term = $wpdb->escape($s);
493
  if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $sentence_term )
494
  {
495
  if ($this->wp_ver23)
496
  {
497
+ $search .= " OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
498
  } else {
499
+ $search .= " OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
500
  }
501
  }
502
+
503
+
504
 
505
  if ( !empty($search) )
506
  $search = " OR ({$search}) ";
737
 
738
  if (!empty($wp_query->query_vars['s']))
739
  {
740
+ $join .= " LEFT JOIN $wpdb->users AS u ON ($wpdb->posts.post_author = u.ID) ";
741
  }
742
  $this->se_log("authors join: ".$join);
743
  return $join;
views/options.php CHANGED
@@ -230,13 +230,10 @@ Class se_admin {
230
  <tr class="mainrow">
231
  <td class="titledesc"><?php _e('Search every author','SearchEverything'); ?>:</td>
232
  <td class="forminp">
233
- <?php if ($wp_version <= '2.8'): ?>
234
  <select id="search_authors" name="search_authors">
235
  <option<?php if ($options['se_use_authors'] == 'No') { echo ' selected="selected"'; } ?> value="No">&nbsp;&nbsp;</option>
236
  <option<?php if ($options['se_use_authors'] == 'Yes') { echo ' selected="selected"'; } ?> value="Yes"><?php _e('Yes', 'SearchEverything'); ?></option>
237
  </select>
238
- <?php endif; ?>
239
- <small><?php if ($wp_version >= '2.8') { _e('This is disabled for WP 2.8+. I\'d appreciate the help if you have a fix.', 'SearchEverything');} ?></small>
240
  </td>
241
  </tr>
242
  <tr class="mainrow">
230
  <tr class="mainrow">
231
  <td class="titledesc"><?php _e('Search every author','SearchEverything'); ?>:</td>
232
  <td class="forminp">
 
233
  <select id="search_authors" name="search_authors">
234
  <option<?php if ($options['se_use_authors'] == 'No') { echo ' selected="selected"'; } ?> value="No">&nbsp;&nbsp;</option>
235
  <option<?php if ($options['se_use_authors'] == 'Yes') { echo ' selected="selected"'; } ?> value="Yes"><?php _e('Yes', 'SearchEverything'); ?></option>
236
  </select>
 
 
237
  </td>
238
  </tr>
239
  <tr class="mainrow">