Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed Nov 6, 2024
1 parent da2b451 commit 5384b01
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions assets/js/search/editor/index.js
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,
});
33 changes: 33 additions & 0 deletions assets/js/search/editor/plugins/exclude-from-search.js
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>
);
};

0 comments on commit 5384b01

Please sign in to comment.