diff --git a/admin/importers/class-convertkit-admin-importer-campaignmonitor.php b/admin/importers/class-convertkit-admin-importer-campaignmonitor.php new file mode 100644 index 000000000..7cbde17b3 --- /dev/null +++ b/admin/importers/class-convertkit-admin-importer-campaignmonitor.php @@ -0,0 +1,98 @@ + $form ) { + // $form is a Campaign Monitor forms\core\Form object. It'll be a __PHP_Incomplete_Class if the Campaign Monitor plugin is not active. + // To consistently access the protected form name property, we have to cast to an array. + $form = (array) $form; + + // Access the protected form name property. + // When casting __PHP_Incomplete_Class to an array, protected properties are prefixed with \0*\0. + $forms[ $form_id ] = $form["\0*\0name"]; + } + + return $forms; + + } + +} diff --git a/admin/importers/class-convertkit-admin-importer.php b/admin/importers/class-convertkit-admin-importer.php index 6d218bc41..000ae0557 100644 --- a/admin/importers/class-convertkit-admin-importer.php +++ b/admin/importers/class-convertkit-admin-importer.php @@ -124,8 +124,12 @@ public function import( $mappings ) { continue; } - $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( $third_party_form_id, (int) $kit_form_id ); + } + if ( $this->shortcode_name ) { + $this->replace_shortcodes_in_posts( $third_party_form_id, (int) $kit_form_id ); + } } } @@ -141,24 +145,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 . '%', - '%