diff --git a/includes/class-convertkit-output.php b/includes/class-convertkit-output.php index d937ac45..69cb16bb 100644 --- a/includes/class-convertkit-output.php +++ b/includes/class-convertkit-output.php @@ -112,8 +112,8 @@ public function maybe_tag_subscriber() { $this->settings = new ConvertKit_Settings(); } - // Bail if the API if an API Key and Secret is not defined. - if ( ! $this->settings->has_api_key_and_secret() ) { + // Bail if the API hasn't been configured. + if ( ! $this->settings->has_access_and_refresh_token() ) { return; } diff --git a/includes/class-convertkit-settings.php b/includes/class-convertkit-settings.php index 542b2ba5..70042d56 100644 --- a/includes/class-convertkit-settings.php +++ b/includes/class-convertkit-settings.php @@ -162,7 +162,10 @@ public function is_api_secret_a_constant() { */ public function has_api_key_and_secret() { - return $this->has_api_key() && $this->has_api_secret(); + _deprecated_function( __FUNCTION__, '2.6.3', 'has_access_and_refresh_token()' ); + + // Use check for access and refresh token. + return $this->has_access_and_refresh_token(); } diff --git a/tests/_support/Helper/Acceptance/ConvertKitPlugin.php b/tests/_support/Helper/Acceptance/ConvertKitPlugin.php index c6d07a4e..dd14b75f 100644 --- a/tests/_support/Helper/Acceptance/ConvertKitPlugin.php +++ b/tests/_support/Helper/Acceptance/ConvertKitPlugin.php @@ -60,9 +60,6 @@ public function setupConvertKitPlugin($I, $options = false) { // Define default options. $defaults = [ - // API Key and Secret retained for testing Legacy Forms and Landing Pages. - 'api_key' => $_ENV['CONVERTKIT_API_KEY'], - 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], 'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN'], 'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN'], 'debug' => 'on', @@ -99,8 +96,6 @@ public function setupConvertKitPluginCredentialsNoData($I) $I->setupConvertKitPlugin( $I, [ - 'api_key' => $_ENV['CONVERTKIT_API_KEY_NO_DATA'], - 'api_secret' => $_ENV['CONVERTKIT_API_SECRET_NO_DATA'], 'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN_NO_DATA'], 'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN_NO_DATA'], 'post_form' => '', diff --git a/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php b/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php index 592d8b84..9777a271 100644 --- a/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php +++ b/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php @@ -70,8 +70,17 @@ public function testFormBlockWithValidFormParameter(AcceptanceTester $I) */ public function testFormBlockWithValidLegacyFormParameter(AcceptanceTester $I) { - // Setup Plugin and Resources. - $I->setupConvertKitPlugin($I); + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + 'page_form' => '', + 'product_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Add a Page using the Gutenberg editor. diff --git a/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php b/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php index 22a6ecb5..12c6ab39 100644 --- a/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php +++ b/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php @@ -261,8 +261,17 @@ public function testFormShortcodeWhenFormDoesNotExistInPluginFormResources(Accep */ public function testFormShortcodeWithValidLegacyFormParameter(AcceptanceTester $I) { - // Setup Plugin. - $I->setupConvertKitPluginNoDefaultForms($I); // Don't specify default forms. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + 'page_form' => '', + 'product_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Create Page with Shortcode. @@ -325,8 +334,17 @@ public function testFormShortcodeWithValidLegacyIDParameter(AcceptanceTester $I) */ public function testFormShortcodeWithValidLegacyFormShortcodeFromConvertKitApp(AcceptanceTester $I) { - // Setup Plugin. - $I->setupConvertKitPluginNoDefaultForms($I); // Don't specify default forms. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + 'page_form' => '', + 'product_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Create Page with Shortcode. diff --git a/tests/acceptance/forms/general/EditFormLinkCest.php b/tests/acceptance/forms/general/EditFormLinkCest.php index 2a6b3ae0..258ce12f 100644 --- a/tests/acceptance/forms/general/EditFormLinkCest.php +++ b/tests/acceptance/forms/general/EditFormLinkCest.php @@ -159,6 +159,15 @@ public function testEditFormLinkOnPageWithInvalidForm(AcceptanceTester $I) */ public function testEditFormLinkOnPageWithLegacyForm(AcceptanceTester $I) { + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + ] + ); + // Add a Page using the Gutenberg editor. $I->addGutenbergPage($I, 'page', 'Kit: Page: Form: Legacy: Edit Link'); diff --git a/tests/acceptance/forms/general/WidgetFormCest.php b/tests/acceptance/forms/general/WidgetFormCest.php index cf2cd753..4533a62e 100644 --- a/tests/acceptance/forms/general/WidgetFormCest.php +++ b/tests/acceptance/forms/general/WidgetFormCest.php @@ -42,6 +42,17 @@ public function _before(AcceptanceTester $I) */ public function testLegacyFormWidgetWithValidFormParameter(AcceptanceTester $I) { + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'page_form' => '', + 'post_form' => '', + ] + ); + // Add legacy widget, setting the Form setting to the value specified in the .env file. $I->addLegacyWidget( $I, @@ -69,6 +80,17 @@ public function testLegacyFormWidgetWithValidFormParameter(AcceptanceTester $I) */ public function testLegacyFormWidgetWithValidLegacyFormParameter(AcceptanceTester $I) { + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'page_form' => '', + 'post_form' => '', + ] + ); + // Add legacy widget, setting the Form setting to the value specified in the .env file. $I->addLegacyWidget( $I, @@ -118,6 +140,17 @@ public function testBlockFormWidgetWithValidFormParameter(AcceptanceTester $I) */ public function testBlockFormBlockWithValidLegacyFormParameter(AcceptanceTester $I) { + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'page_form' => '', + 'post_form' => '', + ] + ); + // Add block widget, setting the Form setting to the value specified in the .env file. $I->addBlockWidget( $I, diff --git a/tests/acceptance/forms/post-types/CPTFormCest.php b/tests/acceptance/forms/post-types/CPTFormCest.php index e246ab6e..59904c29 100644 --- a/tests/acceptance/forms/post-types/CPTFormCest.php +++ b/tests/acceptance/forms/post-types/CPTFormCest.php @@ -435,10 +435,12 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(AcceptanceT */ public function testAddNewCPTUsingDefaultLegacyForm(AcceptanceTester $I) { - // Setup Plugin, without defining default Forms. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. $I->setupConvertKitPlugin( $I, [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], 'article_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], ] ); @@ -550,11 +552,13 @@ public function testAddNewCPTUsingDefinedForm(AcceptanceTester $I) */ public function testAddNewCPTUsingDefinedLegacyForm(AcceptanceTester $I) { - // Setup ConvertKit Plugin. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. $I->setupConvertKitPlugin( $I, [ - 'article_form' => $_ENV['CONVERTKIT_API_FORM_ID'], + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'article_form' => '', ] ); $I->setupConvertKitPluginResources($I); diff --git a/tests/acceptance/forms/post-types/PageFormCest.php b/tests/acceptance/forms/post-types/PageFormCest.php index 6a3d8881..a0ade86f 100644 --- a/tests/acceptance/forms/post-types/PageFormCest.php +++ b/tests/acceptance/forms/post-types/PageFormCest.php @@ -323,13 +323,13 @@ public function testAddNewPageUsingDefaultFormAfterOutOfBoundsElement(Acceptance */ public function testAddNewPageUsingDefaultLegacyForm(AcceptanceTester $I) { - // Setup ConvertKit plugin to use legacy Form as default for Pages. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. $I->setupConvertKitPlugin( $I, [ - 'page_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], - 'post_form' => '', - 'product_form' => '', + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'page_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], ] ); $I->setupConvertKitPluginResources($I); @@ -713,8 +713,15 @@ public function testAddNewPageUsingModalFormWithWPRocketPlugin(AcceptanceTester */ public function testAddNewPageUsingDefinedLegacyForm(AcceptanceTester $I) { - // Setup ConvertKit plugin. - $I->setupConvertKitPlugin($I); + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'page_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Add a Page using the Gutenberg editor. diff --git a/tests/acceptance/forms/post-types/PostFormCest.php b/tests/acceptance/forms/post-types/PostFormCest.php index ec1c76a4..bb450c65 100644 --- a/tests/acceptance/forms/post-types/PostFormCest.php +++ b/tests/acceptance/forms/post-types/PostFormCest.php @@ -358,13 +358,13 @@ public function testAddNewPostUsingDefaultFormAfterOutOfBoundsElement(Acceptance */ public function testAddNewPostUsingDefaultLegacyForm(AcceptanceTester $I) { - // Setup Plugin, without defining default Forms. + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. $I->setupConvertKitPlugin( $I, [ - 'page_form' => '', - 'post_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], - 'product_form' => '', + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], ] ); $I->setupConvertKitPluginResources($I); @@ -465,8 +465,15 @@ public function testAddNewPostUsingDefinedForm(AcceptanceTester $I) */ public function testAddNewPostUsingDefinedLegacyForm(AcceptanceTester $I) { - // Setup ConvertKit Plugin. - $I->setupConvertKitPlugin($I); + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Add a Post using the Gutenberg editor. diff --git a/tests/acceptance/integrations/other/DiviFormCest.php b/tests/acceptance/integrations/other/DiviFormCest.php index 06d368df..41aa4e42 100644 --- a/tests/acceptance/integrations/other/DiviFormCest.php +++ b/tests/acceptance/integrations/other/DiviFormCest.php @@ -152,8 +152,17 @@ public function testFormModuleInFrontendEditorWhenNoForms(AcceptanceTester $I) */ public function testFormModuleWithValidLegacyFormParameter(AcceptanceTester $I) { - // Setup Plugin, without defining default Forms. - $I->setupConvertKitPluginNoDefaultForms($I); + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + 'page_form' => '', + 'product_form' => '', + ] + ); $I->setupConvertKitPluginResources($I); // Create Page with Form module in Divi. diff --git a/tests/acceptance/integrations/other/ElementorFormCest.php b/tests/acceptance/integrations/other/ElementorFormCest.php index 3f04c467..e34349eb 100644 --- a/tests/acceptance/integrations/other/ElementorFormCest.php +++ b/tests/acceptance/integrations/other/ElementorFormCest.php @@ -78,6 +78,18 @@ public function testFormWidgetWithValidFormParameter(AcceptanceTester $I) */ public function testFormWidgetWithValidLegacyFormParameter(AcceptanceTester $I) { + // Setup Plugin with API Key and Secret, which is required for Legacy Forms to work. + $I->setupConvertKitPlugin( + $I, + [ + 'api_key' => $_ENV['CONVERTKIT_API_KEY'], + 'api_secret' => $_ENV['CONVERTKIT_API_SECRET'], + 'post_form' => '', + 'page_form' => '', + 'product_form' => '', + ] + ); + // Create Page with Form widget in Elementor. $pageID = $this->_createPageWithFormWidget($I, 'Kit: Legacy Form: Elementor Widget: Valid Form Param', $_ENV['CONVERTKIT_API_LEGACY_FORM_ID']);