forked from 10up/ElasticPress
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da2b451
commit 5384b01
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* WordPress dependencies. | ||
*/ | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import ExcludeFromSearch from './plugins/exclude-from-search'; | ||
|
||
registerPlugin('ep-exclude-from-search', { | ||
render: ExcludeFromSearch, | ||
icon: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* WordPress dependencies. | ||
*/ | ||
import { CheckboxControl } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { PluginPostStatusInfo } from '@wordpress/edit-post'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export default () => { | ||
const { editPost } = useDispatch('core/editor'); | ||
|
||
const { ep_exclude_from_search = false, ...meta } = useSelect( | ||
(select) => select('core/editor').getEditedPostAttribute('meta') || {}, | ||
); | ||
|
||
const onChange = (ep_exclude_from_search) => { | ||
editPost({ meta: { ...meta, ep_exclude_from_search } }); | ||
}; | ||
|
||
return ( | ||
<PluginPostStatusInfo> | ||
<CheckboxControl | ||
label={__('Exclude from search results', 'elasticpress')} | ||
help={__( | ||
"Excludes this post from the results of your site's search form while Enterprise Search is active.", | ||
'elasticpress', | ||
)} | ||
checked={ep_exclude_from_search} | ||
onChange={onChange} | ||
/> | ||
</PluginPostStatusInfo> | ||
); | ||
}; |