Search Everything - Version 8.1.7

Version Description

  • Compatibility with WordPress 4.7
  • Security update: resolve SQL injection vunerability related to WP 4.7
Download this release

Release Info

Developer sovrn
Plugin Icon wp plugin Search Everything
Version 8.1.7
Comparing to
See all releases

Code changes from version 8.1.6 to 8.1.7

README.markdown DELETED
@@ -1,79 +0,0 @@
1
- Description
2
- ===========
3
-
4
- Better WordPress search in three steps
5
- --------------------------------------
6
-
7
- 1. Activate
8
- 2. Configure options
9
- 3. Search ( maybe that's only two steps )
10
-
11
- Options include search highlight, searching pages, excerpts, attachments, drafts, comments and custom fields (metadata).
12
-
13
- What it does:
14
- -------------
15
-
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 )
23
- * Search Every Category
24
- * Search non-password protected pages only
25
- * Search Every Comment
26
- * Search only approved comments
27
- * Search Every Draft
28
- * Search Every Excerpt
29
- * Search Every Attachment (post type)
30
- * Search Every Custom Field (metadata)
31
- * Exclude Posts from search
32
- * Exclude Categories from search
33
-
34
-
35
- Installation
36
- ============
37
-
38
- Installation Instructions:
39
-
40
- 1. Download the plugin and unzip it (didn't you already do this?).
41
- 2. Put the 'search-everything' directory into your wp-content/plugins/ directory.
42
- 3. Go to the Plugins page in your WordPress Administration area and click 'Activate' next to Search Everything.
43
- 4. Go to the Options > Search Everything and configure your settings.
44
- 5. That's it. Have fun and if you can contribute (see notes).
45
-
46
-
47
- Frequently Asked Questions
48
- --------------------------
49
-
50
- > It doesn't work
51
-
52
- Read the installation guide.
53
-
54
- > It *still* doesn't work
55
-
56
- Create an issue here on github.
57
-
58
- What Translations are included?
59
- ===============================
60
-
61
- * Arabic
62
- * Belarusian
63
- * China / Chinese
64
- * Dutch
65
- * French
66
- * German
67
- * Hungarian
68
- * Italian
69
- * Japanese
70
- * Korean
71
- * Latvian
72
- * Norwegian (Bokmål)
73
- * Norwegian (Nynorsk)
74
- * Romanian
75
- * Russian
76
- * Spanish
77
- * Swedish
78
- * Turkish
79
- * Taiwan / Chinese
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lang/SearchEverything-ar_AR.mo CHANGED
File without changes
lang/SearchEverything-ar_AR.po CHANGED
File without changes
lang/SearchEverything-da_DK.mo CHANGED
File without changes
lang/SearchEverything-da_DK.po CHANGED
File without changes
lang/SearchEverything-hu_HU.mo CHANGED
File without changes
lang/SearchEverything-hu_HU.po CHANGED
File without changes
lang/SearchEverything-ja.mo CHANGED
File without changes
lang/SearchEverything-ko_KR.mo DELETED
Binary file
lang/SearchEverything-ko_KR.mo.html CHANGED
File without changes
lang/SearchEverything-ko_KR.po DELETED
@@ -1,260 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Search Everything 6.3.1\n"
4
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/search-everything\n"
5
- "POT-Creation-Date: 2009-06-11 23:25+0000\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: Nod <contact@nod.pe.kr>\n"
8
- "Language-Team: FantasyAmplifier.com <contact@nod.pe.kr>\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "Plural-Forms: nplurals=2; plural=n != 1\n"
13
- "X-Poedit-Language: Korean\n"
14
- "X-Poedit-Country: KOREA, REPUBLIC OF\n"
15
-
16
- #: views/options.php:54
17
- #: views/options.php:61
18
- msgid "Your default search settings have been <strong>updated</strong> by Search Everything. </p><p> What are you waiting for? Go check out the new search results!"
19
- msgstr "워드프레스 기본 검색 설정이 Search Everything에 의해 <strong>수정</strong>되었습니다. </p><p>검색결과를 확인해보세요."
20
-
21
- #: views/options.php:71
22
- msgid "Search Everything Version:"
23
- msgstr "SE 버전:"
24
-
25
- #: views/options.php:76
26
- #: views/options.php:278
27
- msgid "Update Options"
28
- msgstr "변경 사항 적용"
29
-
30
- #: views/options.php:84
31
- msgid "Basic Configuration"
32
- msgstr "기본 환경설정"
33
-
34
- #: views/options.php:90
35
- msgid "Search every page"
36
- msgstr "모든 페이지 검색"
37
-
38
- #: views/options.php:90
39
- msgid "(non-password protected)"
40
- msgstr "비밀번호로 보호되지 않은 글"
41
-
42
- #: views/options.php:94
43
- #: views/options.php:105
44
- #: views/options.php:118
45
- #: views/options.php:132
46
- #: views/options.php:143
47
- #: views/options.php:153
48
- #: views/options.php:163
49
- #: views/options.php:173
50
- #: views/options.php:186
51
- #: views/options.php:197
52
- #: views/options.php:207
53
- #: views/options.php:217
54
- #: views/options.php:227
55
- msgid "Yes"
56
- msgstr "네"
57
-
58
- #: views/options.php:101
59
- msgid "Search approved pages only"
60
- msgstr "승인된 페이지만 검색"
61
-
62
- #: views/options.php:114
63
- msgid "Search every tag name"
64
- msgstr "모든 태그 검색"
65
-
66
- #: views/options.php:128
67
- msgid "Search every category name and description"
68
- msgstr "모든 카테고리 이름과 설명 검색"
69
-
70
- #: views/options.php:139
71
- msgid "Search every comment"
72
- msgstr "모든 댓글 검색"
73
-
74
- #: views/options.php:149
75
- msgid "Search comment authors"
76
- msgstr "댓글 작성자 이름 검색"
77
-
78
- #: views/options.php:159
79
- msgid "Search approved comments only"
80
- msgstr "승인된 댓글만 검색"
81
-
82
- #: views/options.php:169
83
- msgid "Search every excerpt"
84
- msgstr "모든 글 요약 검색"
85
-
86
- #: views/options.php:182
87
- msgid "Search every draft"
88
- msgstr "모든 임시글 검색"
89
-
90
- #: views/options.php:193
91
- msgid "Search every attachment"
92
- msgstr "모든 첨부파일 검색"
93
-
94
- #: views/options.php:193
95
- msgid "(post type = attachment)"
96
- msgstr "(포스트 유형 = 첨부)"
97
-
98
- #: views/options.php:203
99
- msgid "Search every custom field"
100
- msgstr "모든 사용자정의 필드 검색"
101
-
102
- #: views/options.php:203
103
- msgid "(metadata)"
104
- msgstr "(메타정보)"
105
-
106
- #: views/options.php:213
107
- msgid "Search every author"
108
- msgstr "모든 저자 이름 검색"
109
-
110
- #: views/options.php:223
111
- msgid "Highlight Search Terms"
112
- msgstr "검색어 강조"
113
-
114
- #: views/options.php:233
115
- msgid "Highlight Background Color"
116
- msgstr "배경색 강조"
117
-
118
- #: views/options.php:236
119
- msgid "Examples:<br/>'#FFF984' or 'red'"
120
- msgstr "예:'#FFF984' 처럼 색상코드나 'red'처럼 색깔 이름을 입력해주세요."
121
-
122
- #: views/options.php:246
123
- msgid "Advanced Configuration - Exclusion"
124
- msgstr "고급 설정 - 검섹 제외"
125
-
126
- #: views/options.php:252
127
- msgid "Exclude some post or page IDs"
128
- msgstr "특정 포스트나 페이지 검색 제외"
129
-
130
- #: views/options.php:255
131
- msgid "Comma separated Post IDs (example: 1, 5, 9)"
132
- msgstr "글 고유번호(ID)를 쉼표를 이용해 구분하세요. 예) 1, 7, 139"
133
-
134
- #: views/options.php:259
135
- msgid "Exclude Categories"
136
- msgstr "카테고리 제외"
137
-
138
- #: views/options.php:262
139
- msgid "Comma separated category IDs (example: 1, 4)"
140
- msgstr "카테고리 고유번호(ID)를 쉼표(,)를 이용해 구분해주세요. 예) 1, 203, 7"
141
-
142
- #: views/options.php:266
143
- msgid "Full Highlight Style"
144
- msgstr "전체 스타일 강조"
145
-
146
- #: views/options.php:268
147
- msgid "Important: 'Highlight Background Color' must be blank to use this advanced styling."
148
- msgstr "중요: 고급 스타일링 기능을 사용하기 위해서는 기본 환경설정의 검색어 강조의 배경색을 비워두셔야 됩니다."
149
-
150
- #: views/options.php:270
151
- msgid "Example:<br/>background-color: #FFF984; font-weight: bold; color: #000; padding: 0 1px;"
152
- msgstr "예: background-color: #FFF984; font-weight: bold; color: #000; padding: 0 1px;"
153
-
154
- #: views/options.php:283
155
- msgid "Developed by Dan Cameron of"
156
- msgstr "플러그인 개발: Dan Cameron "
157
-
158
- #: views/options.php:283
159
- msgid "Sprout Venture"
160
- msgstr "(Sprout Venture)"
161
-
162
- #: views/options.php:283
163
- msgid "We Provide custom WordPress Plugins and Themes and a whole lot more."
164
- msgstr "Sprout Venture에서는 많은 워드프레스 플러그인과 테마를 주문제작하고 있습니다."
165
-
166
- #: views/options.php:287
167
- msgid "Reset Button"
168
- msgstr "설정 초기화"
169
-
170
- #: views/options.php:295
171
- msgid "Find a bug?"
172
- msgstr "버그를 발견하셨어요?"
173
-
174
- #: views/options.php:295
175
- msgid "Post it as a new issue"
176
- msgstr "글을 올려 주세요."
177
-
178
- #: views/options.php:302
179
- msgid "Test Search Form"
180
- msgstr "SE 검색창"
181
-
182
- #: views/options.php:309
183
- msgid "Use this search form to run a live search test."
184
- msgstr "아래 검색창을 이용해 시험 검색해보세요."
185
-
186
- #: views/options.php:315
187
- msgid "Run Test Search"
188
- msgstr "검색"
189
-
190
- #: views/options.php:326
191
- msgid "News"
192
- msgstr "소식"
193
-
194
- #: views/options.php:327
195
- msgid "Development Support"
196
- msgstr "SE 개발 지원"
197
-
198
- #: views/options.php:328
199
- msgid "Localization Support"
200
- msgstr "SE 지역화 지원"
201
-
202
- #: views/options.php:334
203
- msgid "LOCALIZATION SUPPORT:"
204
- msgstr "SE 플러그인 지역화 지원:"
205
-
206
- #: views/options.php:334
207
- msgid "Version 6 was a major update and a few areas need new localization support. If you can help send me your translations by posting them as a new issue, "
208
- msgstr "SE 6판에서는 중요한 업데이트가 있었으며 몇몇 지역에서는 플러그인 지역화(번역) 지원이 필요합니다. 만약 도움을 주실 수 있다면 번역하신 언어 파일을 새글을 작성해 첨부해주세요."
209
-
210
- #: views/options.php:334
211
- msgid "here"
212
- msgstr "글을 올려주실 곳"
213
-
214
- #: views/options.php:335
215
- msgid "Thank You!"
216
- msgstr "감사합니다!"
217
-
218
- #: views/options.php:335
219
- msgid "The development of Search Everything since Version one has primarily come from the WordPress community, I&#8217;m grateful for their dedicated and continued support."
220
- msgstr "Search Everything은 1판부터 워드프레스 커뮤니티로부터 많은 도움을 받아 플러그인을 개발해오고 있습니다. 그 분들의 끊임 없는 지원과 노력에 감사합니다."
221
-
222
- #: views/options.php:345
223
- msgid "and many more..."
224
- msgstr "더 많은 분들이 있습니다."
225
-
226
- #: views/options.php:345
227
- msgid "how about you?"
228
- msgstr "도움을 주지 않으시겠어요?"
229
-
230
- #. Plugin Name of an extension
231
- msgid "Search Everything"
232
- msgstr "Search Everything"
233
-
234
- #. Plugin URI of an extension
235
- msgid "https://core.sproutventure.com/projects/show/search-everything"
236
- msgstr "https://core.sproutventure.com/projects/show/search-everything"
237
-
238
- #. Description of an extension
239
- msgid "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."
240
- msgstr "템플릿 페이지를 수정하지 않고 검색 기능을 향상시켜줍니다."
241
-
242
- #. Author of an extension
243
- msgid "Dan Cameron of Sprout Venture"
244
- msgstr "Sprout Ventur의 Dan Cameron"
245
-
246
- #. Author URI of an extension
247
- msgid "http://sproutventure.com/"
248
- msgstr "http://sproutventure.com/"
249
-
250
- #~ msgid "Search Everything Options <strong>Updated</strong>."
251
- #~ msgstr "Search Everything 설정이 <strong>수정</strong>되었습니다."
252
- #~ msgid "SE Search Options"
253
- #~ msgstr "SE 검색 설정"
254
- #~ msgid "Use this form to configure your search options."
255
- #~ msgstr "검색 옵션을 설정하기 위해 이 폼을 사용하세요."
256
- #~ msgid "Search Options Form"
257
- #~ msgstr "검색 옵션 폼"
258
- #~ msgid "Site Search"
259
- #~ msgstr "사이트 검색"
260
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lang/SearchEverything-ko_KR.po.html CHANGED
File without changes
lang/SearchEverything-nl_NL.mo CHANGED
File without changes
lang/SearchEverything-nl_NL.po CHANGED
File without changes
lang/SearchEverything-no_NO.mo CHANGED
File without changes
lang/SearchEverything-no_NO.po CHANGED
File without changes
lang/SearchEverything-pl_PL.mo CHANGED
File without changes
lang/SearchEverything-pl_PL.po CHANGED
File without changes
lang/SearchEverything-ro_RO.mo CHANGED
File without changes
lang/SearchEverything-ro_RO.po CHANGED
File without changes
lang/SearchEverything-ru_RU.mo CHANGED
File without changes
lang/SearchEverything-ru_RU.po CHANGED
File without changes
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: sovrn, zemanta
3
  Tags: search, search highlight, tag search, category search, category exclusion, comment search, page search, admin, seo, post filter, research
4
  Requires at least: 3.6
5
- Tested up to: 4.6
6
- Stable tag: 8.1.6
7
 
8
  Search Everything increases WordPress' default search functionality in three easy steps.
9
 
@@ -115,6 +115,9 @@ Before using the plugin please read the full version of [Zemanta Terms of Servic
115
 
116
 
117
  == Changelog ==
 
 
 
118
 
119
  = 8.1.6 =
120
  * Security update: filtering out empty search strings that could enable sql injections
2
  Contributors: sovrn, zemanta
3
  Tags: search, search highlight, tag search, category search, category exclusion, comment search, page search, admin, seo, post filter, research
4
  Requires at least: 3.6
5
+ Tested up to: 4.7.3
6
+ Stable tag: 8.1.7
7
 
8
  Search Everything increases WordPress' default search functionality in three easy steps.
9
 
115
 
116
 
117
  == Changelog ==
118
+ = 8.1.7 =
119
+ * Compatibility with WordPress 4.7
120
+ * Security update: resolve SQL injection vunerability related to WP 4.7
121
 
122
  = 8.1.6 =
123
  * Security update: filtering out empty search strings that could enable sql injections
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
search-everything.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Search Everything
4
  Plugin URI: http://wordpress.org/plugins/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: 8.1.6
7
  Author: Sovrn, zemanta
8
  Author URI: http://www.sovrn.com
9
  */
10
 
11
- define('SE_VERSION', '8.1.6');
12
 
13
  if (!defined('SE_PLUGIN_FILE'))
14
  define('SE_PLUGIN_FILE', plugin_basename(__FILE__));
@@ -48,10 +48,6 @@ add_action('wp_loaded','se_initialize_plugin');
48
 
49
  function se_initialize_plugin() {
50
  $SE = new SearchEverything();
51
-
52
- //add filters based upon option settings
53
- //include_once(SE_PLUGIN_DIR . '/zemanta/zemanta.php');
54
- //$se_zemanta = new SEZemanta();
55
  }
56
 
57
  function se_get_view($view) {
@@ -244,38 +240,44 @@ class SearchEverything {
244
 
245
  // add where clause to the search query
246
  function se_search_where( $where, $wp_query ) {
247
-
248
  if ( !$wp_query->is_search() && !$this->ajax_request)
249
  return $where;
250
 
251
  $this->query_instance = &$wp_query;
252
  global $wpdb;
253
 
254
- $searchQuery = $this->se_search_default();
255
 
256
  //add filters based upon option settings
257
  if ( $this->options['se_use_tag_search'] ) {
258
  $searchQuery .= $this->se_build_search_tag();
259
  }
 
260
  if ( $this->options['se_use_category_search'] || $this->options['se_use_tax_search'] ) {
261
  $searchQuery .= $this->se_build_search_categories();
262
  }
 
263
  if ( $this->options['se_use_metadata_search'] ) {
264
  $searchQuery .= $this->se_build_search_metadata();
265
  }
 
266
  if ( $this->options['se_use_excerpt_search'] ) {
267
  $searchQuery .= $this->se_build_search_excerpt();
268
  }
 
269
  if ( $this->options['se_use_comment_search'] ) {
270
  $searchQuery .= $this->se_build_search_comments();
271
  }
 
272
  if ( $this->options['se_use_authors'] ) {
273
  $searchQuery .= $this->se_search_authors();
274
  }
275
- if ( $searchQuery != '' ) {
276
- $where = preg_replace( '#\(\(\(.*?\)\)\)#', '(('.$searchQuery.'))', $where );
277
 
 
 
 
278
  }
 
279
  if ( $this->options['se_exclude_posts_list'] != '' ) {
280
  $where .= $this->se_build_exclude_posts();
281
  }
@@ -290,9 +292,7 @@ class SearchEverything {
290
  // replacing the old search terms seems to be the best way to
291
  // avoid issue with multiple terms
292
  function se_search_default(){
293
-
294
  global $wpdb;
295
-
296
  $not_exact = empty($this->query_instance->query_vars['exact']);
297
  $search_sql_query = '';
298
  $seperator = '';
@@ -304,13 +304,10 @@ class SearchEverything {
304
  foreach ( $terms as $term ) {
305
  $search_sql_query .= $seperator;
306
 
307
- $esc_term = esc_sql($term);
308
- if ($not_exact) {
309
- $esc_term = "%$esc_term%";
310
- }
311
 
312
- $like_title = "($wpdb->posts.post_title LIKE '$esc_term')";
313
- $like_post = "($wpdb->posts.post_content LIKE '$esc_term')";
314
 
315
  $search_sql_query .= "($like_title OR $like_post)";
316
 
@@ -404,18 +401,17 @@ class SearchEverything {
404
  $n = ( $exact ) ? '' : '%';
405
  $searchand = '';
406
  foreach ( $search_terms as $term ) {
407
- $term = addslashes_gpc( $term );
408
- $search .= "{$searchand}($wpdb->posts.post_excerpt LIKE '{$n}{$term}{$n}')";
409
  $searchand = ' AND ';
410
  }
411
- $sentence_term = esc_sql( $s );
412
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
413
- $search = "($search) OR ($wpdb->posts.post_excerpt LIKE '{$n}{$sentence_term}{$n}')";
414
  }
415
  if ( !empty( $search ) )
416
  $search = " OR ({$search}) ";
417
  }
418
-
419
  return $search;
420
  }
421
 
@@ -466,20 +462,19 @@ class SearchEverything {
466
  $search = '';
467
  if ( !empty( $search_terms ) ) {
468
  // Building search query on comments content
469
- $n = ( $exact ) ? '' : '%';
470
  $searchand = '';
471
  $searchContent = '';
472
  foreach ( $search_terms as $term ) {
473
- $term = addslashes_gpc( $term );
474
  if ( $this->wp_ver23 ) {
475
- $searchContent .= "{$searchand}(cmt.comment_content LIKE '{$n}{$term}{$n}')";
476
  }
477
  $searchand = ' AND ';
478
  }
479
- $sentense_term = esc_sql( $s );
480
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentense_term ) {
481
  if ( $this->wp_ver23 ) {
482
- $searchContent = "($searchContent) OR (cmt.comment_content LIKE '{$n}{$sentense_term}{$n}')";
483
  }
484
  }
485
  $search = $searchContent;
@@ -488,16 +483,16 @@ class SearchEverything {
488
  $searchand = '';
489
  $comment_author = '';
490
  foreach ( $search_terms as $term ) {
491
- $term = addslashes_gpc( $term );
492
  if ( $this->wp_ver23 ) {
493
- $comment_author .= "{$searchand}(cmt.comment_author LIKE '{$n}{$term}{$n}')";
494
  }
495
  $searchand = ' AND ';
496
  }
497
- $sentence_term = esc_sql( $s );
498
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
499
  if ( $this->wp_ver23 ) {
500
- $comment_author = "($comment_author) OR (cmt.comment_author LIKE '{$n}{$sentence_term}{$n}')";
501
  }
502
  }
503
  $search = "($search) OR ($comment_author)";
@@ -519,32 +514,30 @@ class SearchEverything {
519
  global $wpdb;
520
  $s = $this->query_instance->query_vars['s'];
521
  $search_terms = $this->se_get_search_terms();
522
- $n = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? '' : '%';
523
  $search = '';
524
  $searchand = '';
525
 
526
  if ( !empty( $search_terms ) ) {
527
  // Building search query
528
  foreach ( $search_terms as $term ) {
529
- $term = addslashes_gpc( $term );
530
  if ( $this->wp_ver23 ) {
531
- $search .= "{$searchand}(u.display_name LIKE '{$n}{$term}{$n}')";
532
  } else {
533
- $search .= "{$searchand}(u.display_name LIKE '{$n}{$term}{$n}')";
534
  }
535
  $searchand = ' OR ';
536
  }
537
- $sentence_term = esc_sql( $s );
538
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
539
  if ( $this->wp_ver23 ) {
540
- $search .= " OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
541
  } else {
542
- $search .= " OR (u.display_name LIKE '{$n}{$sentence_term}{$n}')";
543
  }
544
  }
545
 
546
-
547
-
548
  if ( !empty( $search ) )
549
  $search = " OR ({$search}) ";
550
 
@@ -559,27 +552,27 @@ class SearchEverything {
559
  global $wpdb;
560
  $s = $this->query_instance->query_vars['s'];
561
  $search_terms = $this->se_get_search_terms();
562
- $n = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? '' : '%';
563
  $search = '';
564
 
565
  if ( !empty( $search_terms ) ) {
566
  // Building search query
567
  $searchand = '';
568
  foreach ( $search_terms as $term ) {
569
- $term = addslashes_gpc( $term );
570
  if ( $this->wp_ver23 ) {
571
- $search .= "{$searchand}(m.meta_value LIKE '{$n}{$term}{$n}')";
572
  } else {
573
- $search .= "{$searchand}(meta_value LIKE '{$n}{$term}{$n}')";
574
  }
575
  $searchand = ' AND ';
576
  }
577
- $sentence_term = esc_sql( $s );
578
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
579
  if ( $this->wp_ver23 ) {
580
- $search = "($search) OR (m.meta_value LIKE '{$n}{$sentence_term}{$n}')";
581
  } else {
582
- $search = "($search) OR (meta_value LIKE '{$n}{$sentence_term}{$n}')";
583
  }
584
  }
585
 
@@ -603,19 +596,18 @@ class SearchEverything {
603
 
604
  if ( !empty( $search_terms ) ) {
605
  // Building search query
606
- $n = ( $exact ) ? '' : '%';
607
  $searchand = '';
608
  foreach ( $search_terms as $term ) {
609
- $term = addslashes_gpc( $term );
610
  if ( $this->wp_ver23 ) {
611
- $search .= "{$searchand}(tter.name LIKE '{$n}{$term}{$n}')";
612
  }
613
  $searchand = ' OR ';
614
  }
615
- $sentence_term = esc_sql( $s );
616
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
617
  if ( $this->wp_ver23 ) {
618
- $search = "($search) OR (tter.name LIKE '{$n}{$sentence_term}{$n}')";
619
  }
620
  }
621
  if ( !empty( $search ) )
@@ -637,16 +629,17 @@ class SearchEverything {
637
 
638
  if ( !empty( $search_terms ) ) {
639
  // Building search query for categories slug.
640
- $n = ( $exact ) ? '' : '%';
641
  $searchand = '';
642
  $searchSlug = '';
643
  foreach ( $search_terms as $term ) {
644
- $term = addslashes_gpc( $term );
645
- $searchSlug .= "{$searchand}(tter.slug LIKE '{$n}".sanitize_title_with_dashes( $term )."{$n}')";
646
  $searchand = ' AND ';
647
  }
 
 
648
  if ( count( $search_terms ) > 1 && $search_terms[0] != $s ) {
649
- $searchSlug = "($searchSlug) OR (tter.slug LIKE '{$n}".sanitize_title_with_dashes( $s )."{$n}')";
650
  }
651
  if ( !empty( $searchSlug ) )
652
  $search = " OR ({$searchSlug}) ";
@@ -655,13 +648,13 @@ class SearchEverything {
655
  $searchand = '';
656
  $searchDesc = '';
657
  foreach ( $search_terms as $term ) {
658
- $term = addslashes_gpc( $term );
659
- $searchDesc .= "{$searchand}(ttax.description LIKE '{$n}{$term}{$n}')";
660
  $searchand = ' AND ';
661
  }
662
- $sentence_term = esc_sql( $s );
663
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
664
- $searchDesc = "($searchDesc) OR (ttax.description LIKE '{$n}{$sentence_term}{$n}')";
665
  }
666
  if ( !empty( $searchDesc ) )
667
  $search = $search." OR ({$searchDesc}) ";
@@ -855,7 +848,12 @@ class SearchEverything {
855
  add_action('wp_ajax_search_everything', 'search_everything_callback');
856
 
857
  function search_everything_callback() {
858
- $is_query = !empty($_GET['s']);
 
 
 
 
 
859
  $result = array();
860
  if ($is_query) {
861
  $result = array(
@@ -864,7 +862,7 @@ function search_everything_callback() {
864
  );
865
 
866
  $params = array(
867
- 's' => $_GET['s']
868
  );
869
 
870
  $zemanta_response = se_api(array(
@@ -892,8 +890,9 @@ function search_everything_callback() {
892
  if (!empty($_GET['exact'])) {
893
  $params['exact'] = true;
894
  }
 
895
  $params["showposts"] = 5;
896
- $post_query = new WP_query($params);
897
 
898
  while ( $post_query->have_posts() ) {
899
  $post_query->the_post();
3
  Plugin Name: Search Everything
4
  Plugin URI: http://wordpress.org/plugins/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: 8.1.7
7
  Author: Sovrn, zemanta
8
  Author URI: http://www.sovrn.com
9
  */
10
 
11
+ define('SE_VERSION', '8.1.7');
12
 
13
  if (!defined('SE_PLUGIN_FILE'))
14
  define('SE_PLUGIN_FILE', plugin_basename(__FILE__));
48
 
49
  function se_initialize_plugin() {
50
  $SE = new SearchEverything();
 
 
 
 
51
  }
52
 
53
  function se_get_view($view) {
240
 
241
  // add where clause to the search query
242
  function se_search_where( $where, $wp_query ) {
 
243
  if ( !$wp_query->is_search() && !$this->ajax_request)
244
  return $where;
245
 
246
  $this->query_instance = &$wp_query;
247
  global $wpdb;
248
 
249
+ $searchQuery = $this->se_search_default();
250
 
251
  //add filters based upon option settings
252
  if ( $this->options['se_use_tag_search'] ) {
253
  $searchQuery .= $this->se_build_search_tag();
254
  }
255
+
256
  if ( $this->options['se_use_category_search'] || $this->options['se_use_tax_search'] ) {
257
  $searchQuery .= $this->se_build_search_categories();
258
  }
259
+
260
  if ( $this->options['se_use_metadata_search'] ) {
261
  $searchQuery .= $this->se_build_search_metadata();
262
  }
263
+
264
  if ( $this->options['se_use_excerpt_search'] ) {
265
  $searchQuery .= $this->se_build_search_excerpt();
266
  }
267
+
268
  if ( $this->options['se_use_comment_search'] ) {
269
  $searchQuery .= $this->se_build_search_comments();
270
  }
271
+
272
  if ( $this->options['se_use_authors'] ) {
273
  $searchQuery .= $this->se_search_authors();
274
  }
 
 
275
 
276
+ if ( $searchQuery != '' ) {
277
+ // lets use _OUR_ query instead of WP's, as we have posts already included in our query as well(assuming it's not empty which we check for)
278
+ $where = " AND " . $searchQuery . " ";
279
  }
280
+
281
  if ( $this->options['se_exclude_posts_list'] != '' ) {
282
  $where .= $this->se_build_exclude_posts();
283
  }
292
  // replacing the old search terms seems to be the best way to
293
  // avoid issue with multiple terms
294
  function se_search_default(){
 
295
  global $wpdb;
 
296
  $not_exact = empty($this->query_instance->query_vars['exact']);
297
  $search_sql_query = '';
298
  $seperator = '';
304
  foreach ( $terms as $term ) {
305
  $search_sql_query .= $seperator;
306
 
307
+ $esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
 
 
 
308
 
309
+ $like_title = "($wpdb->posts.post_title LIKE $esc_term)";
310
+ $like_post = "($wpdb->posts.post_content LIKE $esc_term)";
311
 
312
  $search_sql_query .= "($like_title OR $like_post)";
313
 
401
  $n = ( $exact ) ? '' : '%';
402
  $searchand = '';
403
  foreach ( $search_terms as $term ) {
404
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
405
+ $search .= "{$searchand}($wpdb->posts.post_excerpt LIKE $term)";
406
  $searchand = ' AND ';
407
  }
408
+ $sentence_term = $wpdb->prepare("%s", $exact ? $s : "%$s%");
409
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
410
+ $search = "($search) OR ($wpdb->posts.post_excerpt LIKE $sentence_term)";
411
  }
412
  if ( !empty( $search ) )
413
  $search = " OR ({$search}) ";
414
  }
 
415
  return $search;
416
  }
417
 
462
  $search = '';
463
  if ( !empty( $search_terms ) ) {
464
  // Building search query on comments content
 
465
  $searchand = '';
466
  $searchContent = '';
467
  foreach ( $search_terms as $term ) {
468
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
469
  if ( $this->wp_ver23 ) {
470
+ $searchContent .= "{$searchand}(cmt.comment_content LIKE $term)";
471
  }
472
  $searchand = ' AND ';
473
  }
474
+ $sentense_term = $wpdb->prepare("%s", $s);
475
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentense_term ) {
476
  if ( $this->wp_ver23 ) {
477
+ $searchContent = "($searchContent) OR (cmt.comment_content LIKE $sentense_term)";
478
  }
479
  }
480
  $search = $searchContent;
483
  $searchand = '';
484
  $comment_author = '';
485
  foreach ( $search_terms as $term ) {
486
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
487
  if ( $this->wp_ver23 ) {
488
+ $comment_author .= "{$searchand}(cmt.comment_author LIKE $term)";
489
  }
490
  $searchand = ' AND ';
491
  }
492
+ $sentence_term = $wpdb->prepare("%s", $s);
493
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
494
  if ( $this->wp_ver23 ) {
495
+ $comment_author = "($comment_author) OR (cmt.comment_author LIKE $sentence_term)";
496
  }
497
  }
498
  $search = "($search) OR ($comment_author)";
514
  global $wpdb;
515
  $s = $this->query_instance->query_vars['s'];
516
  $search_terms = $this->se_get_search_terms();
517
+ $exact = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? true : false;
518
  $search = '';
519
  $searchand = '';
520
 
521
  if ( !empty( $search_terms ) ) {
522
  // Building search query
523
  foreach ( $search_terms as $term ) {
524
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
525
  if ( $this->wp_ver23 ) {
526
+ $search .= "{$searchand}(u.display_name LIKE $term)";
527
  } else {
528
+ $search .= "{$searchand}(u.display_name LIKE $term)";
529
  }
530
  $searchand = ' OR ';
531
  }
532
+ $sentence_term = $wpdb->prepare("%s", $s);
533
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
534
  if ( $this->wp_ver23 ) {
535
+ $search .= " OR (u.display_name LIKE $sentence_term)";
536
  } else {
537
+ $search .= " OR (u.display_name LIKE $sentence_term)";
538
  }
539
  }
540
 
 
 
541
  if ( !empty( $search ) )
542
  $search = " OR ({$search}) ";
543
 
552
  global $wpdb;
553
  $s = $this->query_instance->query_vars['s'];
554
  $search_terms = $this->se_get_search_terms();
555
+ $exact = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? true : false;
556
  $search = '';
557
 
558
  if ( !empty( $search_terms ) ) {
559
  // Building search query
560
  $searchand = '';
561
  foreach ( $search_terms as $term ) {
562
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
563
  if ( $this->wp_ver23 ) {
564
+ $search .= "{$searchand}(m.meta_value LIKE $term)";
565
  } else {
566
+ $search .= "{$searchand}(meta_value LIKE $term)";
567
  }
568
  $searchand = ' AND ';
569
  }
570
+ $sentence_term = $wpdb->prepare("%s", $s);
571
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
572
  if ( $this->wp_ver23 ) {
573
+ $search = "($search) OR (m.meta_value LIKE $sentence_term)";
574
  } else {
575
+ $search = "($search) OR (meta_value LIKE $sentence_term)";
576
  }
577
  }
578
 
596
 
597
  if ( !empty( $search_terms ) ) {
598
  // Building search query
 
599
  $searchand = '';
600
  foreach ( $search_terms as $term ) {
601
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
602
  if ( $this->wp_ver23 ) {
603
+ $search .= "{$searchand}(tter.name LIKE $term)";
604
  }
605
  $searchand = ' OR ';
606
  }
607
+ $sentence_term = $wpdb->prepare("%s", $s);
608
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
609
  if ( $this->wp_ver23 ) {
610
+ $search = "($search) OR (tter.name LIKE $sentence_term)";
611
  }
612
  }
613
  if ( !empty( $search ) )
629
 
630
  if ( !empty( $search_terms ) ) {
631
  // Building search query for categories slug.
 
632
  $searchand = '';
633
  $searchSlug = '';
634
  foreach ( $search_terms as $term ) {
635
+ $term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($term) . "%");
636
+ $searchSlug .= "{$searchand}(tter.slug LIKE $term)";
637
  $searchand = ' AND ';
638
  }
639
+
640
+ $term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($s) . "%");
641
  if ( count( $search_terms ) > 1 && $search_terms[0] != $s ) {
642
+ $searchSlug = "($searchSlug) OR (tter.slug LIKE $term)";
643
  }
644
  if ( !empty( $searchSlug ) )
645
  $search = " OR ({$searchSlug}) ";
648
  $searchand = '';
649
  $searchDesc = '';
650
  foreach ( $search_terms as $term ) {
651
+ $term = $wpdb->prepare("%s", $exact ? $term : "%$term%");
652
+ $searchDesc .= "{$searchand}(ttax.description LIKE $term)";
653
  $searchand = ' AND ';
654
  }
655
+ $sentence_term = $wpdb->prepare("%s", $s);
656
  if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
657
+ $searchDesc = "($searchDesc) OR (ttax.description LIKE $sentence_term)";
658
  }
659
  if ( !empty( $searchDesc ) )
660
  $search = $search." OR ({$searchDesc}) ";
848
  add_action('wp_ajax_search_everything', 'search_everything_callback');
849
 
850
  function search_everything_callback() {
851
+ global $wpdb;
852
+
853
+
854
+ $s = $_GET['s'];
855
+
856
+ $is_query = !empty($_GET['s']);
857
  $result = array();
858
  if ($is_query) {
859
  $result = array(
862
  );
863
 
864
  $params = array(
865
+ 's' => $s
866
  );
867
 
868
  $zemanta_response = se_api(array(
890
  if (!empty($_GET['exact'])) {
891
  $params['exact'] = true;
892
  }
893
+
894
  $params["showposts"] = 5;
895
+ $post_query = new WP_Query($params);
896
 
897
  while ( $post_query->have_posts() ) {
898
  $post_query->the_post();
static/img/search.png CHANGED
Binary file
static/img/zem-logo.png CHANGED
Binary file
static/js/searcheverything.js CHANGED
@@ -1,14 +1,273 @@
1
- var SearchEverything=function(a){var g={months:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),resizeSearchInput:function(){var b=a("#se-metabox-text");b.css({width:b.closest("div").outerWidth(!0)-b.next("a").outerWidth(!0)})},handleWindowResize:function(){a(window).resize(g.resizeSearchInput)},handleMetaboxActions:function(){a(".meta-box-sortables").on("sortstop",function(a,e){e.item&&(e.item.length&&"se-metabox"===e.item[0].id)&&g.resizeSearchInput()});a(".postbox h3, .postbox .handlediv").on("click",
2
- function(){var b=a(this).closest(".postbox");setTimeout(function(){b.hasClass("closed")||g.resizeSearchInput()},1)})},displayOwnResults:function(b,e){var d=0;a.each(e,function(e,c){var f=a('<li><div title="Click to insert link into post."><h6></h6><a href="" target="_blank"></a><p></p></div></li>');4<e||(d+=1,f.data(c),f.find("h6").text(c.post_title||"Title missing"),f.find("p").text(g.extractText(f,"post_content")),f.find("a").text(g.urlDomain(c.guid)).prop("title",c.title||"Title missing").prop("href",
3
- c.guid),b.append(f))});return d},extractText:function(b,e){var d=a("<div>"+b.data(e)+"</div>").text();!d||0===d.length?d="No Excerpt":100<d.length&&(d=d.substring(0,100)+"\u2026");return d},displayExternalResults:function(b,e){var d=0;a.each(e,function(e,c){var f=a('<li><div title="Click to insert link into post."><h6></h6><a href="" target="_blank"></a><p></p></div></li>');4<e||(d+=1,f.data(c),f.find("h6").text(c.title||"Title missing"),f.find("p").text(g.extractText(f,"text_preview")),f.find("a").text(g.urlDomain(c.url)).prop("title",
4
- c.title||"Title missing").prop("href",c.url),b.append(f))});return d},performSearch:function(){var b=a("#se-metabox-text"),e=a('<div id="se-metabox-results"><div id="se-metabox-external-results" class="se-metabox-results-list se-hidden"><h4>Results from around the web</h4><p class="se-instructions">Click to insert link into post.</p><ul></ul></div><div id="se-metabox-own-results" class="se-metabox-results-list"><h4>Results from your blog</h4><p class="se-instructions">Click to insert link into post.</p><ul></ul></div><div class="se-spinner"></div></div>'),
5
- d=0;a("#se-metabox-results").remove();b.closest("div").after(e);a.ajax({url:b.data("ajaxurl"),method:"get",dataType:"json",data:{action:"search_everything",text:tinyMCE&&tinyMCE.activeEditor.getContent()||"",s:b.prop("value")||""},success:function(e){var c=a("#se-metabox-own-results"),f=c.find("ul"),h=a("#se-metabox-external-results"),i=h.find("ul");a(".se-spinner, .se-no-results").remove();window.externalSearchEnabled?0===e.external.length?a("#se-metabox-results").append('<p class="se-no-results">We haven\'t found any external resources for you.</p>'):
6
- (h.show(),d=g.displayExternalResults(i,e.external),h.find("h4").text(h.find("h4").text()+" ("+d+")")):(c.before('<div id="se-metabox-own-powersearch" class="se-metabox-results-list"><h4>Results from around the web</h4><p>If you want to use external search, you need to enable it in your <a class="se-settings-link" href="options-general.php?page=extend_search" target="_blank"><strong>settings</strong></strong></a>.</p></div>'),a("#se-metabox-own-powersearch").show());0===e.own.length?(a("#se-metabox-results").append('<p class="se-no-results">It seems we haven\'t found any results for search term <strong>'+
7
- b.prop("value")+" on your blog</strong>.</p>"),h.removeClass("se-hidden")):(c.show(),d=g.displayOwnResults(f,e.own),c.find("h4").text(c.find("h4").text()+" ("+d+")"))},error:function(){a(".se-spinner, .se-no-results").remove();a("#se-metabox-results").append('<p class="se-no-results">There was something wrong with the search. Please try again. If this happens a lot, please check out our <a href="http://wordpress.org/support/plugin/search-everything" target="_blank">Support forum</a>.</p>')}});e.on("click",
8
- ".se-settings-link",function(){a(this).parent().text("Thanks. Please refresh this page.")})},urlDomain:function(a){var e=document.createElement("a");e.href=a;return e.hostname},handleSearch:function(){var b=a("#se-metabox-text");b.on("keypress",function(e){13===e.which&&(e.preventDefault(),""!==a.trim(b.prop("value"))&&g.performSearch())});a("#se-metabox-search").on("click",function(e){e.preventDefault();""!==a.trim(b.prop("value"))&&g.performSearch()})},initResultBehaviour:function(){var b=a("#se-metabox");
9
- b.on("click","#se-metabox-own-results li",function(e){var d=a('<div id="se-just-a-wrapper"><p><a target="_blank" class="se-box se-article"><span class="se-box-heading"><span class="se-box-heading-title"></span></span><span class="se-box-text"></span><span class="se-box-date"></span><span class="se-box-domain"></span></a></p></div>'),b=a(this),c;c=b.data("post_date").split(" ")[0].split("-");c=new Date(c[0],c[1]-1,c[2]);c=g.months[c.getMonth()]+" "+c.getDate()+" "+c.getFullYear();var f=a('a.se-box[href="'+
10
- b.data("guid")+'"]',tinyMCE&&tinyMCE.activeEditor.contentWindow.document||document);"A"!==a(e.target).prop("tagName")&&(f.length?"P"===f.parent().prop("tagName")?f.closest("p").remove():f.remove():(d.find(".se-box-heading-title").text(b.data("post_title")||"Title missing".substring(0,50)),d.find(".se-box-heading-domain").text("("+g.urlDomain(b.data("guid"))+")"),d.find(".se-box-text").text(g.extractText(b,"post_content")),d.find(".se-box-date").text(c),d.find(".se-box-domain").text(g.urlDomain(b.data("guid"))),
11
- d.find(".se-box").attr("href",b.data("guid")),send_to_editor&&send_to_editor(d.html())))});b.on("click","#se-metabox-external-results li",function(e){var d=a('<div id="se-just-a-wrapper"><p><a target="_blank" class="se-box se-article"><span class="se-box-heading"><span class="se-box-heading-title"></span></span><span class="se-box-text"></span><span class="se-box-date"></span><span class="se-box-domain"></span></a></p></div>'),b=a(this),c;c=b.data("published_datetime").split("T")[0].split("-");c=
12
- new Date(c[0],parseInt(c[1],10)-1,parseInt(c[2],10));c=g.months[c.getMonth()]+" "+c.getDate()+" "+c.getFullYear();var f=a('a.se-box[href="'+b.data("url")+'"]',tinyMCE&&tinyMCE.activeEditor.contentWindow.document||document);"A"!==a(e.target).prop("tagName")&&(f.length?"P"===f.parent().prop("tagName")?f.closest("p").remove():f.remove():(d.find(".se-box-heading-title").text(b.data("title")||"Title missing".substring(0,50)),d.find(".se-box-heading-domain").text("("+g.urlDomain(b.data("article_id"))+")"),
13
- d.find(".se-box-text").text(g.extractText(b,"text_preview")),d.find(".se-box-date").text(c),d.find(".se-box-domain").text(g.urlDomain(b.data("url"))),d.find(".se-box").attr("href",b.data("url")),send_to_editor&&send_to_editor(d.html())))});b.on("click",".se-metabox-results-list h4",function(){a(this).closest(".se-metabox-results-list").toggleClass("se-hidden")})}};return{initialize:function(){g.resizeSearchInput();g.handleWindowResize();g.handleMetaboxActions();g.handleSearch();g.initResultBehaviour();
14
- return this}}}(jQuery);jQuery(function(){SearchEverything.initialize();jQuery("a.se-back").on("click",function(a){a.preventDefault();window.history.back()})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var SearchEverything = (function ($) {
2
+ var r = {
3
+ months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
4
+ resizeSearchInput: function () {
5
+ var input = $('#se-metabox-text');
6
+
7
+ input.css({
8
+ 'width': input.closest('div').outerWidth(true) - input.next('a').outerWidth(true)
9
+ });
10
+ },
11
+ handleWindowResize: function () {
12
+ $(window).resize(r.resizeSearchInput);
13
+ },
14
+ handleMetaboxActions: function () {
15
+ $('.meta-box-sortables').on('sortstop', function (event, ui) {
16
+ if (ui.item && ui.item.length && ui.item[0].id === 'se-metabox') {
17
+ r.resizeSearchInput();
18
+ }
19
+ });
20
+ $('.postbox h3, .postbox .handlediv').on('click', function (ev) {
21
+ var postbox = $(this).closest('.postbox');
22
+
23
+ setTimeout(function () {
24
+ if (!postbox.hasClass('closed')) {
25
+ r.resizeSearchInput();
26
+ }
27
+ }, 1); // Delay till WP finishes its own thing and then we can kick in
28
+ })
29
+ },
30
+ displayOwnResults: function (holder, data) {
31
+ var count = 0;
32
+
33
+ $.each(data, function (i, result) {
34
+ var listItem = $('<li><div title="Click to insert link into post."><h6></h6><a href="" target="_blank"></a><p></p></div></li>');
35
+ if (i > 4) {
36
+ return;
37
+ }
38
+ count += 1;
39
+ listItem.data(result);
40
+
41
+ listItem.find('h6').text(result.post_title || 'Title missing');
42
+ listItem.find('p').text(r.extractText(listItem, 'post_content'));
43
+ listItem.find('a').text(r.urlDomain(result.guid)).prop('title', result.title || 'Title missing').prop('href', result.guid);
44
+
45
+ holder.append(listItem);
46
+ });
47
+
48
+ return count;
49
+ },
50
+ extractText: function (listItem, dataField) {
51
+ var temp = $('<div>' + listItem.data(dataField) + '</div>').text();
52
+
53
+ if (!temp || temp.length === 0) {
54
+ temp = 'No Excerpt';
55
+ } else if (temp.length > 100) {
56
+ temp = temp.substring(0, 100) + '…';
57
+ }
58
+ return temp;
59
+ },
60
+ displayExternalResults: function (holder, data) {
61
+ var count = 0;
62
+
63
+ $.each(data, function (i, result) {
64
+ var listItem = $('<li><div title="Click to insert link into post."><h6></h6><a href="" target="_blank"></a><p></p></div></li>');
65
+ if (i > 4) {
66
+ return;
67
+ }
68
+ count += 1;
69
+ listItem.data(result);
70
+
71
+ listItem.find('h6').text(result.title || 'Title missing');
72
+ listItem.find('p').text(r.extractText(listItem, 'text_preview'));
73
+ listItem.find('a').text(r.urlDomain(result.url)).prop('title', result.title || 'Title missing').prop('href', result.url);
74
+
75
+ holder.append(listItem);
76
+ });
77
+
78
+ return count;
79
+ },
80
+ performSearch: function () {
81
+ var input = $('#se-metabox-text'),
82
+ results = $('<div id="se-metabox-results"><div id="se-metabox-external-results" class="se-metabox-results-list se-hidden"><h4>Results from around the web</h4><p class="se-instructions">Click to insert link into post.</p><ul></ul></div><div id="se-metabox-own-results" class="se-metabox-results-list"><h4>Results from your blog</h4><p class="se-instructions">Click to insert link into post.</p><ul></ul></div><div class="se-spinner"></div></div>'),
83
+ count = 0;
84
+
85
+ $('#se-metabox-results').remove();
86
+ input.closest('div').after(results);
87
+
88
+ $.ajax({
89
+ url: input.data('ajaxurl'),
90
+ method: 'get',
91
+ dataType: "json",
92
+ data: {
93
+ action: 'search_everything',
94
+ text: tinyMCE && tinyMCE.activeEditor.getContent() || '',
95
+ s: input.prop('value') || ''
96
+ },
97
+ success: function (data) {
98
+ var ownResults = $('#se-metabox-own-results'),
99
+ ownResultsList = ownResults.find('ul'),
100
+ externalResults = $('#se-metabox-external-results'),
101
+ externalResultsList = externalResults.find('ul');
102
+
103
+ $('.se-spinner, .se-no-results').remove();
104
+ if (!window.externalSearchEnabled) {
105
+ ownResults.before('<div id="se-metabox-own-powersearch" class="se-metabox-results-list"><h4>Results from around the web</h4><p>If you want to use external search, you need to enable it in your <a class="se-settings-link" href="options-general.php?page=extend_search" target="_blank"><strong>settings</strong></strong></a>.</p></div>');
106
+ $('#se-metabox-own-powersearch').show();
107
+ } else {
108
+ if (data.external.length === 0) {
109
+ $('#se-metabox-results').append('<p class="se-no-results">We haven\'t found any external resources for you.</p>');
110
+ } else {
111
+ externalResults.show();
112
+ count = r.displayExternalResults(externalResultsList, data.external);
113
+ externalResults.find('h4').text(externalResults.find('h4').text() + ' (' + count + ')');
114
+ }
115
+ }
116
+ if (data.own.length === 0) {
117
+ $('#se-metabox-results').append('<p class="se-no-results">It seems we haven\'t found any results for search term <strong>' + input.prop('value') + ' on your blog</strong>.</p>');
118
+ externalResults.removeClass('se-hidden');
119
+ } else {
120
+ ownResults.show();
121
+ count = r.displayOwnResults(ownResultsList, data.own);
122
+ ownResults.find('h4').text(ownResults.find('h4').text() + ' (' + count + ')');
123
+ }
124
+ },
125
+ error: function (xhr) {
126
+ $('.se-spinner, .se-no-results').remove();
127
+ $('#se-metabox-results').append('<p class="se-no-results">There was something wrong with the search. Please try again. If this happens a lot, please check out our <a href="http://wordpress.org/support/plugin/search-everything" target="_blank">Support forum</a>.</p>');
128
+
129
+ }
130
+ });
131
+
132
+ results.on('click', '.se-settings-link', function () {
133
+ $(this).parent().text('Thanks. Please refresh this page.');
134
+ });
135
+ },
136
+ urlDomain: function (url) { // http://stackoverflow.com/a/8498668
137
+ var a = document.createElement('a');
138
+ a.href = url;
139
+ return a.hostname;
140
+ },
141
+ handleSearch: function () {
142
+ var input = $('#se-metabox-text');
143
+ input.on('keypress', function (ev) {
144
+ if (13 === ev.which) {
145
+ ev.preventDefault(); // Don't actually post... that would be silly
146
+ if ($.trim(input.prop('value')) !== '') {
147
+ r.performSearch();
148
+ }
149
+ }
150
+ });
151
+
152
+ $('#se-metabox-search').on('click', function (ev) {
153
+ ev.preventDefault(); // Don't actually go to another page... that would be destructive
154
+ if ($.trim(input.prop('value')) !== '') {
155
+ r.performSearch();
156
+ }
157
+ });
158
+ },
159
+ initResultBehaviour: function () {
160
+ var html = '<div id="se-just-a-wrapper">' +
161
+ '<p>' +
162
+ '<a target="_blank" class="se-box se-article">' +
163
+ '<span class="se-box-heading">' +
164
+ '<span class="se-box-heading-title"></span>' +
165
+ '</span>' +
166
+ '<span class="se-box-text"></span>' +
167
+ '<span class="se-box-date"></span>' +
168
+ '<span class="se-box-domain"></span>' +
169
+ '</a>' +
170
+ '</p>' +
171
+ '</div>',
172
+ metabox = $('#se-metabox');
173
+
174
+ metabox.on('click', '#se-metabox-own-results li', function (ev) {
175
+ var insertHtml = $(html),
176
+ listItem = $(this),
177
+ date = (function () {
178
+ var datePart = listItem.data('post_date').split(' ')[0].split('-'),
179
+ actualDate = new Date(datePart[0], datePart[1] - 1, datePart[2]);
180
+
181
+ return r.months[actualDate.getMonth()] + ' ' + actualDate.getDate() + ' ' + actualDate.getFullYear();
182
+ }()),
183
+ inserted = $('a.se-box[href="' + listItem.data('guid') + '"]', tinyMCE && tinyMCE.activeEditor.contentWindow.document || document);
184
+
185
+ if ($(ev.target).prop('tagName') === 'A') {
186
+ return;
187
+ }
188
+
189
+ if (inserted.length) {
190
+ if (inserted.parent().prop("tagName") === 'P') {
191
+ inserted.closest('p').remove();
192
+ } else {
193
+ inserted.remove();
194
+ }
195
+ } else {
196
+ insertHtml.find('.se-box-heading-title').text(listItem.data('post_title') || 'Title missing'.substring(0, 50));
197
+ insertHtml.find('.se-box-heading-domain').text('(' + r.urlDomain(listItem.data('guid')) + ')');
198
+ insertHtml.find('.se-box-text').text(r.extractText(listItem, 'post_content'));
199
+ insertHtml.find('.se-box-date').text(date);
200
+ insertHtml.find('.se-box-domain').text(r.urlDomain(listItem.data('guid')));
201
+ insertHtml.find('.se-box').attr('href', listItem.data('guid'));
202
+
203
+ if (send_to_editor) {
204
+ send_to_editor(insertHtml.html());
205
+ } else {
206
+ // Dunno yet
207
+ }
208
+ }
209
+ });
210
+ metabox.on('click', '#se-metabox-external-results li', function (ev) {
211
+ var insertHtml = $(html),
212
+ listItem = $(this),
213
+ date = (function () {
214
+ var datePart = listItem.data('published_datetime').split('T')[0].split('-'),
215
+ actualDate = new Date(datePart[0], parseInt(datePart[1], 10) - 1, parseInt(datePart[2], 10));
216
+
217
+ return r.months[actualDate.getMonth()] + ' ' + actualDate.getDate() + ' ' + actualDate.getFullYear();
218
+ }()),
219
+ inserted = $('a.se-box[href="' + listItem.data('url') + '"]', tinyMCE && tinyMCE.activeEditor.contentWindow.document || document);
220
+
221
+ if ($(ev.target).prop('tagName') === 'A') {
222
+ return;
223
+ }
224
+
225
+ if (inserted.length) {
226
+ if (inserted.parent().prop("tagName") === 'P') {
227
+ inserted.closest('p').remove();
228
+ } else {
229
+ inserted.remove();
230
+ }
231
+ } else {
232
+ insertHtml.find('.se-box-heading-title').text(listItem.data('title') || 'Title missing'.substring(0, 50));
233
+ insertHtml.find('.se-box-heading-domain').text('(' + r.urlDomain(listItem.data('article_id')) + ')');
234
+ insertHtml.find('.se-box-text').text(r.extractText(listItem, 'text_preview'));
235
+ insertHtml.find('.se-box-date').text(date);
236
+ insertHtml.find('.se-box-domain').text(r.urlDomain(listItem.data('url')));
237
+ insertHtml.find('.se-box').attr('href', listItem.data('url'));
238
+
239
+ if (send_to_editor) {
240
+ send_to_editor(insertHtml.html());
241
+ } else {
242
+ // Dunno yet
243
+ }
244
+ }
245
+ });
246
+
247
+ metabox.on('click', '.se-metabox-results-list h4', function () {
248
+ $(this).closest('.se-metabox-results-list').toggleClass('se-hidden');
249
+ });
250
+ }
251
+ },
252
+ u = {
253
+ initialize: function () {
254
+ r.resizeSearchInput();
255
+ r.handleWindowResize();
256
+ r.handleMetaboxActions();
257
+ r.handleSearch();
258
+ r.initResultBehaviour();
259
+
260
+ return this;
261
+ }
262
+ };
263
+ return u;
264
+ }(jQuery));
265
+
266
+ jQuery(function () {
267
+ SearchEverything.initialize();
268
+
269
+ jQuery("a.se-back").on('click', function (evt) {
270
+ evt.preventDefault();
271
+ window.history.back();
272
+ });
273
+ });