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 94877e72e..000ae0557 100644
--- a/admin/importers/class-convertkit-admin-importer.php
+++ b/admin/importers/class-convertkit-admin-importer.php
@@ -119,8 +119,17 @@ 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 );
+ // Skip empty Kit Form IDs i.e. no mapping was provided for this third party form.
+ if ( empty( $kit_form_id ) ) {
+ continue;
+ }
+
+ 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 );
+ }
}
}
@@ -136,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 . '%',
- '%
Some content with characters !@£$%^&*()_+~!@£$%^&*()_+\\\
',
+
+ // Configure Kit Plugin to not display a default Form, so we test against the Kit Form in the content.
+ 'meta_input' => [
+ '_wp_convertkit_post_meta' => [
+ 'form' => '0',
+ 'landing_page' => '',
+ 'tag' => '',
+ ],
+ ],
+ ]
+ ),
+ ];
+
+ // Load Form Importer screen of Setup Wizard.
+ $I->amOnAdminPage('options.php?page=convertkit-setup&step=form-importer');
+
+ // Select the Kit Forms to replace the ActiveCampaign Forms.
+ $I->fillSelect2Field(
+ $I,
+ container: '#select2-form-importer-activecampaign-1-container',
+ value: $_ENV['CONVERTKIT_API_FORM_NAME']
+ );
+ $I->fillSelect2Field(
+ $I,
+ container: '#select2-form-importer-activecampaign-2-container',
+ value: $_ENV['CONVERTKIT_API_FORM_NAME']
+ );
+
+ // Click the Finish Setup button.
+ $I->click('Finish Setup');
+
+ // Confirm expected setup wizard screen is displayed.
+ $this->_seeExpectedSetupWizardScreen(
+ $I,
+ step: 'finish',
+ stepCount: 4,
+ totalSteps: 4,
+ title: 'Setup complete'
+ );
+
+ // Test each Page.
+ foreach ($pageIDs as $pageID) {
+ $I->amOnPage('?p=' . $pageID);
+
+ // Check Kit Forms are displayed.
+ $I->seeElementInDOM('form[data-sv-form]');
+ }
+ }
+
/**
* Tests that a link to the Setup Wizard exists on the Plugins screen, and works when clicked.
*
@@ -606,8 +715,9 @@ private function _activatePlugin(EndToEndTester $I)
* @param int $stepCount Current step count.
* @param string $title Expected title.
* @param bool $nextButtonIsLink Check that next button is a link (false = must be a