diff --git a/assets/js/search/editor/plugins/exclude-from-search.js b/assets/js/search/editor/plugins/exclude-from-search.js index c1c65280b5..eaf7bf4037 100644 --- a/assets/js/search/editor/plugins/exclude-from-search.js +++ b/assets/js/search/editor/plugins/exclude-from-search.js @@ -9,8 +9,8 @@ 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 { ep_exclude_from_search = false, ...meta } = useSelect( + (select) => select('core/editor').getEditedPostAttribute('meta') || {}, ); const onChange = (ep_exclude_from_search) => { diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index fd5db13975..a5fb672760 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -689,6 +689,12 @@ public function register_meta() { * Enqueue block editor assets. */ public function enqueue_block_editor_assets() { + global $post; + + if ( ! $post instanceof \WP_Post ) { + return; + } + wp_enqueue_script( 'ep-search-editor', EP_URL . '/dist/js/search-editor-script.js',