Search Everything - Version 8.1.1

Version Description

  • Security update (CSRF vunerability fix)
  • Added form validation to Options page
Download this release

Release Info

Developer ddksr
Plugin Icon wp plugin Search Everything
Version 8.1.1
Comparing to
See all releases

Code changes from version 8.1 to 8.1.1

config.php CHANGED
@@ -109,6 +109,12 @@ function se_upgrade() {
109
  }
110
  }
111
 
 
 
 
 
 
 
112
  function se_migrate_8_0() {
113
  $se_meta = get_option('se_meta', false);
114
  $se_meta['version'] = '8.1';
109
  }
110
  }
111
 
112
+ function se_migrate_8_1() {
113
+ $se_meta = get_option('se_meta', false);
114
+ $se_meta['version'] = '8.1.1';
115
+ update_option('se_meta', $se_meta);
116
+ }
117
+
118
  function se_migrate_8_0() {
119
  $se_meta = get_option('se_meta', false);
120
  $se_meta['version'] = '8.1';
options.php CHANGED
@@ -85,7 +85,6 @@ Class se_admin {
85
 
86
  // if our current user can't edit this post, bail
87
  if( !current_user_can( 'edit_post' ) ) return;
88
-
89
 
90
  }
91
 
@@ -94,10 +93,51 @@ Class se_admin {
94
  add_options_page('Search', 'Search Everything', 'manage_options', 'extend_search', array(&$this, 'se_option_page'));
95
  }
96
 
97
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  //build admin interface
99
  function se_option_page() {
100
  global $wpdb, $table_prefix, $wp_version;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  $new_options = array(
102
  'se_exclude_categories' => (isset($_POST['exclude_categories']) && !empty($_POST['exclude_categories'])) ? $_POST['exclude_categories'] : '',
103
  'se_exclude_categories_list' => (isset($_POST['exclude_categories_list']) && !empty($_POST['exclude_categories_list'])) ? $_POST['exclude_categories_list'] : '',
85
 
86
  // if our current user can't edit this post, bail
87
  if( !current_user_can( 'edit_post' ) ) return;
 
88
 
89
  }
90
 
93
  add_options_page('Search', 'Search Everything', 'manage_options', 'extend_search', array(&$this, 'se_option_page'));
94
  }
95
 
96
+ function se_validation($validation_rules) {
97
+ $regex = array(
98
+ "color" => "^(([a-z]+)|(#[0-9a-f]{2,6}))?$",
99
+ "numeric-comma" => "^(\d+(, ?\d+)*)?$",
100
+ "css" => "^(([a-zA-Z-])+\ *\:[^;]+; *)*$"
101
+ );
102
+ $messages = array(
103
+ "numeric-comma" => __("incorrect format for field <strong>%s</strong>",'SearchEverything'),
104
+ "color" => __("field <strong>%s</strong> should be a css color ('red' or '#abc123')",'SearchEverything'),
105
+ "css" => __("field <strong>%s</strong> doesn't contain valid css",'SearchEverything')
106
+ );
107
+ $errors = array();
108
+ foreach($validation_rules as $field => $rule_name) {
109
+ $rule = $regex[$rule_name];
110
+ if(!preg_match("/$rule/", $_POST[$field])) {
111
+ $errors[$field] = $messages[$rule_name];
112
+ }
113
+ }
114
+ return $errors;
115
+ }
116
+
117
  //build admin interface
118
  function se_option_page() {
119
  global $wpdb, $table_prefix, $wp_version;
120
+
121
+ if($_POST) {
122
+ check_admin_referer('se-everything-nonce');
123
+ $errors = $this->se_validation(array(
124
+ "highlight_color" => "color",
125
+ "highlight_style" => "css",
126
+ "exclude_categories_list" => "numeric-comma",
127
+ "exclude_posts_list" => "numeric-comma"
128
+ ));
129
+ if ($errors) {
130
+ $fields = array(
131
+ "highlight_color" => __('Highlight Background Color', 'SearchEverything'),
132
+ "highlight_style" => __('Full Highlight Style','SearchEverything'),
133
+ "exclude_categories_list" => __('Exclude Categories','SearchEverything'),
134
+ "exclude_posts_list" => __('Exclude some post or page IDs','SearchEverything')
135
+ );
136
+ include(se_get_view('options_page_errors'));
137
+ return;
138
+ }
139
+ }
140
+
141
  $new_options = array(
142
  'se_exclude_categories' => (isset($_POST['exclude_categories']) && !empty($_POST['exclude_categories'])) ? $_POST['exclude_categories'] : '',
143
  'se_exclude_categories_list' => (isset($_POST['exclude_categories_list']) && !empty($_POST['exclude_categories_list'])) ? $_POST['exclude_categories_list'] : '',
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: 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: 3.9
6
- Stable tag: 8.1
7
 
8
  Search Everything increases WordPress' default search functionality in three easy steps.
9
 
@@ -107,6 +107,10 @@ Note: We changed some labels in settings, old translations might not work and ne
107
 
108
  == Changelog ==
109
 
 
 
 
 
110
  = 8.1 =
111
  * Fixed link search bug
112
  * Fixed bug of limiting number of results in Research Everything
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: 3.9
6
+ Stable tag: 8.1.1
7
 
8
  Search Everything increases WordPress' default search functionality in three easy steps.
9
 
107
 
108
  == Changelog ==
109
 
110
+ = 8.1.1 =
111
+ * Security update (CSRF vunerability fix)
112
+ * Added form validation to Options page
113
+
114
  = 8.1 =
115
  * Fixed link search bug
116
  * Fixed bug of limiting number of results in Research Everything
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
7
  Author: Zemanta
8
  Author URI: http://www.zemanta.com
9
  */
10
 
11
- define('SE_VERSION', '8.1');
12
 
13
  if (!defined('SE_PLUGIN_FILE'))
14
  define('SE_PLUGIN_FILE', plugin_basename(__FILE__));
@@ -675,7 +675,11 @@ class SearchEverything {
675
  if ( !empty( $this->query_instance->query_vars['s'] ) ) {
676
  $excludedPostList = trim( $this->options['se_exclude_posts_list'] );
677
  if ( $excludedPostList != '' ) {
678
- $excl_list = implode( ',', explode( ',', $excludedPostList ) );
 
 
 
 
679
  $excludeQuery = ' AND ('.$wpdb->posts.'.ID NOT IN ( '.$excl_list.' ))';
680
  }
681
  $this->se_log( "ex posts where: ".$excludeQuery );
@@ -690,7 +694,11 @@ class SearchEverything {
690
  if ( !empty( $this->query_instance->query_vars['s'] ) ) {
691
  $excludedCatList = trim( $this->options['se_exclude_categories_list'] );
692
  if ( $excludedCatList != '' ) {
693
- $excl_list = implode( ',', explode( ',', $excludedCatList ) );
 
 
 
 
694
  if ( $this->wp_ver23 ) {
695
  $excludeQuery = " AND ( ctax.term_id NOT IN ( ".$excl_list." ))";
696
  }
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.1
7
  Author: Zemanta
8
  Author URI: http://www.zemanta.com
9
  */
10
 
11
+ define('SE_VERSION', '8.1.1');
12
 
13
  if (!defined('SE_PLUGIN_FILE'))
14
  define('SE_PLUGIN_FILE', plugin_basename(__FILE__));
675
  if ( !empty( $this->query_instance->query_vars['s'] ) ) {
676
  $excludedPostList = trim( $this->options['se_exclude_posts_list'] );
677
  if ( $excludedPostList != '' ) {
678
+ $excluded_post_list = array();
679
+ foreach(explode( ',', $excludedPostList ) as $post_id) {
680
+ $excluded_post_list[] = (int)$post_id;
681
+ }
682
+ $excl_list = implode( ',', $excluded_post_list);
683
  $excludeQuery = ' AND ('.$wpdb->posts.'.ID NOT IN ( '.$excl_list.' ))';
684
  }
685
  $this->se_log( "ex posts where: ".$excludeQuery );
694
  if ( !empty( $this->query_instance->query_vars['s'] ) ) {
695
  $excludedCatList = trim( $this->options['se_exclude_categories_list'] );
696
  if ( $excludedCatList != '' ) {
697
+ $excluded_cat_list = array();
698
+ foreach(explode( ',', $excludedCatList ) as $cat_id) {
699
+ $excluded_cat_list[] = (int)$cat_id;
700
+ }
701
+ $excl_list = implode( ',', $excluded_cat_list);
702
  if ( $this->wp_ver23 ) {
703
  $excludeQuery = " AND ( ctax.term_id NOT IN ( ".$excl_list." ))";
704
  }
static/css/admin.css CHANGED
@@ -37,3 +37,10 @@ p span.se-thank-you {font-size: large; font-weight: bold;}
37
  #wpwrap #wpcontent .se-updated .se-logo img {width: 90px;}
38
  #se-research-settings small, #se-basic-settings small, #se-advanced-settings small, #se-test-search small, #se-info small {font-size: 11px;}
39
 
 
 
 
 
 
 
 
37
  #wpwrap #wpcontent .se-updated .se-logo img {width: 90px;}
38
  #se-research-settings small, #se-basic-settings small, #se-advanced-settings small, #se-test-search small, #se-info small {font-size: 11px;}
39
 
40
+ div.error.se-error-box {
41
+ margin: 5px 15px 2px 2px;
42
+ }
43
+ div.error.se-error-box ul {
44
+ list-style-type: disc;
45
+ padding-left: 20px;
46
+ }
static/img/search.png CHANGED
Binary file
static/img/zem-logo.png CHANGED
Binary file
static/js/searcheverything.js CHANGED
@@ -1,268 +1,14 @@
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
- });
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()})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/options_page.php CHANGED
@@ -6,6 +6,7 @@
6
  On this page you can customize each of these two features.','SearchEverything') ?></p>
7
  </div>
8
  <form method="post">
 
9
  <table id="se-research-settings" class="widefat">
10
  <tr class="title">
11
  <th scope="col" class="manage-column se-col"><?php _e('Research Everything compose-screen widget', 'SearchEverything'); ?></th>
@@ -15,7 +16,7 @@
15
  <td><input type="checkbox" id="research_metabox" name="research_metabox" value="yes" <?php checked($options['se_research_metabox']['visible_on_compose']); ?> /></td>
16
  </tr>
17
  <tr scope="row"><td><?php _e('Enable search results from the web on compose screen','SearchEverything')?><br>
18
- <small>(This will help you research similar posts. <a href="http://www.zemanta.com/blog/research-everything/" target="_blank">Learn more.</a>)</small></td>
19
  <td><input type="checkbox" id="research_external_results" name="research_external_results" value="yes" <?php checked($options['se_research_metabox']['external_search_enabled']); ?> /><span class="se-zem-color">&lArr; Try me. ;)</span></td>
20
  </tr>
21
  <tr scope="row"><td><?php _e('Zemanta api key','SearchEverything')?><br>
6
  On this page you can customize each of these two features.','SearchEverything') ?></p>
7
  </div>
8
  <form method="post">
9
+ <?php wp_nonce_field('se-everything-nonce'); ?>
10
  <table id="se-research-settings" class="widefat">
11
  <tr class="title">
12
  <th scope="col" class="manage-column se-col"><?php _e('Research Everything compose-screen widget', 'SearchEverything'); ?></th>
16
  <td><input type="checkbox" id="research_metabox" name="research_metabox" value="yes" <?php checked($options['se_research_metabox']['visible_on_compose']); ?> /></td>
17
  </tr>
18
  <tr scope="row"><td><?php _e('Enable search results from the web on compose screen','SearchEverything')?><br>
19
+ <small>(This will help you research similar posts. <a href="http://zem.si/1l7q5KS" target="_blank">Learn more.</a>)</small></td>
20
  <td><input type="checkbox" id="research_external_results" name="research_external_results" value="yes" <?php checked($options['se_research_metabox']['external_search_enabled']); ?> /><span class="se-zem-color">&lArr; Try me. ;)</span></td>
21
  </tr>
22
  <tr scope="row"><td><?php _e('Zemanta api key','SearchEverything')?><br>
views/options_page_errors.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="error se-error-box">
2
+ <p>
3
+ Oops, there are errors in your submit:
4
+ <ul>
5
+ <?php foreach($errors as $field => $message): ?>
6
+ <li><?php echo sprintf($message, $fields[$field]); ?></li>
7
+ <?php endforeach; ?>
8
+ </ul>
9
+ </p>
10
+ <p>Please go <a href="#" class="se-back">back</a> and check your settings again.</p>
11
+ </div>