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
← All changes | includes/blocks/class-convertkit-block-form.php +39 -9 3.3.33.4.4 View file →
@@ -26,8 +26,11 @@
26 26
27 27 // Register this as a Gutenberg block in the ConvertKit Plugin.
28 28 add_filter( 'convertkit_blocks', array( $this, 'register' ) );
29 29
30 + // Register this block's MCP abilities.
31 + add_filter( 'convertkit_abilities', array( $this, 'register_abilities' ) );
32 +
30 33 // Enqueue scripts for this Gutenberg Block in the editor view.
31 34 add_action( 'convertkit_gutenberg_enqueue_scripts', array( $this, 'enqueue_scripts_editor' ) );
32 35
33 36 // Enqueue styles for this Gutenberg Block in the editor view.
@@ -82,9 +85,11 @@
82 85
83 86 /**
84 87 * This will register as:
85 88 * - a shortcode, with the name [convertkit_form].
89 + * - a shortcode, with the name [kit_form].
86 90 * - a shortcode, with the name [convertkit], for backward compat.
91 + * - a shortcode, with the name [kit].
87 92 * - a Gutenberg block, with the name convertkit/form.
88 93 */
89 94 return 'form';
90 95
@@ -101,8 +106,21 @@
101 106
102 107 }
103 108
104 109 /**
110 + * Returns this block's plural title.
111 + *
112 + * @since 3.4.0
113 + *
114 + * @return string
115 + */
116 + public function get_title_plural() {
117 +
118 + return __( 'Kit Forms', 'convertkit' );
119 +
120 + }
121 +
122 + /**
105 123 * Returns this block's icon.
106 124 *
107 125 * @since 3.1.1
108 126 */
@@ -261,32 +279,44 @@
261 279 * @return bool|array
262 280 */
263 281 public function get_fields() {
264 282
265 - // Get ConvertKit Forms.
283 + // Get ConvertKit Forms. Non-legacy forms populate the sidebar dropdown;
284 + // legacy forms are exposed separately as a fallback so the sidebar can
285 + // keep displaying a previously-saved legacy form as the current
286 + // selection without offering other legacy forms as new choices.
266 287 $forms = array();
288 + $legacy_forms = array();
267 289 $convertkit_forms = new ConvertKit_Resource_Forms( 'block_edit' );
268 290 if ( $convertkit_forms->exist() ) {
269 291 foreach ( $convertkit_forms->get() as $form ) {
270 - // Legacy forms don't include a `format` key, so define them as inline.
271 - $forms[ absint( $form['id'] ) ] = sprintf(
292 + $label = sprintf(
272 293 '%s [%s]',
273 294 sanitize_text_field( $form['name'] ),
295 + // Legacy forms don't include a `format` key, so define them as inline.
274 296 ( ! empty( $form['format'] ) ? sanitize_text_field( $form['format'] ) : 'inline' )
275 297 );
298 +
299 + if ( ! empty( $form['format'] ) ) {
300 + $forms[ absint( $form['id'] ) ] = $label;
301 + } else {
302 + $legacy_forms[ absint( $form['id'] ) ] = $label;
303 + }
276 304 }
277 305 }
278 306
279 307 return array(
280 308 'form' => array(
281 - 'label' => __( 'Form', 'convertkit' ),
282 - 'type' => 'resource',
283 - 'resource' => 'forms',
284 - 'values' => $forms,
285 - 'data' => array(
309 + 'label' => __( 'Form', 'convertkit' ),
310 + 'type' => 'resource',
311 + 'resource' => 'forms',
312 + 'values' => $forms,
313 + 'legacy_values' => $legacy_forms,
314 + 'data' => array(
286 315 // Used by resources/backend/js/gutenberg-block-form.js to determine the selected form's format
287 316 // (modal, slide in, sticky bar) and output a message in the block editor for the preview to explain
288 - // why some formats cannot be previewed.
317 + // why some formats cannot be previewed. Includes legacy forms so the preview code can still find
318 + // them when a saved block references a legacy form.
289 319 'forms' => ( $convertkit_forms->exist() ? $convertkit_forms->get() : array() ),
290 320 ),
291 321 ),
292 322 );