From 734c947dc4e58637a9a062b1f0ec32ed4d25e3cc Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 4 Feb 2026 10:19:25 +0800 Subject: [PATCH 1/4] Check if block/shortcode defined when fetching and replacing forms --- .../class-convertkit-admin-importer.php | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/admin/importers/class-convertkit-admin-importer.php b/admin/importers/class-convertkit-admin-importer.php index 94877e72e..11f4c86e0 100644 --- a/admin/importers/class-convertkit-admin-importer.php +++ b/admin/importers/class-convertkit-admin-importer.php @@ -119,8 +119,12 @@ public function import( $mappings ) { // Iterate through the mappings, replacing the third party form shortcodes and blocks with the Kit form shortcodes and blocks. foreach ( $mappings as $third_party_form_id => $kit_form_id ) { - $this->replace_blocks_in_posts( (int) $third_party_form_id, (int) $kit_form_id ); - $this->replace_shortcodes_in_posts( (int) $third_party_form_id, (int) $kit_form_id ); + if ( $this->block_name ) { + $this->replace_blocks_in_posts( (int) $third_party_form_id, (int) $kit_form_id ); + } + if ( $this->shortcode_name ) { + $this->replace_shortcodes_in_posts( (int) $third_party_form_id, (int) $kit_form_id ); + } } } @@ -136,24 +140,49 @@ public function get_forms_in_posts() { global $wpdb; - // Search post_content for the third party form block or shortcode and return array of post IDs. - $results = $wpdb->get_col( - $wpdb->prepare( - " - SELECT ID - FROM {$wpdb->posts} - WHERE post_status = %s - AND ( - post_content LIKE %s - OR post_content LIKE %s - ) - ", - 'publish', - '%[' . $this->shortcode_name . '%', - '%