diff --git a/admin/section/class-convertkit-settings-general.php b/admin/section/class-convertkit-settings-general.php index fea9cde9..fd7cb834 100644 --- a/admin/section/class-convertkit-settings-general.php +++ b/admin/section/class-convertkit-settings-general.php @@ -337,7 +337,7 @@ public function register_fields() { add_settings_field( 'non_inline_form', - __( 'Default Form (Site Wide)', 'convertkit' ), + __( 'Default Forms (Site Wide)', 'convertkit' ), array( $this, 'non_inline_form_callback' ), $this->settings_key, $this->name, @@ -657,7 +657,7 @@ public function non_inline_form_callback( $args ) { $preview_url = WP_ConvertKit()->get_class( 'preview_output' )->get_preview_form_home_url(); $description = sprintf( '%s %s %s', - esc_html__( 'Select a non-inline modal, slide in or sticky bar form to automatically display site wide. Ignored if a non-inline form is specified in Default Form settings above, individual Post / Page settings, or any block / shortcode.', 'convertkit' ), + esc_html__( 'Select one or more non-inline modal, slide in or sticky bar forms to automatically display site wide. Ignored if a non-inline form is specified in Default Form settings above, individual Post / Page settings, or any block / shortcode.', 'convertkit' ), '' . esc_html__( 'Click here', 'convertkit' ) . '', esc_html__( 'to preview how this will display.', 'convertkit' ) ); @@ -671,9 +671,7 @@ public function non_inline_form_callback( $args ) { 'convertkit-preview-output-link', ), $this->settings->get_non_inline_form(), - array( - '' => esc_html__( 'None', 'convertkit' ), - ), + false, array( 'data-target' => '#convertkit-preview-non-inline-form', 'data-link' => esc_attr( $preview_url ) . '&convertkit_form_id=', diff --git a/includes/class-convertkit-output.php b/includes/class-convertkit-output.php index 8500f3e2..2b2090ea 100644 --- a/includes/class-convertkit-output.php +++ b/includes/class-convertkit-output.php @@ -803,8 +803,8 @@ public function get_subscriber_id_from_request() { } /** - * Outputs a non-inline form if defined in the Plugin's settings > - * Default Non-Inline Form (Global) setting. + * Outputs a non-inline forms if defined in the Plugin's settings > + * Default Forms (Site Wide) setting. * * @since 2.3.3 */ @@ -822,28 +822,33 @@ public function output_global_non_inline_form() { // Get form. $convertkit_forms = new ConvertKit_Resource_Forms(); - $form = $convertkit_forms->get_by_id( (int) $this->settings->get_non_inline_form() ); - // Bail if the Form doesn't exist (this shouldn't happen, but you never know). - if ( ! $form ) { - return; - } + // Iterate through forms. + foreach ( $this->settings->get_non_inline_form() as $form_id ) { + // Get Form. + $form = $convertkit_forms->get_by_id( (int) $form_id ); - // Add the form to the scripts array so it is included in the output. - add_filter( - 'convertkit_output_scripts_footer', - function ( $scripts ) use ( $form ) { + // Bail if the Form doesn't exist (this shouldn't happen, but you never know). + if ( ! $form ) { + continue; + } - $scripts[] = array( - 'async' => true, - 'data-uid' => $form['uid'], - 'src' => $form['embed_js'], - ); + // Add the form to the scripts array so it is included in the output. + add_filter( + 'convertkit_output_scripts_footer', + function ( $scripts ) use ( $form ) { - return $scripts; + $scripts[] = array( + 'async' => true, + 'data-uid' => $form['uid'], + 'src' => $form['embed_js'], + ); - } - ); + return $scripts; + + } + ); + } } diff --git a/includes/class-convertkit-preview-output.php b/includes/class-convertkit-preview-output.php index 5eb80465..685985be 100644 --- a/includes/class-convertkit-preview-output.php +++ b/includes/class-convertkit-preview-output.php @@ -72,7 +72,7 @@ public function preview_form( $form_id ) { } /** - * Adds a non-inline form for display if the request is from a logged in user who has clicked a preview link + * Adds non-inline form(s) for display if the request is from a logged in user who has clicked a preview link * and is viewing the home page. * * @since 2.3.3 @@ -99,33 +99,40 @@ public function preview_non_inline_form() { return; } - // Determine the form to preview. - $preview_form_id = (int) ( isset( $_REQUEST['convertkit_form_id'] ) ? sanitize_text_field( $_REQUEST['convertkit_form_id'] ) : 0 ); + // Bail if no form(s) to preview. + if ( ! isset( $_REQUEST['convertkit_form_id'] ) ) { + return; + } - // Get form. + // Determine form ID(s) to preview. $convertkit_forms = new ConvertKit_Resource_Forms(); - $form = $convertkit_forms->get_by_id( $preview_form_id ); + $preview_form_ids = explode( ',', sanitize_text_field( $_REQUEST['convertkit_form_id'] ) ); - // Bail if the Form doesn't exist (this shouldn't happen, but you never know). - if ( ! $form ) { - return; - } + foreach ( $preview_form_ids as $preview_form_id ) { + // Get form. + $form = $convertkit_forms->get_by_id( (int) $preview_form_id ); - // Add the form to the scripts array so it is included in the preview. - add_filter( - 'convertkit_output_scripts_footer', - function ( $scripts ) use ( $form ) { + // Bail if the Form doesn't exist (this shouldn't happen, but you never know). + if ( ! $form ) { + continue; + } - $scripts[] = array( - 'async' => true, - 'data-uid' => $form['uid'], - 'src' => $form['embed_js'], - ); + // Add the form to the scripts array so it is included in the preview. + add_filter( + 'convertkit_output_scripts_footer', + function ( $scripts ) use ( $form ) { - return $scripts; + $scripts[] = array( + 'async' => true, + 'data-uid' => $form['uid'], + 'src' => $form['embed_js'], + ); - } - ); + return $scripts; + + } + ); + } } diff --git a/includes/class-convertkit-resource-forms.php b/includes/class-convertkit-resource-forms.php index d4f4ab74..84466858 100644 --- a/includes/class-convertkit-resource-forms.php +++ b/includes/class-convertkit-resource-forms.php @@ -154,23 +154,23 @@ public function get_select_field_all( $name, $id, $css_classes, $selected_option * * @since 2.3.9 * - * @param string $name Name. - * @param string $id ID. - * @param bool|array $css_classes attributes. - * @param bool|string|array $description Description. - * @return string HTML Select Field + * @param string $name Name. + * @param string $id ID. + * @param bool|array $css_classes attributes. + * @param bool|string|array $description Description. + * @return string HTML Select Field */ - public function get_select_field_non_inline( $name, $id, $css_classes, $selected_option, $prepend_options = false, $attributes = false, $description = false ) { + public function get_select_field_non_inline( $name, $id, $css_classes, $selected_options, $prepend_options = false, $attributes = false, $description = false ) { - return $this->get_select_field( + return $this->get_multi_select_field( $this->get_non_inline(), $name, $id, $css_classes, - $selected_option, + $selected_options, $prepend_options, $attributes, $description @@ -260,6 +260,89 @@ private function get_select_field( $forms, $name, $id, $css_classes, $selected_o } + /** + * Returns a CSS class(es). + * @param array $selected_options ', + esc_attr( $value ), + ( in_array( $value, $selected_options, true ) ? ' selected' : '' ), + esc_attr( $label ) + ); + } + } + + // Iterate through resources, if they exist, building ', + esc_attr( $form['id'] ), + ( in_array( $form['id'], $selected_options, true ) ? ' selected' : '' ), + esc_attr( $form['name'] ), + ( ! empty( $form['format'] ) ? esc_attr( $form['format'] ) : 'inline' ) + ); + } + } + + // Close select. + $html .= ''; + + // If no description is provided, return the select field now. + if ( ! $description ) { + return $html; + } + + // Append description before returning field. + if ( ! is_array( $description ) ) { + return $html . '

' . $description . '

'; + } + + // Return description lines in a paragraph, using breaklines for each description entry in the array. + return $html . '

' . implode( '
', $description ) . '

'; + + } + /** * Returns the HTML/JS markup for the given Form ID. * diff --git a/includes/class-convertkit-settings.php b/includes/class-convertkit-settings.php index 70042d56..e3017bbd 100644 --- a/includes/class-convertkit-settings.php +++ b/includes/class-convertkit-settings.php @@ -353,16 +353,22 @@ public function get_default_form_position_element_index( $post_type ) { * * @since 2.3.3 * - * @return string|int Non-inline Form (blank string|form id) + * @return array */ public function get_non_inline_form() { - // Return blank string if no inline form is specified. + // Return blank array if no inline form is specified. if ( ! $this->has_non_inline_form() ) { - return ''; + return array(); + } + + // 2.6.8 and earlier stored a single Form ID in a string. + if ( is_string( $this->settings['non_inline_form'] ) ) { + return array( (int) $this->settings['non_inline_form'] ); } - return $this->settings['non_inline_form']; + // Cast values to integers and return. + return array_map( 'intval', $this->settings['non_inline_form'] ); } @@ -375,7 +381,16 @@ public function get_non_inline_form() { */ public function has_non_inline_form() { - return ( ! empty( $this->settings['non_inline_form'] ) ? true : false ); + // 2.6.8 and earlier stored a single Form ID in a string. + if ( is_string( $this->settings['non_inline_form'] ) ) { + if ( ! empty( $this->settings['non_inline_form'] ) ) { + return true; + } + + return false; + } + + return ( count( $this->settings['non_inline_form'] ) > 0 ? true : false ); } @@ -439,7 +454,7 @@ public function get_defaults() { 'api_secret' => '', // string. // Settings. - 'non_inline_form' => '', // string. + 'non_inline_form' => array(), // array. 'debug' => '', // blank|on. 'no_scripts' => '', // blank|on. 'no_css' => '', // blank|on. diff --git a/tests/_support/Helper/Acceptance/ConvertKitPlugin.php b/tests/_support/Helper/Acceptance/ConvertKitPlugin.php index 9e3073e0..51ab6165 100644 --- a/tests/_support/Helper/Acceptance/ConvertKitPlugin.php +++ b/tests/_support/Helper/Acceptance/ConvertKitPlugin.php @@ -68,7 +68,7 @@ public function setupConvertKitPlugin($I, $options = false) 'post_form' => $_ENV['CONVERTKIT_API_FORM_ID'], 'page_form' => $_ENV['CONVERTKIT_API_FORM_ID'], 'product_form' => $_ENV['CONVERTKIT_API_FORM_ID'], - 'non_inline_form' => '', + 'non_inline_form' => array(), ]; // If supplied options are an array, merge them with the defaults. diff --git a/tests/_support/Helper/Acceptance/Select2.php b/tests/_support/Helper/Acceptance/Select2.php index 8560a5fe..f349d0d8 100644 --- a/tests/_support/Helper/Acceptance/Select2.php +++ b/tests/_support/Helper/Acceptance/Select2.php @@ -29,4 +29,23 @@ public function fillSelect2Field($I, $container, $value, $ariaAttributeName = 'a $I->waitForElementVisible('ul#select2-' . $fieldName . '-results li.select2-results__option--highlighted'); $I->pressKey('.select2-search__field[' . $ariaAttributeName . '="select2-' . $fieldName . '-results"]', \Facebook\WebDriver\WebDriverKeys::ENTER); } + + /** + * Helper method to enter text into a jQuery Select2 multiple selection field, selecting the option that appears. + * + * @since 2.6.9 + * + * @param AcceptanceTester $I Tester. + * @param string $container Field CSS Class / ID. + * @param string $value Field Value. + * @param string $ariaAttributeName Aria Attribute Name (aria-controls|aria-owns). + */ + public function fillSelect2MultipleField($I, $container, $value, $ariaAttributeName = 'aria-describedby') + { + $fieldID = $I->grabAttributeFrom($container, 'id'); + $fieldName = str_replace('-container', '', str_replace('select2-', '', $fieldID)); + $I->fillField('.select2-search__field[' . $ariaAttributeName . '="select2-' . $fieldName . '-container"]', $value); + $I->waitForElementVisible('ul#select2-' . $fieldName . '-results li.select2-results__option--highlighted'); + $I->pressKey('.select2-search__field[' . $ariaAttributeName . '="select2-' . $fieldName . '-container"]', \Facebook\WebDriver\WebDriverKeys::ENTER); + } } diff --git a/tests/acceptance/forms/general/NonInlineFormCest.php b/tests/acceptance/forms/general/NonInlineFormCest.php index dd86e0b5..205ca384 100644 --- a/tests/acceptance/forms/general/NonInlineFormCest.php +++ b/tests/acceptance/forms/general/NonInlineFormCest.php @@ -46,7 +46,7 @@ public function testDefaultNonInlineForm(AcceptanceTester $I) $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] ), ] ); $I->setupConvertKitPluginResources($I); @@ -68,13 +68,59 @@ public function testDefaultNonInlineForm(AcceptanceTester $I) $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); // View Page. - $I->amOnPage('/convertkit-default-non-inline-global'); + $I->amOnPage('/kit-default-non-inline-global'); // Confirm that one ConvertKit Form is output in the DOM. // This confirms that there is only one script on the page for this form, which renders the form. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); } + /** + * Test that the defined default non-inline forms displays site wide + * when more than one form is specified. + * + * @since 2.6.9 + * + * @param AcceptanceTester $I Tester. + */ + public function testDefaultNonInlineForms(AcceptanceTester $I) + { + // Setup Plugin with a non-inline Default Form (Site Wide). + $I->setupConvertKitPlugin( + $I, + [ + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], + ), + ] + ); + $I->setupConvertKitPluginResources($I); + + // Create a Page in the database. + $I->havePostInDatabase( + [ + 'post_title' => 'Kit: Default Non Inline Global Forms', + 'post_type' => 'page', + 'post_status' => 'publish', + ] + ); + + // View the home page. + $I->amOnPage('/'); + + // Confirm that two ConvertKit Forms are output in the DOM. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1); + + // View Page. + $I->amOnPage('/kit-default-non-inline-global-forms'); + + // Confirm that two Kit Forms are output in the DOM. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1); + } + /** * Test that no non-inline form displays site wide when not selected in the Plugin's settings. * @@ -111,7 +157,9 @@ public function testDefaultNonInlineFormIgnoredWhenDefaultPageNonInlineFormDefin $I, [ 'page_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -149,7 +197,9 @@ public function testDefaultNonInlineFormIgnoredWhenPageNonInlineFormDefined(Acce $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -187,7 +237,9 @@ public function testDefaultNonInlineFormIgnoredWhenPageNonInlineFormDefinedInBlo $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -235,7 +287,9 @@ public function testDefaultNonInlineFormIgnoredWhenPageNonInlineFormDefinedInSho $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -285,7 +339,9 @@ public function testDefaultNonInlineFormIgnoredWhenDefaultPostNonInlineFormDefin $I, [ 'post_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'], - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -323,7 +379,9 @@ public function testDefaultNonInlineFormIgnoredWhenPostNonInlineFormDefined(Acce $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -361,7 +419,9 @@ public function testDefaultNonInlineFormIgnoredWhenPostCategoryNonInlineFormDefi $I->setupConvertKitPlugin( $I, [ - 'non_inline_form' => $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), ] ); @@ -401,6 +461,52 @@ public function testDefaultNonInlineFormIgnoredWhenPostCategoryNonInlineFormDefi $I->dontSeeElementInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]'); } + /** + * Test that the defined default non-inline form displays site wide + * when stored as a string in the Plugin settings from older + * Plugin versions < 2.6.9. + * + * @since 2.6.9 + * + * @param AcceptanceTester $I Tester. + */ + public function testDefaultNonInlineFormOnUpgrade(AcceptanceTester $I) + { + // Setup Plugin with a non-inline Default Form (Site Wide). + $I->setupConvertKitPlugin( + $I, + [ + 'non_inline_form' => array( + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'], + ), + ] + ); + $I->setupConvertKitPluginResources($I); + + // Create a Page in the database. + $I->havePostInDatabase( + [ + 'post_title' => 'Kit: Default Non Inline Global Upgrade', + 'post_type' => 'page', + 'post_status' => 'publish', + ] + ); + + // View the home page. + $I->amOnPage('/'); + + // Confirm that one ConvertKit Form is output in the DOM. + // This confirms that there is only one script on the page for this form, which renders the form. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); + + // View Page. + $I->amOnPage('/kit-default-non-inline-global-upgrade'); + + // Confirm that one ConvertKit Form is output in the DOM. + // This confirms that there is only one script on the page for this form, which renders the form. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); + } + /** * Deactivate and reset Plugin(s) after each test, if the test passes. * We don't use _after, as this would provide a screenshot of the Plugin diff --git a/tests/acceptance/general/PluginSettingsGeneralCest.php b/tests/acceptance/general/PluginSettingsGeneralCest.php index 38da9c8b..c1a9e456 100644 --- a/tests/acceptance/general/PluginSettingsGeneralCest.php +++ b/tests/acceptance/general/PluginSettingsGeneralCest.php @@ -281,8 +281,38 @@ public function testChangeDefaultFormSettingAndPreviewFormLinks(AcceptanceTester // Close newly opened tab. $I->closeTab(); - // Select a non-inline form for the Default non-inline form setting. - $I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_non_inline_form-container', $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME']); + // Click the Save Changes button. + $I->click('Save Changes'); + + // Check that no PHP warnings or notices were output. + $I->checkNoWarningsAndNoticesOnScreen($I); + + // Check the value of the fields match the inputs provided. + $I->seeInField('_wp_convertkit_settings[page_form]', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->seeInField('_wp_convertkit_settings[page_form_position]', 'Before Page content'); + $I->seeInField('_wp_convertkit_settings[post_form]', $_ENV['CONVERTKIT_API_FORM_NAME']); + $I->seeInField('_wp_convertkit_settings[post_form_position]', 'After Post content'); + } + + /** + * Test that no PHP errors or notices are displayed on the Plugin's Setting screen, + * when the Default Forms (Site Wide) setting is changed, and that the preview links + * work when one or more Default Forms are chosen. + * + * @since 2.6.9 + * + * @param AcceptanceTester $I Tester. + */ + public function testChangeDefaultSiteWideFormsSettingAndPreviewFormLinks(AcceptanceTester $I) + { + // Setup Plugin, without defining default Forms. + $I->setupConvertKitPluginNoDefaultForms($I); + + // Go to the Plugin's Settings Screen. + $I->loadConvertKitSettingsGeneralScreen($I); + + // Select the Sticky Bar Form for the Site Wide option. + $I->fillSelect2MultipleField($I, '#select2-_wp_convertkit_settings_non_inline_form-container', $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME']); // Open preview. $I->click('a#convertkit-preview-non-inline-form'); @@ -291,13 +321,36 @@ public function testChangeDefaultFormSettingAndPreviewFormLinks(AcceptanceTester // Switch to newly opened tab. $I->switchToNextTab(); - // Confirm that one ConvertKit Form is output in the DOM. + // Confirm that the preview is the Home Page. + $I->seeElementInDOM('body.home'); + + // Confirm that one Kit Form is output in the DOM. // This confirms that there is only one script on the page for this form, which renders the form. $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); // Close newly opened tab. $I->closeTab(); + // Select a second Modal Form for the Site Wide option. + $I->fillSelect2MultipleField($I, '#select2-_wp_convertkit_settings_non_inline_form-container', $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME']); + + // Open preview. + $I->click('a#convertkit-preview-non-inline-form'); + $I->wait(2); // Required, otherwise switchToNextTab fails. + + // Switch to newly opened tab. + $I->switchToNextTab(); + + // Confirm that the preview is the Home Page. + $I->seeElementInDOM('body.home'); + + // Confirm that two Kit Forms are output in the DOM. + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_ID'] . '"]', 1); + $I->seeNumberOfElementsInDOM('form[data-sv-form="' . $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_ID'] . '"]', 1); + + // Close newly opened tab. + $I->closeTab(); + // Click the Save Changes button. $I->click('Save Changes'); @@ -305,11 +358,15 @@ public function testChangeDefaultFormSettingAndPreviewFormLinks(AcceptanceTester $I->checkNoWarningsAndNoticesOnScreen($I); // Check the value of the fields match the inputs provided. - $I->seeInField('_wp_convertkit_settings[page_form]', $_ENV['CONVERTKIT_API_FORM_NAME']); - $I->seeInField('_wp_convertkit_settings[page_form_position]', 'Before Page content'); - $I->seeInField('_wp_convertkit_settings[post_form]', $_ENV['CONVERTKIT_API_FORM_NAME']); - $I->seeInField('_wp_convertkit_settings[post_form_position]', 'After Post content'); - $I->seeInField('_wp_convertkit_settings[non_inline_form]', $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME']); + $I->seeInFormFields( + 'form', + [ + '_wp_convertkit_settings[non_inline_form][]' => [ + $_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME'], + $_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'], + ], + ] + ); } /**