Search Exclude - Version 1.2.4

Version Description

  • Security release. All users are encouraged to update.
  • Added filter searchexclude_filter_permissions.
Download this release

Release Info

Developer pronskiy
Plugin Icon 128x128 Search Exclude
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

Files changed (2) hide show
  1. readme.txt +4 -3
  2. search-exclude.php +12 -4
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: pronskiy, williamdodson, stevelock
3
  Tags: admin, plugin, search
4
  Requires at least: 3.3
5
- Tested up to: 5.2
6
- Stable tag: 1.2.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -78,8 +78,9 @@ function filterForProducts($exclude, $query)
78
 
79
  == Changelog ==
80
 
81
- = 1.2.3 =
82
  * Security release. All users are encouraged to update.
 
83
 
84
  = 1.2.2 =
85
  * Added action searchexclude_hide_from_search
2
  Contributors: pronskiy, williamdodson, stevelock
3
  Tags: admin, plugin, search
4
  Requires at least: 3.3
5
+ Tested up to: 5.3
6
+ Stable tag: 1.2.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
78
 
79
  == Changelog ==
80
 
81
+ = 1.2.4 =
82
  * Security release. All users are encouraged to update.
83
+ * Added filter searchexclude_filter_permissions.
84
 
85
  = 1.2.2 =
86
  * Added action searchexclude_hide_from_search
search-exclude.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Search Exclude
4
  Description: Hide any page or post from the WordPress search results by checking off the checkbox.
5
- Version: 1.2.2
6
  Author: Roman Pronskiy
7
  Author URI: http://pronskiy.com
8
  Plugin URI: http://wordpress.org/plugins/search-exclude/
@@ -140,6 +140,7 @@ class SearchExclude
140
 
141
  public function saveBulkEdit()
142
  {
 
143
  $postIds = !empty($_POST['post_ids']) ? $this->filterPostIds($_POST[ 'post_ids' ]) : false;
144
  $exclude = isset($_POST['sep_exclude']) && '' !== $_POST['sep_exclude']
145
  ? filter_var($_POST['sep_exclude'], FILTER_VALIDATE_BOOLEAN)
@@ -309,12 +310,19 @@ class SearchExclude
309
 
310
  check_admin_referer( 'search_exclude_submit' );
311
 
312
- if ( !current_user_can('edit_others_pages') ) {
313
- wp_die( 'Not enough permissions', '', ['response' => 401, 'exit' => true] );
314
- }
315
 
316
  $excluded = $this->filterPostIds($_POST['sep_exclude']);
317
  $this->saveExcluded($excluded);
318
  }
 
 
 
 
 
 
 
 
 
319
  }
320
  $pluginSearchExclude = new SearchExclude();
2
  /*
3
  Plugin Name: Search Exclude
4
  Description: Hide any page or post from the WordPress search results by checking off the checkbox.
5
+ Version: 1.2.4
6
  Author: Roman Pronskiy
7
  Author URI: http://pronskiy.com
8
  Plugin URI: http://wordpress.org/plugins/search-exclude/
140
 
141
  public function saveBulkEdit()
142
  {
143
+ $this->checkPermissions();
144
  $postIds = !empty($_POST['post_ids']) ? $this->filterPostIds($_POST[ 'post_ids' ]) : false;
145
  $exclude = isset($_POST['sep_exclude']) && '' !== $_POST['sep_exclude']
146
  ? filter_var($_POST['sep_exclude'], FILTER_VALIDATE_BOOLEAN)
310
 
311
  check_admin_referer( 'search_exclude_submit' );
312
 
313
+ $this->checkPermissions();
 
 
314
 
315
  $excluded = $this->filterPostIds($_POST['sep_exclude']);
316
  $this->saveExcluded($excluded);
317
  }
318
+
319
+ private function checkPermissions()
320
+ {
321
+ $capability = apply_filters('searchexclude_filter_permissions', 'edit_others_pages');
322
+
323
+ if ( !current_user_can($capability) ) {
324
+ wp_die( 'Not enough permissions', '', ['response' => 401, 'exit' => true] );
325
+ }
326
+ }
327
  }
328
  $pluginSearchExclude = new SearchExclude();