Search Exclude - Version 1.1.0

Version Description

  • Tested up to WP 4.0
  • Do not show Plugin on some service pages in Admin
  • Fixed conflict with bbPress
  • Fixed deprecation warning when DEBUG is on
Download this release

Release Info

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

Code changes from version 1.0.6 to 1.1.0

Files changed (2) hide show
  1. readme.txt +8 -2
  2. search-exclude.php +33 -6
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: 3.9
6
- Stable tag: 1.0.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -28,6 +28,12 @@ You can also view the list of all the items that are excluded from search on the
28
 
29
  == Changelog ==
30
 
 
 
 
 
 
 
31
  = 1.0.6 =
32
  * Fixed search filtering for AJAX requests
33
 
2
  Contributors: pronskiy, williamdodson, stevelock
3
  Tags: admin, plugin, search
4
  Requires at least: 3.3
5
+ Tested up to: 4.0
6
+ Stable tag: 1.1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
28
 
29
  == Changelog ==
30
 
31
+ = 1.1.0 =
32
+ * Tested up to WP 4.0
33
+ * Do not show Plugin on some service pages in Admin
34
+ * Fixed conflict with bbPress
35
+ * Fixed deprecation warning when DEBUG is on
36
+
37
  = 1.0.6 =
38
  * Fixed search filtering for AJAX requests
39
 
search-exclude.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Search Exclude
4
  Description: Exclude any page or post from the WordPress search results by checking off the checkbox.
5
- Version: 1.0.6
6
  Author: Roman Pronskiy
7
  Author URI: http://pronskiy.com
8
  Plugin URI: http://wordpress.org/plugins/search-exclude/
@@ -41,6 +41,8 @@ class SearchExclude
41
  add_action('edit_attachment', array($this, 'postSave'));
42
  add_action('add_meta_boxes', array($this, 'addMetabox') );
43
  add_filter('pre_get_posts',array($this, 'searchFilter'));
 
 
44
  }
45
 
46
  /**
@@ -94,10 +96,15 @@ class SearchExclude
94
 
95
  public function addMetabox()
96
  {
97
- add_meta_box( 'sep_metabox_id', 'Search Exclude', array($this, 'metabox'), null);
 
 
 
 
 
98
  }
99
 
100
- public function metabox( $post )
101
  {
102
  $excluded = $this->getExcluded();
103
  $exclude = !(false === array_search($post->ID, $excluded));
@@ -111,7 +118,7 @@ class SearchExclude
111
  add_options_page(
112
  'Search Exclude',
113
  'Search Exclude',
114
- 10,
115
  'search_exclude',
116
  array($this, 'options')
117
  );
@@ -119,12 +126,32 @@ class SearchExclude
119
 
120
  public function searchFilter($query)
121
  {
122
- if ((!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && $query->is_search) {
123
- $query->set('post__not_in', array_merge($query->get('post__not_in'), $this->getExcluded()));
124
  }
125
  return $query;
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  public function postSave( $post_id )
129
  {
130
  if (!isset($_POST['sep'])) return $post_id;
2
  /*
3
  Plugin Name: Search Exclude
4
  Description: Exclude any page or post from the WordPress search results by checking off the checkbox.
5
+ Version: 1.1.0
6
  Author: Roman Pronskiy
7
  Author URI: http://pronskiy.com
8
  Plugin URI: http://wordpress.org/plugins/search-exclude/
41
  add_action('edit_attachment', array($this, 'postSave'));
42
  add_action('add_meta_boxes', array($this, 'addMetabox') );
43
  add_filter('pre_get_posts',array($this, 'searchFilter'));
44
+
45
+ add_filter('bbp_has_replies_query', array($this, 'flagBbPress'));
46
  }
47
 
48
  /**
96
 
97
  public function addMetabox()
98
  {
99
+ $currentScreen = get_current_screen();
100
+ /* Do not show meta box on service pages */
101
+ if (empty($currentScreen->post_type)) {
102
+ return;
103
+ }
104
+ add_meta_box( 'sep_metabox_id', 'Search Exclude', array($this, 'metabox'), null, 'side');
105
  }
106
 
107
+ public function metabox($post)
108
  {
109
  $excluded = $this->getExcluded();
110
  $exclude = !(false === array_search($post->ID, $excluded));
118
  add_options_page(
119
  'Search Exclude',
120
  'Search Exclude',
121
+ 'manage_options',
122
  'search_exclude',
123
  array($this, 'options')
124
  );
126
 
127
  public function searchFilter($query)
128
  {
129
+ if ((!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && $query->is_search && !$this->isBbPress($query)) {
130
+ $query->set('post__not_in', array_merge(array(), $this->getExcluded()));
131
  }
132
  return $query;
133
  }
134
 
135
+ public function isBbPress($query)
136
+ {
137
+ return $query->get('___s2_is_bbp_has_replies');
138
+ }
139
+
140
+ /**
141
+ * Flags a WP Query has being a `bbp_has_replies()` query.
142
+ * @attaches-to ``add_filter('bbp_has_replies_query');``
143
+ *
144
+ * @param array $args Query arguments passed by the filter.
145
+ *
146
+ * @return array The array of ``$args``.
147
+ *
148
+ * @see Workaround for bbPress and the `s` key. See: <http://bit.ly/1obLpv4>
149
+ */
150
+ public function flagBbPress($args)
151
+ {
152
+ return array_merge($args, array('___s2_is_bbp_has_replies' => true));
153
+ }
154
+
155
  public function postSave( $post_id )
156
  {
157
  if (!isset($_POST['sep'])) return $post_id;