From 73efde7df536c9f982f1597a7e66b0a827092b14 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 18:06:21 +0800 Subject: [PATCH 1/6] Block Registration: Improve Performance --- .../blocks/class-convertkit-block-broadcasts.php | 10 ---------- includes/blocks/class-convertkit-block-content.php | 10 ---------- ...s-convertkit-block-form-builder-field-custom.php | 10 ---------- ...ss-convertkit-block-form-builder-field-email.php | 5 ----- .../class-convertkit-block-form-builder-field.php | 10 ---------- .../blocks/class-convertkit-block-form-builder.php | 10 ---------- .../blocks/class-convertkit-block-form-trigger.php | 10 ---------- includes/blocks/class-convertkit-block-form.php | 10 ---------- includes/blocks/class-convertkit-block-product.php | 10 ---------- includes/blocks/class-convertkit-block.php | 13 +++++++++++++ 10 files changed, 13 insertions(+), 85 deletions(-) diff --git a/includes/blocks/class-convertkit-block-broadcasts.php b/includes/blocks/class-convertkit-block-broadcasts.php index 8464a153b..12ecb1923 100644 --- a/includes/blocks/class-convertkit-block-broadcasts.php +++ b/includes/blocks/class-convertkit-block-broadcasts.php @@ -272,11 +272,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'display_grid' => array( 'label' => __( 'Display as grid', 'convertkit' ), @@ -380,11 +375,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'general' => array( 'label' => __( 'General', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-content.php b/includes/blocks/class-convertkit-block-content.php index 7f16f4b62..f1aef2391 100644 --- a/includes/blocks/class-convertkit-block-content.php +++ b/includes/blocks/class-convertkit-block-content.php @@ -104,11 +104,6 @@ public function get_attributes() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get ConvertKit Tags. $tags = array(); $convertkit_tags = new ConvertKit_Resource_Tags(); @@ -137,11 +132,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'general' => array( 'label' => __( 'General', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder-field-custom.php b/includes/blocks/class-convertkit-block-form-builder-field-custom.php index 0df3c5472..0aceefca9 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field-custom.php +++ b/includes/blocks/class-convertkit-block-form-builder-field-custom.php @@ -101,11 +101,6 @@ public function get_attributes() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get Kit Custom Fields. $custom_fields = new ConvertKit_Resource_Custom_Fields( 'block_form_builder' ); $values = array(); @@ -150,11 +145,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get Panels from parent class. $panels = parent::get_panels(); diff --git a/includes/blocks/class-convertkit-block-form-builder-field-email.php b/includes/blocks/class-convertkit-block-form-builder-field-email.php index 71e02e8a7..c509a41b6 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field-email.php +++ b/includes/blocks/class-convertkit-block-form-builder-field-email.php @@ -120,11 +120,6 @@ public function get_attributes() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // The `required` field is not used for this block, // as we always require an email address. $fields = parent::get_fields(); diff --git a/includes/blocks/class-convertkit-block-form-builder-field.php b/includes/blocks/class-convertkit-block-form-builder-field.php index 295fa480b..21bb15278 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field.php +++ b/includes/blocks/class-convertkit-block-form-builder-field.php @@ -194,11 +194,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'label' => array( 'label' => __( 'Label', 'convertkit' ), @@ -223,11 +218,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'general' => array( 'label' => __( 'General', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder.php b/includes/blocks/class-convertkit-block-form-builder.php index 4aa8b2a1b..06129b965 100644 --- a/includes/blocks/class-convertkit-block-form-builder.php +++ b/includes/blocks/class-convertkit-block-form-builder.php @@ -475,11 +475,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get Kit Forms. $forms = new ConvertKit_Resource_Forms( 'block_form_builder' ); $forms_options = array(); @@ -568,11 +563,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'general' => array( 'label' => __( 'General', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-trigger.php b/includes/blocks/class-convertkit-block-form-trigger.php index 5133b916f..6633bafb6 100644 --- a/includes/blocks/class-convertkit-block-form-trigger.php +++ b/includes/blocks/class-convertkit-block-form-trigger.php @@ -212,11 +212,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get non-inline ConvertKit Forms. $forms = array(); $convertkit_forms = new ConvertKit_Resource_Forms( 'block_edit' ); @@ -270,11 +265,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Gutenberg's built-in fields (such as styling, padding etc) don't need to be defined here, as they'll be included // automatically by Gutenberg. return array( diff --git a/includes/blocks/class-convertkit-block-form.php b/includes/blocks/class-convertkit-block-form.php index b3e7c1615..0e7fcf12e 100644 --- a/includes/blocks/class-convertkit-block-form.php +++ b/includes/blocks/class-convertkit-block-form.php @@ -240,11 +240,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get ConvertKit Forms. $forms = array(); $convertkit_forms = new ConvertKit_Resource_Forms( 'block_edit' ); @@ -285,11 +280,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - return array( 'general' => array( 'label' => __( 'General', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-product.php b/includes/blocks/class-convertkit-block-product.php index ba847ab6d..316459699 100644 --- a/includes/blocks/class-convertkit-block-product.php +++ b/includes/blocks/class-convertkit-block-product.php @@ -245,11 +245,6 @@ public function get_supports() { */ public function get_fields() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Get ConvertKit Products. $products = array(); $convertkit_products = new ConvertKit_Resource_Products(); @@ -312,11 +307,6 @@ public function get_fields() { */ public function get_panels() { - // Bail if the request is not for the WordPress Administration, frontend editor or REST API request. - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { - return false; - } - // Gutenberg's built-in fields (such as styling, padding etc) don't need to be defined here, as they'll be included // automatically by Gutenberg. return array( diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index 1b75ba135..282aa4d72 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -24,6 +24,19 @@ class ConvertKit_Block { */ public function register( $blocks ) { + // If the request is for the frontend, return the minimum block definition required + // to register and render the block on the frontend site using register_block_type(). + if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { + $blocks[ $this->get_name() ] = array( + 'attributes' => $this->get_attributes(), + 'render_callback' => array( $this, 'render' ), + ); + + return $blocks; + } + + // Request is for the WordPress Administration, frontend editor or REST API request. + // Register the full block definition, including fields, panels, default values and supports. $blocks[ $this->get_name() ] = array_merge( $this->get_overview(), array( From b42dbc681467fb66c80bdada4f52828c7ba4a92d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 18:16:51 +0800 Subject: [PATCH 2/6] Check if an admin REST API request --- includes/blocks/class-convertkit-block.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index 282aa4d72..9722c3d7f 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -26,7 +26,7 @@ public function register( $blocks ) { // If the request is for the frontend, return the minimum block definition required // to register and render the block on the frontend site using register_block_type(). - if ( ! $this->is_admin_frontend_editor_or_rest_request() ) { + if ( ! $this->is_admin_frontend_editor_or_admin_rest_request() ) { $blocks[ $this->get_name() ] = array( 'attributes' => $this->get_attributes(), 'render_callback' => array( $this, 'render' ), @@ -409,15 +409,16 @@ public function get_atts_as_html_data_attributes( $atts ) { } /** - * Determines if the request is a WordPress REST API request. + * Determines if the request is a WordPress REST API request + * made by a logged in WordPress user who has the capability to edit posts. * * @since 3.1.0 * * @return bool */ - public function is_rest_request() { + public function is_admin_rest_request() { - return defined( 'REST_REQUEST' ) && REST_REQUEST; + return defined( 'REST_REQUEST' ) && REST_REQUEST && current_user_can( 'edit_posts' ); } @@ -428,9 +429,9 @@ public function is_rest_request() { * * @return bool */ - public function is_admin_frontend_editor_or_rest_request() { + public function is_admin_frontend_editor_or_admin_rest_request() { - return WP_ConvertKit()->is_admin_or_frontend_editor() || $this->is_rest_request(); + return WP_ConvertKit()->is_admin_or_frontend_editor() || $this->is_admin_rest_request(); } From 979af129f4d608d01acb001ee4aec55ffcf6cd9c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 18:26:15 +0800 Subject: [PATCH 3/6] Fix updated method name --- includes/blocks/class-convertkit-block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index 9722c3d7f..73bd5a458 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -445,7 +445,7 @@ public function is_admin_frontend_editor_or_admin_rest_request() { public function is_block_editor_request() { // Return false if not a WordPress REST API request, which Gutenberg uses. - if ( ! $this->is_rest_request() ) { + if ( ! $this->is_admin_rest_request() ) { return false; } From b067690721ea654922753f4da0e856b8829edb7e Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 19:19:31 +0800 Subject: [PATCH 4/6] Add `get_title` and `get_icon` methods --- .../class-convertkit-block-broadcasts.php | 26 +++++++++++++++++-- .../blocks/class-convertkit-block-content.php | 26 +++++++++++++++++-- ...ertkit-block-form-builder-field-custom.php | 26 +++++++++++++++++-- ...vertkit-block-form-builder-field-email.php | 26 +++++++++++++++++-- ...nvertkit-block-form-builder-field-name.php | 26 +++++++++++++++++-- ...ss-convertkit-block-form-builder-field.php | 22 ++++++++++++++++ .../class-convertkit-block-form-builder.php | 26 +++++++++++++++++-- .../class-convertkit-block-form-trigger.php | 26 +++++++++++++++++-- .../blocks/class-convertkit-block-form.php | 26 +++++++++++++++++-- .../blocks/class-convertkit-block-product.php | 26 +++++++++++++++++-- includes/blocks/class-convertkit-block.php | 2 ++ 11 files changed, 240 insertions(+), 18 deletions(-) diff --git a/includes/blocks/class-convertkit-block-broadcasts.php b/includes/blocks/class-convertkit-block-broadcasts.php index 12ecb1923..3abb986dd 100644 --- a/includes/blocks/class-convertkit-block-broadcasts.php +++ b/includes/blocks/class-convertkit-block-broadcasts.php @@ -91,6 +91,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Broadcasts', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-broadcasts.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -103,9 +125,9 @@ public function get_overview() { $settings = new ConvertKit_Settings(); return array( - 'title' => __( 'Kit Broadcasts', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Displays a list of your Kit broadcasts.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-broadcasts.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-content.php b/includes/blocks/class-convertkit-block-content.php index f1aef2391..45c2bc4f6 100644 --- a/includes/blocks/class-convertkit-block-content.php +++ b/includes/blocks/class-convertkit-block-content.php @@ -44,6 +44,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Custom Content', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-content.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -54,9 +76,9 @@ public function get_name() { public function get_overview() { return array( - 'title' => __( 'Kit Custom Content', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Displays Kit Custom Content for a subscriber if their tag matches the Page\'s tag.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-content.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder-field-custom.php b/includes/blocks/class-convertkit-block-form-builder-field-custom.php index 0aceefca9..83e727869 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field-custom.php +++ b/includes/blocks/class-convertkit-block-form-builder-field-custom.php @@ -31,6 +31,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Builder: Custom Field', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form-builder-field-custom.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -41,9 +63,9 @@ public function get_name() { public function get_overview() { return array( - 'title' => __( 'Kit Form Builder: Custom Field', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Adds a text field to the Kit Form Builder, whose value is stored in a Kit custom field.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-form-builder-field-custom.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder-field-email.php b/includes/blocks/class-convertkit-block-form-builder-field-email.php index c509a41b6..5389d463c 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field-email.php +++ b/includes/blocks/class-convertkit-block-form-builder-field-email.php @@ -58,6 +58,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Builder: Email Field', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form-builder-field-email.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -68,9 +90,9 @@ public function get_name() { public function get_overview() { return array( - 'title' => __( 'Kit Form Builder: Email Field', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Adds an email field to the Kit Form Builder.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-form-builder-field-email.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder-field-name.php b/includes/blocks/class-convertkit-block-form-builder-field-name.php index f75ca1c9b..77b226ee6 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field-name.php +++ b/includes/blocks/class-convertkit-block-form-builder-field-name.php @@ -49,6 +49,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Builder: Name Field', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form-builder-field-name.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -59,9 +81,9 @@ public function get_name() { public function get_overview() { return array( - 'title' => __( 'Kit Form Builder: Name Field', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Adds a name field to the Kit Form Builder.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-form-builder-field-name.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-builder-field.php b/includes/blocks/class-convertkit-block-form-builder-field.php index 21bb15278..96f68c9bb 100644 --- a/includes/blocks/class-convertkit-block-form-builder-field.php +++ b/includes/blocks/class-convertkit-block-form-builder-field.php @@ -110,6 +110,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Builder: Field', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form-builder-field.svg'; + + } + /** * Returns this block's Attributes * diff --git a/includes/blocks/class-convertkit-block-form-builder.php b/includes/blocks/class-convertkit-block-form-builder.php index 06129b965..a6d87a620 100644 --- a/includes/blocks/class-convertkit-block-form-builder.php +++ b/includes/blocks/class-convertkit-block-form-builder.php @@ -309,6 +309,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Builder', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form-builder.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -322,9 +344,9 @@ public function get_overview() { $settings = new ConvertKit_Settings(); return array( - 'title' => __( 'Kit Form Builder', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Build a subscription form with Kit.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-form-builder.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form-trigger.php b/includes/blocks/class-convertkit-block-form-trigger.php index 6633bafb6..423561557 100644 --- a/includes/blocks/class-convertkit-block-form-trigger.php +++ b/includes/blocks/class-convertkit-block-form-trigger.php @@ -62,6 +62,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form Trigger', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-formtrigger.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -73,9 +95,9 @@ public function get_overview() { $settings = new ConvertKit_Settings(); return array( - 'title' => __( 'Kit Form Trigger', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Displays a modal, sticky bar or slide in form to display when the button is pressed.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-formtrigger.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-form.php b/includes/blocks/class-convertkit-block-form.php index 0e7fcf12e..4332483e2 100644 --- a/includes/blocks/class-convertkit-block-form.php +++ b/includes/blocks/class-convertkit-block-form.php @@ -90,6 +90,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Form', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-form.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -103,9 +125,9 @@ public function get_overview() { $settings = new ConvertKit_Settings(); return array( - 'title' => __( 'Kit Form', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Displays a Kit Form.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-form.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block-product.php b/includes/blocks/class-convertkit-block-product.php index 316459699..1a4cbce91 100644 --- a/includes/blocks/class-convertkit-block-product.php +++ b/includes/blocks/class-convertkit-block-product.php @@ -84,6 +84,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return __( 'Kit Product', 'convertkit' ); + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return 'resources/backend/images/block-icon-product.svg'; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. * @@ -95,9 +117,9 @@ public function get_overview() { $settings = new ConvertKit_Settings(); return array( - 'title' => __( 'Kit Product', 'convertkit' ), + 'title' => $this->get_title(), 'description' => __( 'Displays a button to purchase a Kit product.', 'convertkit' ), - 'icon' => 'resources/backend/images/block-icon-product.svg', + 'icon' => $this->get_icon(), 'category' => 'convertkit', 'keywords' => array( __( 'ConvertKit', 'convertkit' ), diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index 73bd5a458..e15fb91ad 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -28,6 +28,8 @@ public function register( $blocks ) { // to register and render the block on the frontend site using register_block_type(). if ( ! $this->is_admin_frontend_editor_or_admin_rest_request() ) { $blocks[ $this->get_name() ] = array( + 'title' => $this->get_title(), + 'icon' => $this->get_icon(), 'attributes' => $this->get_attributes(), 'render_callback' => array( $this, 'render' ), ); From d5f6c8fc42fe42564ad144863cbaf3bc95253aa3 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 19:19:38 +0800 Subject: [PATCH 5/6] =?UTF-8?q?Divi:=20Don=E2=80=99t=20attempt=20to=20regi?= =?UTF-8?q?ster=20fields=20on=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/integrations/divi/class-convertkit-divi-module.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/integrations/divi/class-convertkit-divi-module.php b/includes/integrations/divi/class-convertkit-divi-module.php index 6cf76a564..ef4c5c95f 100644 --- a/includes/integrations/divi/class-convertkit-divi-module.php +++ b/includes/integrations/divi/class-convertkit-divi-module.php @@ -98,7 +98,10 @@ public function get_fields() { return array(); } - // Bail if no fields. + // Bail if no fields i.e. this is a frontend request. + if ( ! array_key_exists( 'fields', $this->block ) ) { + return array(); + } if ( ! is_array( $this->block['fields'] ) ) { return array(); } From edda02150ad4b7ec5f4ab4be8aa7a6b2b44717d6 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 25 Nov 2025 19:46:59 +0800 Subject: [PATCH 6/6] PHPStan compat. --- includes/blocks/class-convertkit-block.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index e15fb91ad..12a82447e 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -72,6 +72,28 @@ public function get_name() { } + /** + * Returns this block's title. + * + * @since 3.1.1 + */ + public function get_title() { + + return ''; + + } + + /** + * Returns this block's icon. + * + * @since 3.1.1 + */ + public function get_icon() { + + return ''; + + } + /** * Returns this block's Title, Icon, Categories, Keywords and properties. *