diff --git a/src/DonationForms/V2/DonationFormsAdminPage.php b/src/DonationForms/V2/DonationFormsAdminPage.php
index 3ec80a49cc..9319d5d22c 100644
--- a/src/DonationForms/V2/DonationFormsAdminPage.php
+++ b/src/DonationForms/V2/DonationFormsAdminPage.php
@@ -102,8 +102,8 @@ public function loadScripts()
'table' => give(DonationFormsListTable::class)->toArray(),
'adminUrl' => $this->adminUrl,
'pluginUrl' => GIVE_PLUGIN_URL,
- 'showBanner' => ! get_user_meta(get_current_user_id(), 'givewp-show-onboarding-banner', true),
- 'showUpgradedTooltip' => ! get_user_meta(get_current_user_id(), 'givewp-show-upgraded-tooltip', true),
+ 'showBanner' => !get_user_meta(get_current_user_id(), 'givewp-show-onboarding-banner', true),
+ 'showUpgradedTooltip' => !get_user_meta(get_current_user_id(), 'givewp-show-upgraded-tooltip', true),
'supportedAddons' => $this->getSupportedAddons(),
'supportedGateways' => $this->getSupportedGateways(),
];
@@ -133,29 +133,29 @@ public function loadMigrationScripts()
{
if ($this->isShowingAddV2FormPage()) {
EnqueueScript::make('give-add-v2form', 'assets/dist/js/give-add-v2form.js')
- ->loadInFooter()
- ->registerTranslations()
- ->registerLocalizeData('GiveDonationForms', [
- 'supportedAddons' => $this->getSupportedAddons(),
- 'supportedGateways' => $this->getSupportedGateways(),
- ])
- ->enqueue();
+ ->loadInFooter()
+ ->registerTranslations()
+ ->registerLocalizeData('GiveDonationForms', [
+ 'supportedAddons' => $this->getSupportedAddons(),
+ 'supportedGateways' => $this->getSupportedGateways(),
+ ])
+ ->enqueue();
wp_enqueue_style('givewp-design-system-foundation');
}
if ($this->isShowingEditV2FormPage()) {
EnqueueScript::make('give-edit-v2form', 'assets/dist/js/give-edit-v2form.js')
- ->loadInFooter()
- ->registerTranslations()
- ->registerLocalizeData('GiveDonationForms', [
- 'supportedAddons' => $this->getSupportedAddons(),
- 'supportedGateways' => $this->getSupportedGateways(),
- 'migrationApiRoot' => $this->migrationApiRoot,
- 'apiNonce' => $this->apiNonce,
- 'isMigrated' => _give_is_form_migrated((int)$_GET['post'])
- ])
- ->enqueue();
+ ->loadInFooter()
+ ->registerTranslations()
+ ->registerLocalizeData('GiveDonationForms', [
+ 'supportedAddons' => $this->getSupportedAddons(),
+ 'supportedGateways' => $this->getSupportedGateways(),
+ 'migrationApiRoot' => $this->migrationApiRoot,
+ 'apiNonce' => $this->apiNonce,
+ 'isMigrated' => _give_is_form_migrated((int)$_GET['post']),
+ ])
+ ->enqueue();
wp_enqueue_style('givewp-design-system-foundation');
}
@@ -215,7 +215,7 @@ public function render()
*
* @since 3.0.0
*
- * @param WP_Post $post
+ * @param WP_Post $post
*
* @return void
*/
@@ -239,17 +239,20 @@ function showReactTable() {
fetch('', {
method: 'GET',
headers: {
- ['X-WP-Nonce']: '',
- },
+ ['X-WP-Nonce']: ''
+ }
})
.then((res) => {
window.location = window.location.href = '/wp-admin/edit.php?post_type=give_forms&page=give-forms';
});
}
- jQuery(function () {
- jQuery(jQuery(".wrap .page-title-action")[0]).after(
- '',
+ jQuery(function() {
+ jQuery(jQuery('.wrap .page-title-action')[0]).after(
+ ''
);
});
@@ -288,7 +291,7 @@ private function isShowingEditV2FormPage(): bool
*/
private function isShowingAddV2FormPage(): bool
{
- return ! isset($_GET['page']) && isset($_GET['post_type']) && $_GET['post_type'] === 'give_forms';
+ return !isset($_GET['page']) && isset($_GET['post_type']) && $_GET['post_type'] === 'give_forms';
}
/**
@@ -340,7 +343,6 @@ public function getSupportedAddons(): array
'Funds' => defined('GIVE_FUNDS_ADDON_NAME'),
'Peer-to-Peer' => defined('GIVE_P2P_NAME'),
'Gift Aid' => class_exists('Give_Gift_Aid'),
- // 'MailChimp' => class_exists('Give_MailChimp'),
// 'Text-to-Give' => defined('GIVE_TEXT_TO_GIVE_ADDON_NAME'),
// 'Donation Block for Stripe' => defined('DONATION_BLOCK_FILE'),
'Double the Donation' => defined('GIVE_DTD_NAME'),
@@ -349,6 +351,7 @@ public function getSupportedAddons(): array
'Per Form Gateways' => class_exists('Give_Per_Form_Gateways'),
// 'Per Form Confirmations' => class_exists('Per_Form_Confirmations_4_GIVEWP'),
// 'Form Countdown' => class_exists('Give_Form_Countdown'),
+ 'ConvertKit' => defined('GIVE_CONVERTKIT_VERSION'),
'ActiveCampaign' => class_exists('Give_ActiveCampaign'),
];
diff --git a/src/FormMigration/FormMetaDecorator.php b/src/FormMigration/FormMetaDecorator.php
index cc16893be2..67afc8b64d 100644
--- a/src/FormMigration/FormMetaDecorator.php
+++ b/src/FormMigration/FormMetaDecorator.php
@@ -46,7 +46,7 @@ public function isUserRegistrationEnabled(): bool
public function isUserLoginRequired(): bool
{
- return !$this->isGuestDonationsEnabled();
+ return ! $this->isGuestDonationsEnabled();
}
public function isGuestDonationsEnabled(): bool
@@ -69,7 +69,7 @@ public function isCompanyFieldRequired(): bool
$form_option = give_get_meta($this->form->id, '_give_company_field', true);
$global_setting = give_get_option('company_field');
- if (!empty($form_option) && give_is_setting_enabled($form_option, ['required'])) {
+ if ( ! empty($form_option) && give_is_setting_enabled($form_option, ['required'])) {
return true;
} elseif ('global' === $form_option && give_is_setting_enabled($global_setting, ['required'])) {
return true;
@@ -261,7 +261,7 @@ public function isRecurringDonationsEnabled(): bool
{
$_give_recurring = $this->getRecurringDonationsOption();
- return !empty($_give_recurring) && 'no' !== $_give_recurring;
+ return ! empty($_give_recurring) && 'no' !== $_give_recurring;
}
/**
@@ -427,9 +427,9 @@ public function getOfflineAttributes(): array
$instructions = give_get_meta($this->form->id, '_give_offline_checkout_notes', true);
return [
- 'offlineEnabled' => $customization !== 'disabled',
+ 'offlineEnabled' => $customization !== 'disabled',
'offlineUseGlobalInstructions' => $customization === 'global',
- 'offlineDonationInstructions' => $instructions,
+ 'offlineDonationInstructions' => $instructions,
];
}
@@ -485,10 +485,10 @@ public function getFeeRecoverySettings(): array
}
$perGatewaySettings[$v3GatewayId] = [
- 'enabled' => $this->getMeta('_form_gateway_fee_enable_' . $gatewayId) === 'enabled',
+ 'enabled' => $this->getMeta('_form_gateway_fee_enable_' . $gatewayId) === 'enabled',
'feePercentage' => (float)$this->getMeta('_form_gateway_fee_percentage_' . $gatewayId, 2.9),
'feeBaseAmount' => (float)$this->getMeta('_form_gateway_fee_base_amount_' . $gatewayId, 0.30),
- 'maxFeeAmount' => (float)$this->getMeta(
+ 'maxFeeAmount' => (float)$this->getMeta(
'_form_gateway_fee_maximum_fee_amount_' . $gatewayId,
give_format_decimal(['amount' => '0.00'])
),
@@ -497,16 +497,16 @@ public function getFeeRecoverySettings(): array
}
return [
- 'useGlobalSettings' => false,
+ 'useGlobalSettings' => false,
'feeSupportForAllGateways' => $this->getMeta('_form_give_fee_configuration') === 'all_gateways',
- 'perGatewaySettings' => $perGatewaySettings,
- 'feePercentage' => (float)$this->getMeta('_form_give_fee_percentage'),
- 'feeBaseAmount' => (float)$this->getMeta('_form_give_fee_base_amount'),
- 'maxFeeAmount' => (float)$this->getMeta('_form_give_fee_maximum_fee_amount'),
+ 'perGatewaySettings' => $perGatewaySettings,
+ 'feePercentage' => (float)$this->getMeta('_form_give_fee_percentage'),
+ 'feeBaseAmount' => (float)$this->getMeta('_form_give_fee_base_amount'),
+ 'maxFeeAmount' => (float)$this->getMeta('_form_give_fee_maximum_fee_amount'),
'includeInDonationSummary' => $this->getMeta('_form_breakdown') === 'enabled',
- 'donorOptIn' => $this->getMeta('_form_give_fee_mode') === 'donor_opt_in',
- 'feeCheckboxLabel' => $this->getMeta('_form_give_fee_checkbox_label'),
- 'feeMessage' => $this->getMeta('_form_give_fee_explanation'),
+ 'donorOptIn' => $this->getMeta('_form_give_fee_mode') === 'donor_opt_in',
+ 'feeCheckboxLabel' => $this->getMeta('_form_give_fee_checkbox_label'),
+ 'feeMessage' => $this->getMeta('_form_give_fee_explanation'),
];
}
@@ -515,14 +515,17 @@ public function getFeeRecoverySettings(): array
*/
public function isConstantContactEnabled(): bool
{
- $isFormEnabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_enable'),'true');
+ $isFormEnabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_enable'), 'true');
- $isFormDisabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_disable'),'true');
+ $isFormDisabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_disable'), 'true');
- $isGloballyEnabled = give_is_setting_enabled(give_get_option('give_constant_contact_show_checkout_signup'), 'on');
+ $isGloballyEnabled = give_is_setting_enabled(
+ give_get_option('give_constant_contact_show_checkout_signup'),
+ 'on'
+ );
- return !($isFormDisabled || ( !$isGloballyEnabled && !$isFormEnabled));
- }
+ return ! ($isFormDisabled || ( ! $isGloballyEnabled && ! $isFormEnabled));
+ }
/**
* @since 3.7.0
@@ -540,8 +543,10 @@ public function getConstantContactLabel(): string
public function getConstantContactDefaultChecked(): bool
{
$defaultMeta = give_is_setting_enabled(
- give_get_option('give_constant_contact_checked_default',
- true),
+ give_get_option(
+ 'give_constant_contact_checked_default',
+ true
+ ),
'on'
);
@@ -569,7 +574,7 @@ public function isMailchimpEnabled(): bool
$isGloballyEnabled = give_is_setting_enabled(give_get_option('give_mailchimp_show_checkout_signup'), 'on');
- return !($isFormDisabled || (!$isGloballyEnabled && !$isFormEnabled));
+ return ! ($isFormDisabled || ( ! $isGloballyEnabled && ! $isFormEnabled));
}
/**
@@ -577,7 +582,10 @@ public function isMailchimpEnabled(): bool
*/
public function getMailchimpLabel(): string
{
- return $this->getMeta('_give_mailchimp_custom_label', give_get_option('give_mailchimp_label', __('Subscribe to newsletter?')));
+ return $this->getMeta(
+ '_give_mailchimp_custom_label',
+ give_get_option('give_mailchimp_label', __('Subscribe to newsletter?'))
+ );
}
/**
@@ -586,8 +594,12 @@ public function getMailchimpLabel(): string
*/
public function getMailchimpDefaultChecked(): bool
{
- return give_is_setting_enabled($this->getMeta('_give_mailchimp_checked_default',
- give_get_option('give_mailchimp_checked_default', true)));
+ return give_is_setting_enabled(
+ $this->getMeta(
+ '_give_mailchimp_checked_default',
+ give_get_option('give_mailchimp_checked_default', true)
+ )
+ );
}
/**
@@ -596,8 +608,12 @@ public function getMailchimpDefaultChecked(): bool
*/
public function getMailchimpSendDonationData(): bool
{
- return give_is_setting_enabled($this->getMeta('_give_mailchimp_send_donation_data',
- give_get_option('give_mailchimp_donation_data', true)));
+ return give_is_setting_enabled(
+ $this->getMeta(
+ '_give_mailchimp_send_donation_data',
+ give_get_option('give_mailchimp_donation_data', true)
+ )
+ );
}
/**
@@ -606,8 +622,12 @@ public function getMailchimpSendDonationData(): bool
*/
public function getMailchimpSendFFMData(): bool
{
- return give_is_setting_enabled($this->getMeta('_give_mailchimp_send_ffm',
- give_get_option('give_mailchimp_ffm_pass_field')));
+ return give_is_setting_enabled(
+ $this->getMeta(
+ '_give_mailchimp_send_ffm',
+ give_get_option('give_mailchimp_ffm_pass_field')
+ )
+ );
}
/**
@@ -621,7 +641,7 @@ public function getMailchimpDefaultAudiences(): array
/**
* @since 3.3.0
*/
- public function getMailchimpSubscriberTags():? array
+ public function getMailchimpSubscriberTags(): ?array
{
return (array)$this->getMeta('_give_mailchimp_tags', null);
}
@@ -635,8 +655,9 @@ public function getMailchimpSubscriberTags():? array
*
* @since 3.0.0
*
- * @param string $key
- * @param mixed $default
+ * @param string $key
+ * @param mixed $default
+ *
* @return mixed
*/
private function getMeta(string $key, $default = null)
@@ -652,7 +673,7 @@ public function hasFunds(): bool
{
$fundsAndDesignationsAttributes = $this->getFundsAndDesignationsAttributes();
- return !empty($fundsAndDesignationsAttributes['fund']);
+ return ! empty($fundsAndDesignationsAttributes['fund']);
}
/**
@@ -663,7 +684,7 @@ public function hasFundOptions(): bool
{
$fundsAndDesignationsAttributes = $this->getFundsAndDesignationsAttributes();
- return !empty($fundsAndDesignationsAttributes['options']);
+ return ! empty($fundsAndDesignationsAttributes['options']);
}
/**
@@ -679,12 +700,12 @@ public function getFundsAndDesignationsAttributes(): array
$options = [];
- if (!empty($donorOptions)) {
+ if ( ! empty($donorOptions)) {
foreach ($donorOptions as $fundId) {
$options[] = [
- 'value' => $fundId,
- 'label' => $this->getFundLabel($fundId),
- 'checked' => $isAdminChoice ? $fundId === $adminChoice : true,
+ 'value' => $fundId,
+ 'label' => $this->getFundLabel($fundId),
+ 'checked' => $isAdminChoice ? $fundId === $adminChoice : true,
'isDefault' => $this->isDefaultFund($fundId),
];
}
@@ -693,18 +714,18 @@ public function getFundsAndDesignationsAttributes(): array
$fund = [];
if ($isAdminChoice) {
$fund = [
- 'value' => $adminChoice,
- 'label' => $this->getFundLabel($adminChoice),
- 'checked' => true,
+ 'value' => $adminChoice,
+ 'label' => $this->getFundLabel($adminChoice),
+ 'checked' => true,
'isDefault' => $this->isDefaultFund($adminChoice),
];
- } elseif (!empty($options)) {
+ } elseif ( ! empty($options)) {
$fund = $options[0];
}
return [
- 'label' => $label,
- 'fund' => $fund,
+ 'label' => $label,
+ 'fund' => $fund,
'options' => $options,
];
}
@@ -720,7 +741,7 @@ private function getFundLabel(int $fundId): string
$wpdb->prepare("SELECT * FROM {$wpdb->give_funds} WHERE id = %d", $fundId)
);
- if (!$fund) {
+ if ( ! $fund) {
return '';
}
@@ -736,7 +757,7 @@ private function isDefaultFund(int $fundId): bool
$fund = $wpdb->get_row("SELECT id FROM {$wpdb->give_funds} WHERE is_default = 1");
- if (!$fund) {
+ if ( ! $fund) {
return false;
}
@@ -851,6 +872,60 @@ public function getFormFeaturedImage()
/**
* @since 3.10.0
*/
+ public function isConvertKitEnabled(): bool
+ {
+ $isFormEnabled = $this->getMeta('_give_convertkit_override_option') === 'customize';
+
+ $isFormDisabled = $this->getMeta('_give_convertkit_override_option') === 'disabled';
+
+ $isGloballyEnabled = $this->getMeta('_give_convertkit_override_option') === 'default' &&
+ give_is_setting_enabled(give_get_option('give_convertkit_show_subscribe_checkbox'));
+
+ return $isFormEnabled ? $isGloballyEnabled : $isFormDisabled;
+ }
+
+ /**
+ * @unreleased
+ */
+ public function getConvertKitLabel(): string
+ {
+ $defaultMeta = give_get_option('give_convertkit_label', __('Subscribe to newsletter?'));
+
+ return $this->getMeta('_give_convertkit_custom_label', $defaultMeta);
+ }
+
+ /**
+ * @unreleased
+ */
+ public function getConvertKitDefaultChecked(): bool
+ {
+ $defaultMeta = give_get_option('give_convertkit_checked_default');
+
+ return give_is_setting_enabled($this->getMeta('_give_convertkit_checked_default', $defaultMeta));
+ }
+
+ /**
+ * @unreleased
+ */
+ public function getConvertKitTags(): ?array
+ {
+ $defaultMeta = give_get_option('_give_convertkit_tags', []);
+
+ return ! empty($this->getMeta('_give_convertkit_tags')) ?
+ $this->getMeta('_give_convertkit_tags') :
+ $defaultMeta;
+ }
+
+ /**
+ * @unreleased
+ */
+ public function getConvertKitSelectedForm(): string
+ {
+ $defaultMeta = give_get_option('give_convertkit_list', '');
+
+ return $this->getMeta('_give_convertkit', $defaultMeta);
+ }
+
public function isActiveCampaignEnabled(): bool
{
$isFormEnabled = give_is_setting_enabled($this->getMeta('activecampaign_per_form_options'), 'customized');
@@ -859,7 +934,7 @@ public function isActiveCampaignEnabled(): bool
$isGloballyEnabled = give_is_setting_enabled(give_get_option('give_activecampaign_globally_enabled'), 'on');
- return !($isFormDisabled || (!$isGloballyEnabled && !$isFormEnabled));
+ return ! ($isFormDisabled || ( ! $isGloballyEnabled && ! $isFormEnabled));
}
/**
@@ -893,7 +968,7 @@ public function getActiveCampaignSelectedLists(): array
{
$defaultMeta = give_get_option('give_activecampaign_lists', []);
- return !empty($this->getMeta('give_activecampaign_lists')) ?
+ return ! empty($this->getMeta('give_activecampaign_lists')) ?
$this->getMeta('give_activecampaign_lists') : $defaultMeta;
}
@@ -902,9 +977,9 @@ public function getActiveCampaignSelectedLists(): array
*/
public function getActiveCampaignTags(): array
{
- $defaultMeta = give_get_option('give_activecampaign_tags',[]);
+ $defaultMeta = give_get_option('give_activecampaign_tags', []);
- return !empty($this->getMeta('give_activecampaign_tags')) ?
+ return ! empty($this->getMeta('give_activecampaign_tags')) ?
$this->getMeta('give_activecampaign_tags') : $defaultMeta;
}
}
diff --git a/src/FormMigration/ServiceProvider.php b/src/FormMigration/ServiceProvider.php
index 5c0ef142de..2684b75a34 100644
--- a/src/FormMigration/ServiceProvider.php
+++ b/src/FormMigration/ServiceProvider.php
@@ -52,6 +52,7 @@ public function register()
Steps\GiftAid::class,
Steps\FormFeaturedImage::class,
Steps\FormExcerpt::class,
+ Steps\ConvertKit::class,
Steps\ActiveCampaign::class,
Steps\DoubleTheDonation::class,
]);
@@ -70,11 +71,10 @@ public function boot()
protected function registerRoutes()
{
add_action('rest_api_init', function () {
-
// give-api/v2/admin/forms/migrate
register_rest_route('give-api/v2', 'admin/forms/migrate/(?P\d+)', [
- 'methods' => WP_REST_Server::CREATABLE,
- 'callback' => function (WP_REST_Request $request) {
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => function (WP_REST_Request $request) {
return (new MigrationController($request))(
DonationFormV2::find($request->get_param('id'))
);
@@ -82,19 +82,19 @@ protected function registerRoutes()
'permission_callback' => function () {
return current_user_can('manage_options');
},
- 'args' => [
+ 'args' => [
'id' => [
- 'type' => 'integer',
+ 'type' => 'integer',
'sanitize_callback' => 'absint',
- 'description' => __('The ID of the form (v2) to migrate to v3.', 'give'),
+ 'description' => __('The ID of the form (v2) to migrate to v3.', 'give'),
],
],
]);
// give-api/v2/admin/forms/transfer
register_rest_route('give-api/v2', 'admin/forms/transfer', [
- 'methods' => WP_REST_Server::CREATABLE,
- 'callback' => function (WP_REST_Request $request) {
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => function (WP_REST_Request $request) {
return (new TransferController($request))(
DonationFormV2::find($request->get_param('formId')),
TransferOptions::fromRequest($request)
@@ -103,28 +103,28 @@ protected function registerRoutes()
'permission_callback' => function () {
return current_user_can('manage_options');
},
- 'args' => [
- 'formId' => [
- 'type' => 'integer',
+ 'args' => [
+ 'formId' => [
+ 'type' => 'integer',
'sanitize_callback' => function ($value) {
return intval($value);
// return array_map('intval', explode(',', $value));
},
- 'description' => __('The ID of the form (v3) to transfer donations (from v2).', 'give'),
+ 'description' => __('The ID of the form (v3) to transfer donations (from v2).', 'give'),
],
'changeUrl' => [
- 'type' => 'boolean',
+ 'type' => 'boolean',
'required' => false,
- 'default' => true
+ 'default' => true,
],
- 'delete' => [
- 'type' => 'boolean',
+ 'delete' => [
+ 'type' => 'boolean',
'required' => true,
],
- 'redirect' => [
- 'type' => 'boolean',
+ 'redirect' => [
+ 'type' => 'boolean',
'required' => false,
- 'default' => true
+ 'default' => true,
],
],
]);
diff --git a/src/FormMigration/Steps/ConvertKit.php b/src/FormMigration/Steps/ConvertKit.php
new file mode 100644
index 0000000000..55e0ede15c
--- /dev/null
+++ b/src/FormMigration/Steps/ConvertKit.php
@@ -0,0 +1,47 @@
+formV2->isConvertKitEnabled();
+ }
+
+ /**
+ * @unreleased
+ */
+ public function process(): void
+ {
+ $block = BlockModel::make([
+ 'name' => 'givewp-convertkit/convertkit',
+ 'attributes' => $this->getAttributes()
+ ]);
+
+ $this->fieldBlocks->insertAfter('givewp/email', $block);
+ }
+
+ /**
+ * @unreleased
+ */
+ private function getAttributes(): array
+ {
+ return [
+ 'label' => $this->formV2->getConvertKitLabel() ,
+ 'defaultChecked' => $this->formV2->getConvertKitDefaultChecked(),
+ 'selectedForm' => $this->formV2->getConvertKitSelectedForm(),
+ 'tagSubscribers' => $this->formV2->getConvertKitTags()
+ ];
+ }
+}
diff --git a/tests/Feature/FormMigration/Steps/TestConvertKit.php b/tests/Feature/FormMigration/Steps/TestConvertKit.php
new file mode 100644
index 0000000000..a73fd99042
--- /dev/null
+++ b/tests/Feature/FormMigration/Steps/TestConvertKit.php
@@ -0,0 +1,97 @@
+ __('Subscribe to newsletter?' , 'give'),
+ '_give_convertkit' => '6352843',
+ '_give_convertkit_tags' => ['4619079', '4619080'],
+ '_give_convertkit_checked_default' => true,
+ ];
+
+ $formV2 = $this->createSimpleDonationForm(['meta' => $meta]);
+
+ $payload = FormMigrationPayload::fromFormV2($formV2);
+
+ $convertkit = new ConvertKit($payload);
+
+ $convertkit->process();
+
+ $block = $payload->formV3->blocks->findByName('givewp-convertkit/convertkit');
+
+ $this->assertSame($meta['_give_convertkit_custom_label'], $block->getAttribute('label'));
+ $this->assertSame($meta['_give_convertkit_tags'], $block->getAttribute('tagSubscribers'));
+ $this->assertSame($meta['_give_convertkit'], $block->getAttribute('selectedForm'));
+ $this->assertTrue(true, $block->getAttribute('defaultChecked'));
+ }
+
+ /**
+ * @unreleased
+ */
+ public function testProcessShouldUpdateConvertkitBlockAttributesFromGlobalSettings(): void
+ {
+ $meta = [
+ 'give_convertkit_label' => __('Subscribe to newsletter?', 'give'),
+ 'give_convertkit_list' => '6352843',
+ '_give_convertkit_tags' => ['4619079', '4619080'],
+ 'give_convertkit_checked_default' => true,
+ ];
+
+ foreach ($meta as $key => $value) {
+ give_update_option($key, $value);
+ }
+
+ $formV2 = $this->createSimpleDonationForm(['meta' => $meta]);
+
+ $payload = FormMigrationPayload::fromFormV2($formV2);
+
+ $convertkit = new ConvertKit($payload);
+
+ $convertkit->process();
+
+ $block = $payload->formV3->blocks->findByName('givewp-convertkit/convertkit');
+
+ $this->assertSame($meta['give_convertkit_label'], $block->getAttribute('label'));
+ $this->assertSame($meta['give_convertkit_list'], $block->getAttribute('selectedForm'));
+ $this->assertSame($meta['_give_convertkit_tags'], $block->getAttribute('tagSubscribers'));
+ $this->assertTrue(true, $block->getAttribute('defaultChecked'));
+ }
+
+ /**
+ * @unreleased
+ */
+ public function testProcessShouldUpdateConvertkitBlockAttributesWhenNoMeta(): void
+ {
+ $formV2 = $this->createSimpleDonationForm();
+
+ $payload = FormMigrationPayload::fromFormV2($formV2);
+
+ $convertkit = new ConvertKit($payload);
+
+ $convertkit->process();
+
+ $block = $payload->formV3->blocks->findByName('givewp-convertkit/convertkit');
+
+ $this->assertSame(__('Subscribe to newsletter?', 'give'), $block->getAttribute('label'));
+ $this->assertSame('', $block->getAttribute('selectedForm'));
+ $this->assertNull(null, $block->getAttribute('tagSubscribers'));
+ $this->assertTrue(true, $block->getAttribute('defaultChecked'));
+ }
+}