Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Add Tag Functionality #732

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/class-convertkit-output.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion includes/class-convertkit-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

Expand Down
5 changes: 0 additions & 5 deletions tests/_support/Helper/Acceptance/ConvertKitPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' => '',
Expand Down
13 changes: 11 additions & 2 deletions tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 22 additions & 4 deletions tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions tests/acceptance/forms/general/EditFormLinkCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
33 changes: 33 additions & 0 deletions tests/acceptance/forms/general/WidgetFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions tests/acceptance/forms/post-types/CPTFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
]
);
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 13 additions & 6 deletions tests/acceptance/forms/post-types/PageFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 13 additions & 6 deletions tests/acceptance/forms/post-types/PostFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions tests/acceptance/integrations/other/DiviFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tests/acceptance/integrations/other/ElementorFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down