PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.5.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.5.0
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / resources / backend / js / gutenberg-block-product.js

gutenberg-block-product.js in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 2.5.0, at resources/backend/js/gutenberg-block-product.js

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Product Block specific functions for Gutenberg.
3 *
4 * @since 1.9.6.5
5 *
6 * @package ConvertKit
7 * @author ConvertKit
8 */
9
10 /**
11 * Custom callback function to render the ConvertKit Product Block preview in the Gutenberg Editor.
12 *
13 * @since 1.9.8.5
14 */
15 function convertKitGutenbergProductBlockRenderPreview( block, props ) {
16
17 // If no API Key has been defined in the Plugin, return a prompt to tell the editor
18 // what to do.
19 if ( ! block.has_access_token ) {
20 return convertKitGutenbergDisplayBlockNoticeWithLink(
21 block.name,
22 block.no_access_token.notice,
23 block.no_access_token.link,
24 block.no_access_token.link_text
25 );
26 }
27
28 // If no Products exist in ConvertKit, return a prompt to tell the editor
29 // what to do.
30 if ( ! block.has_resources ) {
31 return convertKitGutenbergDisplayBlockNoticeWithLink(
32 block.name,
33 block.no_resources.notice,
34 block.no_resources.link,
35 block.no_resources.link_text
36 );
37 }
38
39 // If no Product has been selected for display, return a prompt to tell the editor
40 // what to do.
41 if ( props.attributes.product === '' ) {
42 return convertKitGutenbergDisplayBlockNotice( block.name, block.gutenberg_help_description );
43 }
44
45 // A Product is specified.
46 // Use the block's PHP's render() function by calling the ServerSideRender component.
47 return wp.element.createElement(
48 wp.serverSideRender,
49 {
50 block: 'convertkit/' + block.name,
51 attributes: props.attributes,
52
53 // This is only output in the Gutenberg editor, so must be slightly different from the inner class name used to
54 // apply styles with i.e. convertkit-block.name.
55 className: 'convertkit-ssr-' + block.name,
56 }
57 );
58
59 }
60