Skip to content

Commit

Permalink
Merge pull request #4008 from 10up/fix/issue-3995
Browse files Browse the repository at this point in the history
Use the correct version of PluginPostStatusInfo depending on the WP version
  • Loading branch information
felipeelia authored Nov 22, 2024
2 parents 53990f8 + 894644b commit 32a6890
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions assets/js/search/editor/plugins/exclude-from-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 (
<PluginPostStatusInfo>
<WrapperElement>
<CheckboxControl
label={__('Exclude from search results', 'elasticpress')}
help={__(
Expand All @@ -27,7 +38,8 @@ export default () => {
)}
checked={ep_exclude_from_search}
onChange={onChange}
{...marginBottomProp}
/>
</PluginPostStatusInfo>
</WrapperElement>
);
};

0 comments on commit 32a6890

Please sign in to comment.