| 1 |
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
import { |
| 4 |
ToggleControl, |
| 5 |
PanelBody, |
| 6 |
} from '@wordpress/components'; |
| 7 |
import { useSelect, useDispatch } from '@wordpress/data'; |
| 8 |
import solidIcon from './icon'; |
| 9 |
|
| 10 |
const SolidExcludeMeta = () => { |
| 11 |
const meta = useSelect((select) => select('core/editor').getEditedPostAttribute('meta')); |
| 12 |
const { editPost } = useDispatch('core/editor'); |
| 13 |
|
| 14 |
if ( meta === undefined ) { |
| 15 |
return null; |
| 16 |
} |
| 17 |
|
| 18 |
return ( |
| 19 |
<> |
| 20 |
<PluginSidebarMoreMenuItem |
| 21 |
target="swpsp-cache" |
| 22 |
icon={ solidIcon } |
| 23 |
> |
| 24 |
{ __( 'Cache Exclusion', 'solid-performance' ) } |
| 25 |
</PluginSidebarMoreMenuItem> |
| 26 |
<PluginSidebar |
| 27 |
isPinnable={ false } |
| 28 |
icon={ solidIcon } |
| 29 |
name="swpsp-cache" |
| 30 |
title={ __( 'Cache Exclusion', 'solid-performance' ) } |
| 31 |
> |
| 32 |
<PanelBody> |
| 33 |
<ToggleControl |
| 34 |
label={ __( 'Exclude from Page Cache', 'solid-performance' ) } |
| 35 |
checked={meta._swpsp_post_exclude} |
| 36 |
onChange={(value) => editPost({ meta: { _swpsp_post_exclude: value } })} |
| 37 |
/> |
| 38 |
</PanelBody> |
| 39 |
</PluginSidebar> |
| 40 |
</> |
| 41 |
); |
| 42 |
}; |
| 43 |
export default SolidExcludeMeta; |
| 44 |
|