Skip to content

Commit

Permalink
Sync Github repo with WordPress SVN plugin directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pronskiy committed Apr 16, 2016
1 parent 74176ca commit 154587e
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 39 deletions.
73 changes: 73 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,85 @@ WordPress Search Exclude
=================

Search Exclude – WordPress plugin that lets you hide any page, post or whatever from the search results. Just check off the corresponding checkbox on post/page edit page.
Supports quick and bulk edit.

You can also view the list of all the items that are excluded from search on the plugin settings page.

### Installation

1. Upload `search-exclude` directory to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to any post/page edit page and check off the checkbox `Exclude from Search Results` if you don't want the post/page to be shown in the search results

### Frequently Asked Questions

#### Does this plugin affect SEO?

No, it does not affect crawling and indexing by search engines.
The only thing it does is hiding selected post/pages from your site search page. Not altering SEO indexing.

#### Are there any hooks or actions available to customize plugin behaviour?

Yes.
There is an action `searchexclude_hide_from_search`.
You can pass any post/page/custom_post ids as an array in the first parameter.
The second parameter specifies state of visibility in search. Pass true if you want to hide posts/pages,
or false - if you want show them in the search results.

Example:
Let's say you want "Exclude from Search Results" checkbox to be checked off by default
for newly created posts, but not pages. In this case you can add following code
to your theme's function.php:

```php
add_filter('default_content', 'excludeNewPostByDefault', 10, 2);
function excludeNewPostByDefault($content, $post)
{
if ('post' === $post->post_type) {
do_action('searchexclude_hide_from_search', array($post->ID), true);
}
}
```

Also there is a filter `searchexclude_filter_search`.
With this filter you can turn on/off search filtering dynamically.
Parameters:
$exclude - current search filtering state (specifies whether to filter search or not)
$query - current WP_Query object

By returning true or false you can turn search filtering respectively.

Example:
Let's say you need to disable search filtering if searching by specific post_type.
In this case you could add following code to you functions.php:
```php
add_filter('searchexclude_filter_search', 'filterForProducts', 10, 2);
function filterForProducts($exclude, $query)
{
return $exclude && 'product' !== $query->get('post_type');
}
```

### Changelog

#### 1.2.2
* Added action searchexclude_hide_from_search
* Added filter searchexclude_filter_search
* Fixed Bulk actions for Firefox

#### 1.2.1
* Fixed bug when unable to save post on PHP <5.5 because of boolval() usage

#### 1.2.0
* Added quick and bulk edit support
* Tested up to WP 4.1

#### 1.1.0
* 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

#### 1.0.6
* Fixed search filtering for AJAX requests

Expand Down
9 changes: 9 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.fixed .column-search_exclude {
width: 12%;
}
.fixed .column-search_exclude div {
text-align: center;
}
.inline-edit-row fieldset label span.title.search-exclude-label {
width: 11em;
}
52 changes: 52 additions & 0 deletions js/search_exclude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(function($) {

// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;

// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {

// "call" the original WP edit function
// we don't want to leave WordPress hanging
$wp_inline_edit.apply( this, arguments );

var $post_id = 0;
if ( typeof( id ) == 'object' ) {
$post_id = parseInt(this.getId(id));
}

if ( $post_id > 0 ) {
var $edit_row = $( '#edit-' + $post_id );
var $exclude = $( '#search-exclude-' + $post_id).data("search_exclude");
$edit_row.find( 'input[name="sep[exclude]"]' ).prop('checked', $exclude);
}
};

$('#bulk_edit').live( 'click', function() {
// define the bulk edit row
var $bulk_row = $( '#bulk-edit' );

// get the selected post ids that are being edited
var $post_ids = new Array();
$bulk_row.find('#bulk-titles').children().each( function() {
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
});

// get the search exclude value
var $exclude = $bulk_row.find('select[name="sep[exclude]"]').val();

// save the data
$.ajax({
url: ajaxurl,
type: 'POST',
cache: false,
async: false, // Fixes bulk editing in FF, see https://wordpress.org/support/topic/bulk-search-exclude-doesnt-work
data: {
action: 'search_exclude_save_bulk_edit',
post_ids: $post_ids,
sep_exclude: $exclude
}
});
});

})(jQuery);
77 changes: 73 additions & 4 deletions readme.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,101 @@
Contributors: pronskiy, williamdodson, stevelock
Tags: admin, plugin, search
Requires at least: 3.3
Tested up to: 3.9
Stable tag: 1.0.6
Tested up to: 4.5
Stable tag: 1.2.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Hide any post or page from the search results.

== Description ==

With this plugin you can exclude any page, post or whatever from the search results by checking off the corresponding checkbox on post/page edit page.
With this plugin you can exclude any page, post or whatever from the WordPress search results by checking off the corresponding checkbox on post/page edit page.
Supports quick and bulk edit.

You can also view the list of all the items that are excluded from search on the plugin settings page.
On the plugin settings page you can also see the list of all the items that are hidden from search.

== Installation ==

1. Upload `search-exclude` directory to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to any post/page edit page and check off the checkbox `Exclude from Search Results` if you don't want the post/page to be shown in the search results

== Frequently Asked Questions ==

= Does this plugin affect SEO? =

No, it does not affect crawling and indexing by search engines.
The only thing it does is hiding selected post/pages from your site search page. Not altering SEO indexing.

= Are there any hooks or actions available to customize plugin behaviour? =

Yes.
There is an action `searchexclude_hide_from_search`.
You can pass any post/page/custom_post ids as an array in the first parameter.
The second parameter specifies state of visibility in search. Pass true if you want to hide posts/pages,
or false - if you want show them in the search results.

Example:
Let's say you want "Exclude from Search Results" checkbox to be checked off by default
for newly created posts, but not pages. In this case you can add following code
to your theme's function.php:

`
add_filter('default_content', 'excludeNewPostByDefault', 10, 2);
function excludeNewPostByDefault($content, $post)
{
if ('post' === $post->post_type) {
do_action('searchexclude_hide_from_search', array($post->ID), true);
}
}
`

Also there is a filter `searchexclude_filter_search`.
With this filter you can turn on/off search filtering dynamically.
Parameters:
$exclude - current search filtering state (specifies whether to filter search or not)
$query - current WP_Query object

By returning true or false you can turn search filtering respectively.

Example:
Let's say you need to disable search filtering if searching by specific post_type.
In this case you could add following code to you functions.php:
`
add_filter('searchexclude_filter_search', 'filterForProducts', 10, 2);
function filterForProducts($exclude, $query)
{
return $exclude && 'product' !== $query->get('post_type');
}
`

== Screenshots ==

1. screenshot-1.png
2. screenshot-2.png

== Changelog ==

= 1.2.2 =
* Added action searchexclude_hide_from_search
* Added filter searchexclude_filter_search
* Fixed Bulk actions for Firefox

= 1.2.1 =
* Fixed bug when unable to save post on PHP <5.5 because of boolval() usage


= 1.2.0 =
* Added quick and bulk edit support
* Tested up to WP 4.1

= 1.1.0 =
* 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

= 1.0.6 =
* Fixed search filtering for AJAX requests

Expand Down
Loading

0 comments on commit 154587e

Please sign in to comment.