PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.4
3.4.4 3.4.3 3.4.2 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 All 197 releases
convertkit / resources / backend / js / legacy-resource-notice.js

legacy-resource-notice.js in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.4, at resources/backend/js/legacy-resource-notice.js

48 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Renders a non-dismissible warning notice inside Gutenberg
3 * when a post/page references a legacy Kit resource.
4 *
5 * @author ConvertKit
6 * @since 3.3.7
7 */
8
9 document.addEventListener('DOMContentLoaded', function () {
10 // Bail if the notice data is not available.
11 if (typeof convertkit_legacy_resource_notice === 'undefined') {
12 return;
13 }
14
15 // Bail if no warnings are found.
16 if (
17 typeof convertkit_legacy_resource_notice.warnings === 'undefined' ||
18 convertkit_legacy_resource_notice.warnings.length === 0
19 ) {
20 return;
21 }
22
23 // Bail if Gutenberg is not available.
24 if (
25 typeof wp === 'undefined' ||
26 typeof wp.data === 'undefined' ||
27 typeof wp.data.dispatch !== 'function'
28 ) {
29 return;
30 }
31
32 // Build the notice.
33 // Gutenberg's Notice component renders `message` as plain text with
34 // `white-space: normal`, so `\n` collapses to a space and any leading
35 // `- ` dashes look odd. Inline the items with `; ` separators instead —
36 // this reads naturally on the single line the component actually renders.
37 const message =
38 convertkit_legacy_resource_notice.intro +
39 ' ' +
40 convertkit_legacy_resource_notice.warnings.join('; ');
41
42 // Create the notice.
43 wp.data.dispatch('core/notices').createWarningNotice(message, {
44 id: convertkit_legacy_resource_notice.id,
45 isDismissible: false,
46 });
47 });
48