From 2d5e8fd6568cecbf63b893212df950570cc12ae6 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Tue, 19 Nov 2024 09:11:19 -0300 Subject: [PATCH] Use the correct version of PluginPostStatusInfo depending on the WP version --- .../editor/plugins/exclude-from-search.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/assets/js/search/editor/plugins/exclude-from-search.js b/assets/js/search/editor/plugins/exclude-from-search.js index d4e7b8ef12..bf99b258ee 100644 --- a/assets/js/search/editor/plugins/exclude-from-search.js +++ b/assets/js/search/editor/plugins/exclude-from-search.js @@ -3,7 +3,8 @@ */ import { CheckboxControl } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; -import { PluginPostStatusInfo } from '@wordpress/edit-post'; +import { PluginPostStatusInfo as PluginPostStatusInfoLegacy } from '@wordpress/edit-post'; +import { PluginPostStatusInfo } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; export default () => { @@ -17,8 +18,18 @@ export default () => { editPost({ meta: { ...meta, ep_exclude_from_search } }); }; + let WrapperElement = null; + let marginBottomProp = {}; + + if (typeof PluginPostStatusInfo !== 'undefined') { + WrapperElement = PluginPostStatusInfo; + marginBottomProp = { __nextHasNoMarginBottom: true }; + } else { + WrapperElement = PluginPostStatusInfoLegacy; + } + return ( - + { )} checked={ep_exclude_from_search} onChange={onChange} + {...marginBottomProp} /> - + ); };