PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 2.0.1
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v2.0.1
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
powered-cache / assets / js / admin / metabox.js

metabox.js in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 2.0.1, at assets/js/admin/metabox.js

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const { __ } = wp.i18n;
2 const { PluginDocumentSettingPanel } = wp.editPost;
3 const { CheckboxControl } = wp.components;
4 const { dispatch, useSelect } = wp.data;
5 const { registerPlugin } = wp.plugins;
6
7 /**
8 * PoweredCacheMetaBox
9 *
10 * @return PluginDocumentSettingPanel
11 */
12 const PoweredCacheMetaBox = () => {
13 const meta = useSelect((select) => select('core/editor').getEditedPostAttribute('meta'));
14 const disableCache = meta.powered_cache_disable_cache || false;
15 const disableLazyLoad = meta.powered_cache_disable_lazyload || false;
16
17 if (!('powered_cache_disable_cache' in meta) && !('powered_cache_disable_lazyload' in meta)) {
18 return null; // nothing to control
19 }
20
21 return (
22 <PluginDocumentSettingPanel
23 icon="superhero"
24 title={__('Powered Cache', 'powered-cache')}
25 className="powered-cache-panel"
26 >
27 {'powered_cache_disable_cache' in meta && (
28 <CheckboxControl
29 label={__("Don't cache this post", 'powered-cache')}
30 checked={disableCache}
31 onChange={() => {
32 dispatch('core/editor').editPost({
33 meta: { powered_cache_disable_cache: !disableCache },
34 });
35 }}
36 />
37 )}
38
39 {'powered_cache_disable_lazyload' in meta && (
40 <CheckboxControl
41 label={__('Disable lazy loading for this post', 'powered-cache')}
42 checked={disableLazyLoad}
43 onChange={() => {
44 dispatch('core/editor').editPost({
45 meta: { powered_cache_disable_lazyload: !disableLazyLoad },
46 });
47 }}
48 />
49 )}
50 </PluginDocumentSettingPanel>
51 );
52 };
53
54 registerPlugin('powered-cache-post-meta', { render: PoweredCacheMetaBox });
55