PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / extend / attributes / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/extend/attributes/index.js

87 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { InspectorControls } from '@wordpress/block-editor';
2 import { hasBlockSupport } from '@wordpress/blocks';
3 import { addFilter } from '@wordpress/hooks';
4 import { __ } from '@wordpress/i18n';
5
6 import ApplyFilters from '../../components/apply-filters';
7 import ProNote from '../../components/pro-note';
8
9 const { pro } = window.GHOSTKIT;
10
11 const { version } = window.ghostkitVariables;
12
13 /**
14 * Add inspector controls.
15 *
16 * @param original
17 * @param root0
18 * @param root0.props
19 */
20 function GhostKitExtensionAttributesInspector(original, { props }) {
21 const { name } = props;
22
23 const hasAttributesSupport = hasBlockSupport(name, [
24 'ghostkit',
25 'attributes',
26 ]);
27
28 if (!hasAttributesSupport) {
29 return original;
30 }
31
32 return (
33 <>
34 {original}
35 <InspectorControls group="advanced">
36 <ApplyFilters
37 name="ghostkit.extension.attributes.controls"
38 props={props}
39 />
40 </InspectorControls>
41 </>
42 );
43 }
44
45 function ProAttributesControls() {
46 return (
47 <ProNote title={__('Attributes', 'ghostkit')}>
48 <p>
49 {__(
50 'Adding custom attributes to block available in the Ghost Kit Pro plugin only.',
51 'ghostkit'
52 )}
53 </p>
54 <ProNote.Button
55 target="_blank"
56 rel="noopener noreferrer"
57 href={`https://www.ghostkit.io/docs/extensions/attributes/?utm_source=plugin&utm_medium=block_settings&utm_campaign=pro_attributes&utm_content=${version}`}
58 >
59 {__('Read More', 'ghostkit')}
60 </ProNote.Button>
61 </ProNote>
62 );
63 }
64
65 // Init filters.
66 addFilter(
67 'ghostkit.editor.extensions',
68 'ghostkit/extension/attributes/inspector',
69 GhostKitExtensionAttributesInspector
70 );
71 addFilter(
72 'ghostkit.extension.attributes.controls',
73 'ghostkit/extension/attributes/controls',
74 (children, { props }) => {
75 if (pro) {
76 return children;
77 }
78
79 return (
80 <>
81 {children}
82 <ProAttributesControls {...props} />
83 </>
84 );
85 }
86 );
87