Search Everything - Version 4.1

Version Description

Download this release

Release Info

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

Code changes from version 4.0.3 to 4.1

SE-Admin.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ Class SearchEverythingAdmin {
4
+
5
+ var $version = '4.1';
6
+
7
+ function SearchEverythingAdmin() {
8
+
9
+ // Load language file
10
+ $locale = get_locale();
11
+ if ( !empty($locale) )
12
+ load_textdomain('SearchEverything', SE_ABSPATH .'lang/SE4-'.$locale.'.mo');
13
+
14
+
15
+ add_action('admin_head', array(&$this, 'SE4_options_style'));
16
+ add_action('admin_menu', array(&$this, 'SE4_add_options_panel'));
17
+
18
+ }
19
+
20
+ function SE4_add_options_panel() {
21
+ add_options_page('Search', 'Search Everything', 7, 'manage_search', array(&$this, 'SE4_option_page'));
22
+ }
23
+
24
+ //build admin interface
25
+ function SE4_option_page() {
26
+ global $wpdb, $table_prefix;
27
+
28
+ if($_POST['action'] == "save") {
29
+ echo "<div class=\"updated fade\" id=\"limitcatsupdatenotice\"><p>" . __("Search Everything Options <strong>Updated</strong>.") . "</p></div>";
30
+
31
+ $new_options = array(
32
+ 'SE4_exclude_categories' => $_POST["exclude_categories"],
33
+ 'SE4_exclude_categories_list' => $_POST["exclude_categories_list"],
34
+ 'SE4_exclude_posts' => $_POST["exclude_posts"],
35
+ 'SE4_exclude_posts_list' => $_POST["exclude_posts_list"],
36
+ 'SE4_use_page_search' => $_POST["search_pages"],
37
+ 'SE4_use_comment_search' => $_POST["search_comments"],
38
+ 'SE4_approved_comments_only' => $_POST["appvd_comments"],
39
+ 'SE4_approved_pages_only' => $_POST["appvd_pages"],
40
+ 'SE4_use_excerpt_search' => $_POST["search_excerpt"],
41
+ 'SE4_use_draft_search' => $_POST["search_drafts"],
42
+ 'SE4_use_attachment_search' => $_POST["search_attachments"],
43
+ 'SE4_use_metadata_search' => $_POST["search_metadata"]
44
+ );
45
+
46
+ update_option("SE4_options", $new_options);
47
+
48
+ }
49
+
50
+ $options = get_option('SE4_options');
51
+
52
+ ?>
53
+
54
+ <div class="wrap" id="SE4_options_panel">
55
+ <h2>Search Everything (SE) Version: <?php echo $this->version; ?></h2>
56
+ <p><?php _e('The options selected below will be used in every search query on this site; in addition to the built-in post search.','SearchEverything'); ?></p>
57
+ </div>
58
+
59
+ <div class="wrap SE4">
60
+ <h2><?php _e('SE Search Options', 'SearchEverything'); ?></h2>
61
+ <p><?php _e('Use this form to configure your search options.', 'SearchEverything'); ?></p>
62
+ <form method="post">
63
+ <fieldset class="options">
64
+ <legend><?php _e('Search Options Form', 'SearchEverything'); ?></legend>
65
+ <p><input type="checkbox" id="exclude_posts" name="exclude_posts" value="true" <?php if($options['SE4_exclude_posts'] == 'true') { echo 'checked="true"'; } ?> />
66
+ <label for="exclude_posts"><?php _e('Exclude some post or page IDs','SearchEverything'); ?></label><br />
67
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="exclude_posts_list" class="SE_text_label"><?php _e('Comma separated Post IDs (example: 1, 5, 9)','SearchEverything'); ?></label><br />
68
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="50" class="SE_text_input" id="exclude_posts_list" name="exclude_posts_list" value="<?php echo $options['SE4_exclude_posts_list'];?>" /></p>
69
+
70
+ <p><input type="checkbox" id="exclude_categories" name="exclude_categories"
71
+ value="true" <?php if($options['SE4_exclude_categories'] == 'true') { echo 'checked="true"'; } ?> />
72
+ <label for="exclude_categories"><?php _e('Exclude Categories <strong><small>(Wordpress 2.2 Only)</strong></small>','SearchEverything'); ?></label><br />
73
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="exclude_categories_list" class="SE_text_label"><?php _e('Comma separated category IDs (example: 1, 4)','SearchEverything'); ?></label><br />
74
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="50" class="SE_text_input" id="exclude_categories_list" name="exclude_categories_list" value="<?php echo $options['SE4_exclude_categories_list'];?>" /></p>
75
+
76
+ <p><input type="checkbox" id="search_pages" name="search_pages"
77
+ value="true" <?php if($options['SE4_use_page_search'] == 'true') { echo 'checked="true"'; } ?> />
78
+ <label for="search_pages"><?php _e('Search every page (non-password protected)','SearchEverything'); ?></label></p>
79
+ <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" class="SE_text_input" id="appvd_pages" name="appvd_pages" value="true" <?php if($options['SE4_approved_pages_only'] == 'true') { echo 'checked="true"'; } ?>
80
+ <label for="appvd_pages"><?php _e('Search approved pages only?','SearchEverything'); ?></label></p>
81
+
82
+ <p><input type="checkbox" id="search_comments" name="search_comments"
83
+ value="true" <?php if($options['SE4_use_comment_search'] == 'true') { echo 'checked="true"'; } ?> />
84
+ <label for="search_comments"><?php _e('Search every comment','SearchEverything'); ?></label></p>
85
+
86
+ <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" class="SE_text_input" id="appvd_comments" name="appvd_comments" value="true" <?php if($options['SE4_approved_comments_only'] == 'true') { echo 'checked="true"'; } ?>
87
+ <label for="appvd_comments"><?php _e('Search approved comments only?','SearchEverything'); ?></label></p>
88
+
89
+ <p><input type="checkbox" id="search_excerpt" name="search_excerpt" value="true" <?php if($options['SE4_use_excerpt_search'] == 'true') { echo 'checked="true"'; } ?> />
90
+ <label for="search_excerpt"><?php _e('Search every excerpt','SearchEverything'); ?></label></p>
91
+
92
+ <p><input type="checkbox" id="search_drafts" name="search_drafts" value="true" <?php if($options['SE4_use_draft_search'] == 'true') { echo 'checked="true"'; } ?>
93
+ <label for="search_drafts"><?php _e('Search every draft','SearchEverything'); ?></label></p>
94
+
95
+ <p><input type="checkbox" id="search_attachments" name="search_attachments" value="true" <?php if($options['SE4_use_attachment_search'] == 'true') { echo 'checked="true"'; } ?> />
96
+ <label for="search_attachments"><?php _e('Search every attachment','SearchEverything'); ?></label></p>
97
+
98
+ <p><input type="checkbox" id="search_metadata" name="search_metadata" value="true" <?php if($options['SE4_use_metadata_search'] == 'true') { echo 'checked="true"'; } ?> />
99
+ <label for="search_metadata"><?php _e('Search every custom field (metadata)','SearchEverything'); ?></label></p>
100
+
101
+ </fieldset>
102
+ <fieldset class="options">
103
+ <div class="submit">
104
+ <input type="hidden" name="action" value="save" />
105
+ <input type="submit" value="<?php _e('Update Options', 'SearchEverything') ?>" />
106
+ </div>
107
+ </fieldset>
108
+ </form>
109
+ </div>
110
+ <div class="wrap SE4">
111
+ <h2><?php _e('SE Search Form', 'SearchEverything'); ?></h2>
112
+ <p><?php _e('Use this search form to run a live search test.', 'SearchEverything'); ?></p>
113
+
114
+ <fieldset>
115
+ <legend><?php _e('Site Search', 'SearchEverything'); ?></legend>
116
+ <form method="get" id="searchform" action="<?php bloginfo('home'); ?>"><p class="srch submit">
117
+ <label for="s"><?php _e('Enter search terms', 'SearchEverything'); ?><br /></label>
118
+ <input type="text" class="srch-txt" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
119
+ <input type="submit" class="SE4_btn" id="searchsubmit" value="<?php _e('Run Test Search', 'SearchEverything'); ?>" /></p>
120
+ </form>
121
+ </fieldset>
122
+ </div>
123
+ <div class="wrap">
124
+ <h2>SE Project Information</h2>
125
+ <p>As of 2.3 I'm taking a hiatus from SE development; however I'm still accepting and committing feature updates and fixes from the community. <br/> You should not fret, the development since Version One has primarily come from the WordPress community and as a Search Everything user myself, I&#8217;m grateful for their dedicated and continued support:</p>
126
+ <ul class="SE_lists">
127
+ <li>Alakhnor</li>
128
+ <li><a href="http://kinrowan.net/">Cori Schlegel</a></li>
129
+ <li><a href="http://green-beast.com/">Mike Cherim</a></li>
130
+ <li><a href="http://blog.saddey.net/">Saddy</a></li>
131
+ <li><a href="http://www.reaper-x.com/">Reaper</a></li>
132
+ <li><a href="http://http://beyn.org/">Barış Ünver</a> (localization support)</li>
133
+ <li>Uli Iserloh</li>
134
+ </ul>
135
+ <p>If you&#8217;d like to contribute there&#8217;s a lot to do:</p>
136
+ <ul class="SE_lists">
137
+ <li><strong>Category Exclusion for new 2.3 Taxonomy Schema</strong></li>
138
+ <li>More meta data functions.</li>
139
+ <li>Searching tags (WP 2.3).</li>
140
+ <li>Search Bookmarks.</li>
141
+ <li>&#8230;anything else you want to add.</li>
142
+ </ul>
143
+ <br/><p>The current project home is at <a href="http://scatter3d.com/">scatter3d.com</a>. If you want to contribute <a href="mailto:dancameron@gmail.com">e-mail me</a> your modifications.</p>
144
+ <p class="sig">Respectfully,<br />
145
+ <a href="http://dancameron.org/">Dan Cameron</a></p>
146
+ </div>
147
+
148
+ <?php
149
+ } //end SE4_option_page
150
+
151
+ //styling options page
152
+ function SE4_options_style() {
153
+ ?>
154
+ <style type="text/css" media="screen">
155
+ div.SE4 p.submit, div.SE4 form p.submit, div.SE4 p.submit input { text-align:left; }
156
+ #SE4_options_panel p.submit { text-align:left; }
157
+ form#searchform label, form#searchform input, form#SE_form label, form#SE_form input { margin-left:10px; }
158
+ input.SE4_btn { cursor:pointer; margin-left:5px; }
159
+ p.srch { margin:0; margin-bottom:20px; }
160
+ p.submit input.srch-txt { background-color:#f4f4f4; background-image:none; border:1px solid #999; padding:6px; }
161
+ p.submit input.srch-txt:focus, p.submit input.srch-txt:active { background-color:#fff; background-image:none; border:1px solid #111; padding:6px; }
162
+ p.sig { margin-left:25px; }
163
+ span.SE_notice { color:#cd0000; font-weight:bold; padding-left:10px; }
164
+ label.SE_text_label { cursor:text; }
165
+ form#SE_form label.SE_text_label, form#SE_form input.SE_text_input { margin-left:38px; }
166
+ ul.SE_lists li { list-style-type:square; }
167
+ </style>
168
+ <?php
169
+ }
170
+
171
+ }
172
+ ?>
lang/SE4-fr_FR.mo ADDED
Binary file
lang/SE4-fr_FR.po ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Search Everything\n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: 2007-10-04 21:49+0100\n"
6
+ "Last-Translator: alakhnor <alakhnor@wanadoo.fr>\n"
7
+ "Language-Team: Alakhnor\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Poedit-Language: French\n"
12
+ "X-Poedit-Country: FRANCE\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: c:\\wamp\\www\\le-hibootest\\wp-content\\plugins\\\n"
15
+ "X-Poedit-SearchPath-0: search-everything\n"
16
+
17
+ #: search-everything/SE-Admin.php:30
18
+ msgid "Search Everything Options <strong>Updated</strong>."
19
+ msgstr "Options de Search Everything <strong>mises à jour</strong>."
20
+
21
+ #: search-everything/SE-Admin.php:59
22
+ msgid "The options selected below will be used in every search query on this site; in addition to the built-in post search."
23
+ msgstr "Les options sélectionnées ci-dessous seront utilisées dans les recherches effectuées sur ce site en s'ajoutant à la fonction de recherche existante."
24
+
25
+ #: search-everything/SE-Admin.php:63
26
+ msgid "SE Search Options"
27
+ msgstr "Options de recherche de SE"
28
+
29
+ #: search-everything/SE-Admin.php:64
30
+ msgid "Use this form to configure your search options."
31
+ msgstr "Utilisez ce formulaire pour configurer vos options de recherche."
32
+
33
+ #: search-everything/SE-Admin.php:67
34
+ msgid "Search Options Form"
35
+ msgstr "Formulaire d'option de recherche"
36
+
37
+ #: search-everything/SE-Admin.php:69
38
+ msgid "Exclude some post or page IDs"
39
+ msgstr "Exclure des ID d'articles ou de pages"
40
+
41
+ #: search-everything/SE-Admin.php:70
42
+ msgid "Comma separated Post IDs (example: 1, 5, 9)"
43
+ msgstr "Liste d'IDs d'articles séparées par des virgules (ex : 1,5,9)"
44
+
45
+ #: search-everything/SE-Admin.php:75
46
+ msgid "Exclude some category IDs (Wordpress 2.2 Only)"
47
+ msgstr "Exclure des ID de catégories (WordPress 2.2 seulement)"
48
+
49
+ #: search-everything/SE-Admin.php:76
50
+ msgid "Comma separated category IDs (example: 1, 4)"
51
+ msgstr "Liste d'IDs de catégories séparées par des virgules (ex : 1,4)"
52
+
53
+ #: search-everything/SE-Admin.php:81
54
+ msgid "Search every page (non-password protected)"
55
+ msgstr "Chercher dans toutes les pages (non-protégées par mot de passe)"
56
+
57
+ #: search-everything/SE-Admin.php:83
58
+ msgid "Search approved pages only?"
59
+ msgstr "Chercher dans les pages validées seulement"
60
+
61
+ #: search-everything/SE-Admin.php:87
62
+ msgid "Search every comment"
63
+ msgstr "Chercher dans tous les commentaires"
64
+
65
+ #: search-everything/SE-Admin.php:90
66
+ msgid "Search approved comments only?"
67
+ msgstr "Chercher dans les commentaires validés seulement"
68
+
69
+ #: search-everything/SE-Admin.php:93
70
+ msgid "Search every excerpt"
71
+ msgstr "Chercher dans tous les excerpt"
72
+
73
+ #: search-everything/SE-Admin.php:96
74
+ msgid "Search every draft"
75
+ msgstr "Chercher dans tous les brouillons"
76
+
77
+ #: search-everything/SE-Admin.php:99
78
+ msgid "Search every attachment"
79
+ msgstr "Chercher dans tous les documents joints"
80
+
81
+ #: search-everything/SE-Admin.php:102
82
+ msgid "Search every custom field (metadata)"
83
+ msgstr "Chercher dans tous les champs personnalisés (Meta-data)"
84
+
85
+ #: search-everything/SE-Admin.php:108
86
+ msgid "Update Options"
87
+ msgstr "Mise à jour"
88
+
89
+ #: search-everything/SE-Admin.php:114
90
+ msgid "SE Search Form"
91
+ msgstr "Formulaire de recherche de SE"
92
+
93
+ #: search-everything/SE-Admin.php:115
94
+ msgid "Use this search form to run a live search test."
95
+ msgstr "Utilisez ce champ pour effectuer une recherche réelle."
96
+
97
+ #: search-everything/SE-Admin.php:118
98
+ msgid "Site Search"
99
+ msgstr "Recherche sur le site"
100
+
101
+ #: search-everything/SE-Admin.php:120
102
+ msgid "Enter search terms"
103
+ msgstr "Entrez les termes de recherche"
104
+
105
+ #: search-everything/SE-Admin.php:122
106
+ msgid "Run Test Search"
107
+ msgstr "Lancer la recherche"
108
+
SE4-tr_TR.mo → lang/SE4-tr_TR.mo RENAMED
File without changes
SE4-tr_TR.po → lang/SE4-tr_TR.po RENAMED
File without changes
SE4.pot → lang/SE4.pot RENAMED
File without changes
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.com/gp/registry/wishlist/3EM84J7FVHE6S/ref=wl_web
4
  Tags: search, comment search, page search, admin, seo
5
  Requires at least: 2.1
6
  Tested up to: 2.3
7
- Stable tag: 4.0.3
8
 
9
  Increases Wordpress' default search functionality through an options panel. Options include searching pages, excerpts, attachments, drafts, comments and custom fields (metadata).
10
 
@@ -29,6 +29,7 @@ Search Everything increases the ability of the default Wordpress Search, options
29
 
30
  == Update Log ==
31
 
 
32
  * 4.0.3 - Localization pot and Turkish translation (props Baris Unver)
33
  * 4.0.2 - CSS Bug fix - minor
34
  * 4.0.1 - Bug fix~Extraneous 's' in options panel
4
  Tags: search, comment search, page search, admin, seo
5
  Requires at least: 2.1
6
  Tested up to: 2.3
7
+ Stable tag: 4.1
8
 
9
  Increases Wordpress' default search functionality through an options panel. Options include searching pages, excerpts, attachments, drafts, comments and custom fields (metadata).
10
 
29
 
30
  == Update Log ==
31
 
32
+ * 4.1 - Major Plugin Architecture change, better localization support
33
  * 4.0.3 - Localization pot and Turkish translation (props Baris Unver)
34
  * 4.0.2 - CSS Bug fix - minor
35
  * 4.0.1 - Bug fix~Extraneous 's' in options panel
search_everything.php CHANGED
@@ -1,428 +1,260 @@
1
- <?php
2
- /*
3
- Plugin Name: Search Everything
4
- Plugin URI: http://dancameron.org/wordpress/
5
- Description: Adds search functionality with little setup. Including options to 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: 4.0.3
7
- Author: Dan Cameron
8
- Author URI: http://dancameron.org/
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
- //add filters based upon option settings
18
-
19
- //logging
20
- $logging = 0;
21
-
22
- // Load language file
23
- $locale = get_locale();
24
- if ( !empty($locale) )
25
- load_textdomain('SearchEverything', ABSPATH . 'wp-content/plugins/' . dirname(plugin_basename(__FILE__)) .'/' . 'SE4-'.$locale.'.mo');
26
-
27
- function SE4_log($msg) {
28
- global $logging;
29
- if ($logging) {
30
- $fp = fopen("logfile.log","a+");
31
- $date = date("Y-m-d H:i:s ");
32
- $source = "search_everything_2 plugin: ";
33
- fwrite($fp, "\n\n".$date."\n".$source."\n".$msg);
34
- fclose($fp);
35
- }
36
- return true;
37
- }
38
-
39
- //add filters based upon option settings
40
- if ("true" == get_option('SE4_use_page_search')) {
41
- add_filter('posts_where', 'SE4_search_pages');
42
- SE4_log("searching pages");
43
- }
44
-
45
- if ("true" == get_option('SE4_use_excerpt_search')) {
46
- add_filter('posts_where', 'SE4_search_excerpt');
47
- SE4_log("searching excerpts");
48
- }
49
-
50
- if ("true" == get_option('SE4_use_comment_search')) {
51
- add_filter('posts_where', 'SE4_search_comments');
52
- add_filter('posts_join', 'SE4_comments_join');
53
- SE4_log("searching comments");
54
- }
55
-
56
- if ("true" == get_option('SE4_use_draft_search')) {
57
- add_filter('posts_where', 'SE4_search_draft_posts');
58
- SE4_log("searching drafts");
59
- }
60
-
61
- if ("true" == get_option('SE4_use_attachment_search')) {
62
- add_filter('posts_where', 'SE4_search_attachments');
63
- SE4_log("searching attachments");
64
- }
65
-
66
- if ("true" == get_option('SE4_use_metadata_search')) {
67
- add_filter('posts_where', 'SE4_search_metadata');
68
- add_filter('posts_join', 'SE4_search_metadata_join');
69
- SE4_log("searching metadata");
70
- }
71
-
72
- if ("true" == get_option('SE4_exclude_posts')) {
73
- add_filter('posts_where', 'SE4_exclude_posts');
74
- SE4_log("searching excluding posts");
75
- }
76
-
77
-
78
- // - Depracated in 2.3
79
- if ("true" == get_option('SE4_exclude_categories')) {
80
- add_filter('posts_where', 'SE4_exclude_categories');
81
- add_filter('posts_join', 'SE4_exclude_categories_join');
82
- SE4_log("searching excluding categories");
83
- }
84
-
85
- // - Depracated
86
- if ("true" == get_option('SE4_use_tag_search')) {
87
- add_filter('posts_where', 'SE4_search_tag');
88
- add_filter('posts_join', 'SE4_search_tag_join');
89
- SE4_log("searching tag");
90
- }
91
-
92
- //Duplicate fix provided by Tiago.Pocinho
93
- add_filter('posts_request', 'SE4_distinct');
94
- function SE4_distinct($query){
95
- global $wp_query;
96
- if (!empty($wp_query->query_vars['s'])) {
97
- if (strstr($where, 'DISTINCT')) {}
98
- else {
99
- $query = str_replace('SELECT', 'SELECT DISTINCT', $query);
100
- }
101
- }
102
- return $query;
103
- }
104
-
105
-
106
- function SE4_exclude_posts($where) {
107
- global $wp_query;
108
- if (!empty($wp_query->query_vars['s'])) {
109
- $excl_list = implode(',', explode(',', trim(get_option('SE4_exclude_posts_list'))));
110
- $where = str_replace('"', '\'', $where);
111
- $where = 'AND ('.substr($where, strpos($where, 'AND')+3).' )';
112
- $where .= ' AND (ID NOT IN ( '.$excl_list.' ))';
113
- }
114
-
115
- SE4_log("ex posts where: ".$where);
116
- return $where;
117
- }
118
-
119
-
120
-
121
-
122
- //exlude some categories from search - Depracated in 2.3
123
- function SE4_exclude_categories($where) {
124
- global $wp_query;
125
- if (!empty($wp_query->query_vars['s'])) {
126
- $excl_list = implode(',', explode(',', trim(get_option('SE4_exclude_categories_list'))));
127
- $where = str_replace('"', '\'', $where);
128
- $where = 'AND ('.substr($where, strpos($where, 'AND')+3).' )';
129
- $where .= ' AND (c.category_id NOT IN ( '.$excl_list.' ))';
130
- }
131
-
132
- SE4_log("ex cats where: ".$where);
133
- return $where;
134
- }
135
-
136
- //join for excluding categories - Depracated in 2.3
137
- function SE4_exclude_categories_join($join) {
138
- global $wp_query, $wpdb;
139
-
140
- if (!empty($wp_query->query_vars['s'])) {
141
-
142
- $join .= "LEFT JOIN $wpdb->post2cat AS c ON $wpdb->posts.ID = c.post_id";
143
- }
144
- SE4_log("category join: ".$join);
145
- return $join;
146
- }
147
-
148
-
149
- //search pages (except password protected pages provided by loops)
150
- function SE4_search_pages($where) {
151
- global $wp_query;
152
- if (!empty($wp_query->query_vars['s'])) {
153
-
154
- $where = str_replace('"', '\'', $where);
155
- if ('true' == get_option('SE4_approved_pages_only')) {
156
- $where = str_replace('post_type = \'post\' AND ', 'post_password = \'\' AND ', $where);
157
- }
158
- else { // < v 2.1
159
- $where = str_replace('post_type = \'post\' AND ', '', $where);
160
- }
161
- }
162
-
163
- SE4_log("pages where: ".$where);
164
- return $where;
165
- }
166
-
167
-
168
- //search excerpts provided by Dennis Turner
169
- function SE4_search_excerpt($where) {
170
- global $wp_query;
171
- if (!empty($wp_query->query_vars['s'])) {
172
- $where = str_replace('"', '\'', $where);
173
- $where = str_replace(' OR (post_content LIKE \'%' .
174
- $wp_query->query_vars['s'] . '%\'', ' OR (post_content LIKE \'%' .
175
- $wp_query->query_vars['s'] . '%\') OR (post_excerpt LIKE \'%' .
176
- $wp_query->query_vars['s'] . '%\'', $where);
177
- }
178
-
179
- SE4_log("excerpts where: ".$where);
180
- return $where;
181
- }
182
-
183
-
184
- //search drafts
185
- function SE4_search_draft_posts($where) {
186
- global $wp_query;
187
- if (!empty($wp_query->query_vars['s'])) {
188
- $where = str_replace('"', '\'', $where);
189
- $where = str_replace(' AND (post_status = \'publish\'', ' AND (post_status = \'publish\' or post_status = \'draft\'', $where);
190
- }
191
-
192
- SE4_log("drafts where: ".$where);
193
- return $where;
194
- }
195
-
196
- //search attachments
197
- function SE4_search_attachments($where) {
198
- global $wp_query;
199
- if (!empty($wp_query->query_vars['s'])) {
200
- $where = str_replace('"', '\'', $where);
201
- $where = str_replace(' AND (post_status = \'publish\'', ' AND (post_status = \'publish\' or post_status = \'attachment\'', $where);
202
- $where = str_replace('AND post_status != \'attachment\'','',$where);
203
- }
204
-
205
- SE4_log("attachments where: ".$where);
206
- return $where;
207
- }
208
-
209
- //search comments
210
- function SE4_search_comments($where) {
211
- global $wp_query, $wpdb;
212
- if (!empty($wp_query->query_vars['s'])) {
213
- $where .= " OR (comment_content LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') ";
214
- }
215
-
216
- SE4_log("comments where: ".$where);
217
-
218
- return $where;
219
- }
220
-
221
- //join for searching comments
222
- function SE4_comments_join($join) {
223
- global $wp_query, $wpdb;
224
-
225
- if (!empty($wp_query->query_vars['s'])) {
226
-
227
- if ('true' == get_option('SE4_approved_comments_only')) {
228
- $comment_approved = " AND comment_approved = '1'";
229
- } else {
230
- $comment_approved = '';
231
- }
232
-
233
- $join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
234
- }
235
- SE4_log("comments join: ".$join);
236
- return $join;
237
- }
238
-
239
- //search metadata
240
- function SE4_search_metadata($where) {
241
- global $wp_query, $wpdb;
242
- if (!empty($wp_query->query_vars['s'])) {
243
- $where .= " OR meta_value LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%' ";
244
- }
245
-
246
- SE4_log("metadata where: ".$where);
247
-
248
- return $where;
249
- }
250
-
251
- //join for searching metadata
252
- function SE4_search_metadata_join($join) {
253
- global $wp_query, $wpdb;
254
-
255
- if (!empty($wp_query->query_vars['s'])) {
256
-
257
- $join .= "LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
258
- }
259
- SE4_log("metadata join: ".$join);
260
- return $join;
261
- }
262
-
263
-
264
-
265
- //build admin interface
266
- function SE4_option_page() {
267
- global $wpdb, $table_prefix;
268
- if($_POST['action'] == "save") {
269
- echo "<div class=\"updated fade\" id=\"limitcatsupdatenotice\"><p>" . __("Search Everything Options <strong>Updated</strong>.") . "</p></div>";
270
-
271
- update_option("SE4_exclude_categories", $_POST["exclude_categories"]);
272
- update_option("SE4_exclude_categories_list", $_POST["exclude_categories_list"]);
273
- update_option("SE4_exclude_posts", $_POST["exclude_posts"]);
274
- update_option("SE4_exclude_posts_list", $_POST["exclude_posts_list"]);
275
- update_option("SE4_use_page_search", $_POST["search_pages"]);
276
- update_option("SE4_use_comment_search", $_POST["search_comments"]);
277
- update_option("SE4_approved_comments_only", $_POST["appvd_comments"]);
278
- update_option("SE4_approved_pages_only", $_POST["appvd_pages"]);
279
- update_option("SE4_use_excerpt_search", $_POST["search_excerpt"]);
280
- update_option("SE4_use_draft_search", $_POST["search_drafts"]);
281
- update_option("SE4_use_attachment_search", $_POST["search_attachments"]);
282
- update_option("SE4_use_metadata_search", $_POST["search_metadata"]);
283
- update_option("search_tag", $_POST["SE4_use_tag_search"]);
284
-
285
- $SE4_exclude_categories = get_option("SE4_exclude_categories");
286
- $SE4_exclude_categories_list = get_option("SE4_exclude_categories_list");
287
- $SE4_exclude_posts = get_option("SE4_exclude_posts");
288
- $SE4_exclude_posts_list = get_option("SE4_exclude_posts_list");
289
- $SE4_use_page_search = get_option("SE4_use_page_search");
290
- $SE4_use_comment_search = get_option("SE4_use_comment_search");
291
- $SE4_approved_comments_only = get_option("SE4_approved_comments_only");
292
- $SE4_approved_pages_only = get_option("SE4_approved_pages_only");
293
- $SE4_use_excerpt_search = get_option("SE4_use_excerpt_search");
294
- $SE4_use_draft_search = get_option("SE4_use_draft_search");
295
- $SE4_use_attachment_search = get_option("SE4_use_attachment_search");
296
- $SE4_use_metadata_search = get_option("SE4_use_metadata_search");
297
- $search_tag = get_option("search_tag");
298
-
299
- }
300
- ?>
301
-
302
- <div class="wrap" id="SE4_options_panel">
303
- <h2>Search Everything (SE) Version: 4</h2>
304
- <p><?php _e('The options selected below will be used in every search query on this site; in addition to the built-in post search.','SearchEverything'); ?></p>
305
-
306
- </div>
307
-
308
- <div class="wrap SE4">
309
- <h2>SE Search Options</h2>
310
- <p>Use this form to configure your search options.</p>
311
- <form method="post">
312
- <fieldset class="options">
313
- <legend>Search Options Form</legend>
314
- <p><input type="checkbox" id="exclude_posts" name="exclude_posts" value="true" <?php if(get_option('SE4_exclude_posts') == 'true') { echo 'checked="true"'; } ?> />
315
- <label for="exclude_posts"><?php _e('Exclude some post or page IDs','SearchEverything'); ?></label><br />
316
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="exclude_posts_list" class="SE_text_label"><?php _e('Comma separated Post IDs (example: 1, 5, 9)','SearchEverything'); ?></label><br />
317
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="50" class="SE_text_input" id="exclude_posts_list" name="exclude_posts_list" value="<?php echo get_option('SE4_exclude_posts_list');?>" /></p>
318
-
319
- <p><input type="checkbox" id="exclude_categories" name="exclude_categories"
320
- value="true" <?php if(get_option('SE4_exclude_categories') == 'true') { echo 'checked="true"'; } ?> />
321
- <label for="exclude_categories"><?php _e('Exclude some category IDs (Wordpress 2.2 Only)','SearchEverything'); ?></label><br />
322
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="exclude_categories_list" class="SE_text_label"><?php _e('Comma separated category IDs (example: 1, 4)','SearchEverything'); ?></label><br />
323
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="50" class="SE_text_input" id="exclude_categories_list" name="exclude_categories_list" value="<?php echo get_option('SE4_exclude_categories_list');?>" /></p>
324
-
325
- <p><input type="checkbox" id="search_pages" name="search_pages"
326
- value="true" <?php if(get_option('SE4_use_page_search') == 'true') { echo 'checked="true"'; } ?> />
327
- <label for="search_pages"><?php _e('Search every page (non-password protected)','SearchEverything'); ?></label></p>
328
- <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" class="SE_text_input" id="appvd_pages" name="appvd_pages" value="true" <?php if(get_option('SE4_approved_pages_only') == 'true') { echo 'checked="true"'; } ?>
329
- <label for="appvd_pages"><?php _e('Search approved pages only?','SearchEverything'); ?></label></p>
330
-
331
- <p><input type="checkbox" id="search_comments" name="search_comments"
332
- value="true" <?php if(get_option('SE4_use_comment_search') == 'true') { echo 'checked="true"'; } ?> />
333
- <label for="search_comments"><?php _e('Search every comment','SearchEverything'); ?></label></p>
334
-
335
- <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" class="SE_text_input" id="appvd_comments" name="appvd_comments" value="true" <?php if(get_option('SE4_approved_comments_only') == 'true') { echo 'checked="true"'; } ?>
336
- <label for="appvd_comments"><?php _e('Search approved comments only?','SearchEverything'); ?></label></p>
337
-
338
- <p><input type="checkbox" id="search_excerpt" name="search_excerpt" value="true" <?php if(get_option('SE4_use_excerpt_search') == 'true') { echo 'checked="true"'; } ?> />
339
- <label for="search_excerpt"><?php _e('Search every excerpt','SearchEverything'); ?></label></p>
340
-
341
- <p><input type="checkbox" id="search_drafts" name="search_drafts" value="true" <?php if(get_option('SE4_use_draft_search') == 'true') { echo 'checked="true"'; } ?>
342
- <label for="search_drafts"><?php _e('Search every draft','SearchEverything'); ?></label></p>
343
-
344
- <p><input type="checkbox" id="search_attachments" name="search_attachments" value="true" <?php if(get_option('SE4_use_attachment_search') == 'true') { echo 'checked="true"'; } ?> />
345
- <label for="search_attachments"><?php _e('Search every attachment','SearchEverything'); ?></label></p>
346
-
347
- <p><input type="checkbox" id="search_metadata" name="search_metadata" value="true" <?php if(get_option('SE4_use_metadata_search') == 'true') { echo 'checked="true"'; } ?> />
348
- <label for="search_metadata"><?php _e('Search every custom field (metadata)','SearchEverything'); ?></label></p>
349
-
350
- </fieldset>
351
- <fieldset class="options">
352
- <div class="submit">
353
- <input type="hidden" name="action" value="save" />
354
- <input type="submit" value="<?php _e('Update Options »') ?>" />
355
- </div>
356
- </fieldset>
357
- </form>
358
- </div>
359
- <div class="wrap SE4">
360
- <h2>SE Search Form</h2>
361
- <p>Use this search form to run a live search test.</p>
362
-
363
- <fieldset>
364
- <legend>Site Search</legend>
365
- <form method="get" id="searchform" action="<?php bloginfo('home'); ?>"><p class="srch submit">
366
- <label for="s">Enter search terms<br /></label>
367
- <input type="text" class="srch-txt" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
368
- <input type="submit" class="SE4_btn" id="searchsubmit" value="Run Test Search" /></p>
369
- </form>
370
- </fieldset>
371
- </div>
372
- <div class="wrap">
373
- <h2>SE Project Information</h2>
374
- <p>The development since Version One has primarily come from the WordPress community and as a Search Everything user myself, I&#8217;m grateful for their dedicated and continued support:</p>
375
- <ul class="SE_lists">
376
- <li><a href="http://kinrowan.net/">Cori Schlegel</a></li>
377
- <li><a href="http://green-beast.com/">Mike Cherim</a></li>
378
- <li><a href="http://blog.saddey.net/">Saddy</a></li>
379
- <li><a href="http://www.reaper-x.com/">Reaper</a></li>
380
- <li><a href="http://http://beyn.org/">Barış Ünver</a> (localization support)</li>
381
-
382
- <li>Alakhnor</li>
383
- <li>Uli Iserloh</li>
384
- </ul>
385
- <p>If you&#8217;d like to contribute there&#8217;s a lot to do:</p>
386
- <ul class="SE_lists">
387
- <li><strong>Category Exclusion for new 2.3 Taxonomy Schema</strong></li>
388
- <li>More meta data functions.</li>
389
- <li>Searching tags (WP 2.3).</li>
390
- <li>Search Bookmarks.</li>
391
- <li>&#8230;anything else you want to add.</li>
392
- </ul>
393
- <br/><p>The current project home is at <a href="http://scatter3d.com/">scatter3d.com</a>. If you want to contribute <a href="mailto:dancameron@gmail.com">e-mail me</a> your modifications.<br/> Donations are accepted.</p>
394
- <p class="sig">Respectfully,<br />
395
- <a href="http://dancameron.org/">Dan Cameron</a></p>
396
- </div>
397
-
398
- <?php
399
- } //end SE4_option_page
400
-
401
- function SE4_add_options_panel() {
402
- add_options_page('Search', 'Search Everything', 7, 'manage_search', 'SE4_option_page', 'SE4_option_page');
403
- }
404
- add_action('admin_menu', 'SE4_add_options_panel');
405
-
406
- //styling options page
407
- function SE4_options_style() {
408
- ?>
409
- <style type="text/css" media="screen">
410
- div.SE4 p.submit, div.SE4 form p.submit, div.SE4 p.submit input { text-align:left; }
411
- #SE4_options_panel p.submit { text-align:left; }
412
- form#searchform label, form#searchform input, form#SE_form label, form#SE_form input { margin-left:10px; }
413
- input.SE4_btn { cursor:pointer; margin-left:5px; }
414
- p.srch { margin:0; margin-bottom:20px; }
415
- p.submit input.srch-txt { background-color:#f4f4f4; background-image:none; border:1px solid #999; padding:6px; }
416
- p.submit input.srch-txt:focus, p.submit input.srch-txt:active { background-color:#fff; background-image:none; border:1px solid #111; padding:6px; }
417
- p.sig { margin-left:25px; }
418
- span.SE_notice { color:#cd0000; font-weight:bold; padding-left:10px; }
419
- label.SE_text_label { cursor:text; }
420
- form#SE_form label.SE_text_label, form#SE_form input.SE_text_input { margin-left:38px; }
421
- ul.SE_lists li { list-style-type:square; }
422
- </style>
423
- <?php
424
- }
425
-
426
- add_action('admin_head', 'SE4_options_style');
427
-
428
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Search Everything
4
+ Plugin URI: http://dancameron.org/wordpress/
5
+ Description: Adds search functionality with little setup. Including options to 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: 4.1
7
+ Author: Dan Cameron
8
+ Author URI: http://dancameron.org/
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
+ define('SE_ABSPATH', ABSPATH . 'wp-content/plugins/' . dirname(plugin_basename(__FILE__)).'/');
17
+
18
+ $SE = new SearchEverything();
19
+ //add filters based upon option settings
20
+
21
+ Class SearchEverything {
22
+
23
+ var $login = false;
24
+ var $options;
25
+
26
+ function SearchEverything(){
27
+
28
+ $this->options = get_option('SE4_options');
29
+
30
+ if (is_admin()) {
31
+ include ( SE_ABSPATH . '/SE-Admin.php' );
32
+ $SEAdmin = new SearchEverythingAdmin();
33
+ }
34
+
35
+ //add filters based upon option settings
36
+ if ("true" == $this->options['SE4_use_page_search']) {
37
+ add_filter('posts_where', array(&$this, 'SE4_search_pages'));
38
+ $this->SE4_log("searching pages");
39
+ }
40
+
41
+ if ("true" == $this->options['SE4_use_excerpt_search']) {
42
+ add_filter('posts_where', array(&$this, 'SE4_search_excerpt'));
43
+ $this->SE4_log("searching excerpts");
44
+ }
45
+
46
+ if ("true" == $this->options['SE4_use_comment_search']) {
47
+ add_filter('posts_where', array(&$this, 'SE4_search_comments'));
48
+ add_filter('posts_join', array(&$this, 'SE4_comments_join'));
49
+ $this->SE4_log("searching comments");
50
+ }
51
+
52
+ if ("true" == $this->options['SE4_use_draft_search']) {
53
+ add_filter('posts_where', array(&$this, 'SE4_search_draft_posts'));
54
+ $this->SE4_log("searching drafts");
55
+ }
56
+
57
+ if ("true" == $this->options['SE4_use_attachment_search']) {
58
+ add_filter('posts_where', array(&$this, 'SE4_search_attachments'));
59
+ $this->SE4_log("searching attachments");
60
+ }
61
+
62
+ if ("true" == $this->options['SE4_use_metadata_search']) {
63
+ add_filter('posts_where', array(&$this, 'SE4_search_metadata'));
64
+ add_filter('posts_join', array(&$this, 'SE4_search_metadata_join'));
65
+ $this->SE4_log("searching metadata");
66
+ }
67
+
68
+ if ("true" == $this->options['SE4_exclude_posts']) {
69
+ add_filter('posts_where', array(&$this, 'SE4_exclude_posts'));
70
+ $this->SE4_log("searching excluding posts");
71
+ }
72
+
73
+ // - Depracated in 2.3
74
+ if ("true" == $this->options['SE4_exclude_categories']) {
75
+ add_filter('posts_where', array(&$this, 'SE4_exclude_categories'));
76
+ add_filter('posts_join', array(&$this, 'SE4_exclude_categories_join'));
77
+ $this->SE4_log("searching excluding categories");
78
+ }
79
+
80
+ //Duplicate fix provided by Tiago.Pocinho
81
+ add_filter('posts_request', array(&$this, 'SE4_distinct'));
82
+ }
83
+
84
+ function SE4_log($msg) {
85
+
86
+ if ($this->logging) {
87
+ $fp = fopen("logfile.log","a+");
88
+ $date = date("Y-m-d H:i:s ");
89
+ $source = "search_everything_2 plugin: ";
90
+ fwrite($fp, "\n\n".$date."\n".$source."\n".$msg);
91
+ fclose($fp);
92
+ }
93
+ return true;
94
+ }
95
+
96
+ //Duplicate fix provided by Tiago.Pocinho
97
+ function SE4_distinct($query){
98
+ global $wp_query;
99
+ if (!empty($wp_query->query_vars['s'])) {
100
+ if (strstr($where, 'DISTINCT')) {}
101
+ else {
102
+ $query = str_replace('SELECT', 'SELECT DISTINCT', $query);
103
+ }
104
+ }
105
+ return $query;
106
+ }
107
+
108
+ function SE4_exclude_posts($where) {
109
+ global $wp_query;
110
+ if (!empty($wp_query->query_vars['s'])) {
111
+ $excl_list = implode(',', explode(',', trim($this->options['SE4_exclude_posts_list'])));
112
+ $where = str_replace('"', '\'', $where);
113
+ $where = 'AND ('.substr($where, strpos($where, 'AND')+3).' )';
114
+ $where .= ' AND (ID NOT IN ( '.$excl_list.' ))';
115
+ }
116
+
117
+ $this->SE4_log("ex posts where: ".$where);
118
+ return $where;
119
+ }
120
+
121
+ //exlude some categories from search - Depracated in 2.3
122
+ function SE4_exclude_categories($where) {
123
+ global $wp_query;
124
+ if (!empty($wp_query->query_vars['s'])) {
125
+ $excl_list = implode(',', explode(',', trim($this->options['SE4_exclude_categories_list'])));
126
+ $where = str_replace('"', '\'', $where);
127
+ $where = 'AND ('.substr($where, strpos($where, 'AND')+3).' )';
128
+ $where .= ' AND (c.category_id NOT IN ( '.$excl_list.' ))';
129
+ }
130
+
131
+ $this->SE4_log("ex cats where: ".$where);
132
+ return $where;
133
+ }
134
+
135
+ //join for excluding categories - Depracated in 2.3
136
+ function SE4_exclude_categories_join($join) {
137
+ global $wp_query, $wpdb;
138
+
139
+ if (!empty($wp_query->query_vars['s'])) {
140
+
141
+ $join .= "LEFT JOIN $wpdb->post2cat AS c ON $wpdb->posts.ID = c.post_id";
142
+ }
143
+ $this->SE4_log("category join: ".$join);
144
+ return $join;
145
+ }
146
+
147
+ //search pages (except password protected pages provided by loops)
148
+ function SE4_search_pages($where) {
149
+ global $wp_query;
150
+ if (!empty($wp_query->query_vars['s'])) {
151
+
152
+ $where = str_replace('"', '\'', $where);
153
+ if ('true' == $this->options['SE4_approved_pages_only']) {
154
+ $where = str_replace('post_type = \'post\' AND ', 'post_password = \'\' AND ', $where);
155
+ }
156
+ else { // < v 2.1
157
+ $where = str_replace('post_type = \'post\' AND ', '', $where);
158
+ }
159
+ }
160
+
161
+ $this->SE4_log("pages where: ".$where);
162
+ return $where;
163
+ }
164
+
165
+ //search excerpts provided by Dennis Turner
166
+ function SE4_search_excerpt($where) {
167
+ global $wp_query;
168
+ if (!empty($wp_query->query_vars['s'])) {
169
+ $where = str_replace('"', '\'', $where);
170
+ $where = str_replace(' OR (post_content LIKE \'%' .
171
+ $wp_query->query_vars['s'] . '%\'', ' OR (post_content LIKE \'%' .
172
+ $wp_query->query_vars['s'] . '%\') OR (post_excerpt LIKE \'%' .
173
+ $wp_query->query_vars['s'] . '%\'', $where);
174
+ }
175
+
176
+ $this->SE4_log("excerpts where: ".$where);
177
+ return $where;
178
+ }
179
+
180
+ //search drafts
181
+ function SE4_search_draft_posts($where) {
182
+ global $wp_query;
183
+ if (!empty($wp_query->query_vars['s'])) {
184
+ $where = str_replace('"', '\'', $where);
185
+ $where = str_replace(' AND (post_status = \'publish\'', ' AND (post_status = \'publish\' or post_status = \'draft\'', $where);
186
+ }
187
+
188
+ $this->SE4_log("drafts where: ".$where);
189
+ return $where;
190
+ }
191
+
192
+ //search attachments
193
+ function SE4_search_attachments($where) {
194
+ global $wp_query;
195
+ if (!empty($wp_query->query_vars['s'])) {
196
+ $where = str_replace('"', '\'', $where);
197
+ $where = str_replace(' AND (post_status = \'publish\'', ' AND (post_status = \'publish\' or post_status = \'attachment\'', $where);
198
+ $where = str_replace('AND post_status != \'attachment\'','',$where);
199
+ }
200
+
201
+ $this->SE4_log("attachments where: ".$where);
202
+ return $where;
203
+ }
204
+
205
+ //search comments
206
+ function SE4_search_comments($where) {
207
+ global $wp_query, $wpdb;
208
+ if (!empty($wp_query->query_vars['s'])) {
209
+ $where .= " OR (comment_content LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%') ";
210
+ }
211
+
212
+ $this->SE4_log("comments where: ".$where);
213
+
214
+ return $where;
215
+ }
216
+
217
+ //join for searching comments
218
+ function SE4_comments_join($join) {
219
+ global $wp_query, $wpdb;
220
+
221
+ if (!empty($wp_query->query_vars['s'])) {
222
+
223
+ if ('true' == $this->options['SE4_approved_comments_only']) {
224
+ $comment_approved = " AND comment_approved = '1'";
225
+ } else {
226
+ $comment_approved = '';
227
+ }
228
+
229
+ $join .= "LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID " . $comment_approved . ") ";
230
+ }
231
+ $this->SE4_log("comments join: ".$join);
232
+ return $join;
233
+ }
234
+
235
+ //search metadata
236
+ function SE4_search_metadata($where) {
237
+ global $wp_query, $wpdb;
238
+ if (!empty($wp_query->query_vars['s'])) {
239
+ $where .= " OR meta_value LIKE '%" . $wpdb->escape($wp_query->query_vars['s']) . "%' ";
240
+ }
241
+
242
+ $this->SE4_log("metadata where: ".$where);
243
+
244
+ return $where;
245
+ }
246
+
247
+ //join for searching metadata
248
+ function SE4_search_metadata_join($join) {
249
+ global $wp_query, $wpdb;
250
+
251
+ if (!empty($wp_query->query_vars['s'])) {
252
+
253
+ $join .= "LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ";
254
+ }
255
+ $this->SE4_log("metadata join: ".$join);
256
+ return $join;
257
+ }
258
+ }
259
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  ?>