Skip to content

Commit

Permalink
Fix: 'Any' string made translatable in 3 php files (#7513)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle B. Johnson <[email protected]>
Co-authored-by: Jon Waldstein <[email protected]>
Co-authored-by: Paulo Iankoski <[email protected]>
  • Loading branch information
4 people authored Aug 23, 2024
1 parent 07104dd commit 5331257
Show file tree
Hide file tree
Showing 17 changed files with 371 additions and 276 deletions.
4 changes: 2 additions & 2 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
* Author: GiveWP
* Author URI: https://givewp.com/
* Version: 3.15.0
* Version: 3.15.1
* Requires at least: 6.4
* Requires PHP: 7.2
* Text Domain: give
Expand Down Expand Up @@ -406,7 +406,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.15.0');
define('GIVE_VERSION', '3.15.1');
}

// Plugin Root File.
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: donation, donate, recurring donations, fundraising, crowdfunding
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 7.2
Stable tag: 3.15.0
Stable tag: 3.15.1
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -262,6 +262,9 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri
10. Use almost any payment gateway integration with GiveWP through our add-ons or by creating your own add-on.

== Changelog ==
= 3.15.1: Aug 22nd, 2024 =
* Fix: Resolved an issue with the Akismet integration preventing form submissions when settings are not yet configured

= 3.15.0: Aug 14th, 2024 =
* New: Added Akismet integration support to forms using the visual form builder
* New: Updated the onboarding wizard to create a new form with the visual form builder
Expand Down
3 changes: 2 additions & 1 deletion src/DonationSpam/EmailAddressWhiteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class EmailAddressWhiteList
protected $whitelistEmails;

/**
* @since 3.15.1 Add array type to enforce type.
* @since 3.15.0
*/
public function __construct($whitelistEmails = [])
public function __construct(array $whitelistEmails = [])
{
$this->whitelistEmails = $whitelistEmails;
}
Expand Down
6 changes: 5 additions & 1 deletion src/DonationSpam/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ class ServiceProvider implements ServiceProviderInterface
*/
public function register(): void
{
/**
* @since 3.15.1 Case filtered value as an array to enforce type.
* @since 3.15.0
*/
give()->singleton(EmailAddressWhiteList::class, function () {
return new EmailAddressWhiteList(
apply_filters( 'give_akismet_whitelist_emails', give_akismet_get_whitelisted_emails() )
(array) apply_filters( 'give_akismet_whitelist_emails', give_akismet_get_whitelisted_emails() )
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Donations/DonationsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function getForms()
return array_merge([
[
'value' => '0',
'text' => 'Any',
'text' => __('Any', 'give'),
],
], $options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Donors/DonorsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function getForms()
return array_merge([
[
'value' => '0',
'text' => 'Any',
'text' => __('Any', 'give'),
],
], $options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/FormMigration/FormMetaDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public function isConvertKitEnabled(): bool
$isGloballyEnabled = $this->getMeta('_give_convertkit_override_option') === 'default' &&
give_is_setting_enabled(give_get_option('give_convertkit_show_subscribe_checkbox'));

return $isFormEnabled ? $isGloballyEnabled : $isFormDisabled;
return ! ($isFormDisabled || ( ! $isGloballyEnabled && ! $isFormEnabled));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Subscriptions/SubscriptionsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function getForms()
return array_merge([
[
'value' => '0',
'text' => 'Any',
'text' => __('Any', 'give'),
]
], $options);
}
Expand Down
122 changes: 67 additions & 55 deletions tests/Feature/FormMigration/Steps/TestActiveCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,106 @@

namespace Give\Tests\Feature\FormMigration\Steps;

use Give\FormMigration\DataTransferObjects\FormMigrationPayload;
use Give\FormMigration\Steps\ActiveCampaign;
use Give\Tests\TestCase;
use Give\Tests\TestTraits\RefreshDatabase;
use Give\Tests\Unit\DonationForms\TestTraits\LegacyDonationFormAdapter;
use Give\Tests\Unit\FormMigration\TestTraits\FormMigrationProcessor;

class TestActiveCampaign extends TestCase
{
use RefreshDatabase, LegacyDonationFormAdapter;
use FormMigrationProcessor;
use LegacyDonationFormAdapter;
use RefreshDatabase;

/**
* @since 3.10.0
* @unreleased
*/
public function testProcessShouldUpdateActiveCampaignBlockAttributesFromV2FormMeta(): void
public function testFormConfiguredToUseGlobalActiveCampaignSettingsMigratesUsingGlobalSettingsWhenGloballyEnabled()
{
$meta = [
'give_activecampaign_label' => __('Subscribe to our newsletter?'),
'give_activecampaign_lists' => ['1', '2'],
'give_activecampaign_tags' => ['tag 1', 'tag 2'],
// Arrange
$options = [
'give_activecampaign_globally_enabled' => 'on',
'give_activecampaign_label' => __('Subscribe to our newsletter?'),
'give_activecampaign_lists' => ['1', '2'],
'give_activecampaign_tags' => ['tag 1', 'tag 2'],
'give_activecampaign_checkbox_default' => true,
];
foreach ($options as $key => $value) {
give_update_option($key, $value);
}
$meta = ['activecampaign_per_form_options' => 'global'];
$v2Form = $this->createSimpleDonationForm(['meta' => $meta]);

$formV2 = $this->createSimpleDonationForm(['meta' => $meta]);

$payload = FormMigrationPayload::fromFormV2($formV2);

$mailchimp = new ActiveCampaign($payload);

$mailchimp->process();

$block = $payload->formV3->blocks->findByName('give-activecampaign/activecampaign');
// Act
$v3Form = $this->migrateForm($v2Form, ActiveCampaign::class);

$this->assertSame($meta['give_activecampaign_label'], $block->getAttribute('label'));
$this->assertSame($meta['give_activecampaign_lists'], $block->getAttribute('selectedLists'));
$this->assertSame($meta['give_activecampaign_tags'], $block->getAttribute('selectedTags'));
// Assert
$block = $v3Form->blocks->findByName('give-activecampaign/activecampaign');
$this->assertSame($options['give_activecampaign_label'], $block->getAttribute('label'));
$this->assertSame($options['give_activecampaign_lists'], $block->getAttribute('selectedLists'));
$this->assertSame($options['give_activecampaign_tags'], $block->getAttribute('selectedTags'));
$this->assertTrue(true, $block->getAttribute('defaultChecked'));
}

/**
* @since 3.10.0
* @unreleased
*/
public function testProcessShouldUpdateActiveCampaignBlockAttributesFromGlobalSettings(): void
public function testFormConfiguredToUseGlobalActiveCampaignSettingsIsMigratedWithoutActiveCampaignBlockWhenNotGloballyEnabled()
{
$meta = [
'give_activecampaign_label' => __('Subscribe to our newsletter?'),
'give_activecampaign_lists' => ['1', '2'],
'give_activecampaign_tags' => ['tag 1', 'tag 2'],
'give_activecampaign_checkbox_default' => true,
];

foreach ($meta as $key => $value) {
give_update_option($key, $value);
}

$formV2 = $this->createSimpleDonationForm(['meta' => $meta]);
// Arrange
give_update_option('give_activecampaign_globally_enabled', 'off');
$meta = ['activecampaign_per_form_options' => 'global'];
$v2Form = $this->createSimpleDonationForm(['meta' => $meta]);

$payload = FormMigrationPayload::fromFormV2($formV2);
// Act
$v3Form = $this->migrateForm($v2Form, ActiveCampaign::class);

$mailchimp = new ActiveCampaign($payload);

$mailchimp->process();

$block = $payload->formV3->blocks->findByName('give-activecampaign/activecampaign');

$this->assertSame($meta['give_activecampaign_label'], $block->getAttribute('label'));
$this->assertSame($meta['give_activecampaign_lists'], $block->getAttribute('selectedLists'));
$this->assertSame($meta['give_activecampaign_tags'], $block->getAttribute('selectedTags'));
$this->assertTrue(true, $block->getAttribute('defaultChecked'));
// Assert
$block = $v3Form->blocks->findByName('give-activecampaign/activecampaign');
$this->assertNull($block);
}

/**
* @since 3.10.0
* @unreleased
*/
public function testProcessShouldUpdateActiveCampaignBlockAttributesWhenNoMeta(): void
public function testFormConfiguredToDisableActiveCampaignIsMigratedWithoutActiveCampaignBlock()
{
$formV2 = $this->createSimpleDonationForm();
// Arrange
$meta = ['activecampaign_per_form_options' => 'disabled'];
$v2Form = $this->createSimpleDonationForm(['meta' => $meta]);

$payload = FormMigrationPayload::fromFormV2($formV2);
// Act
$v3Form = $this->migrateForm($v2Form, ActiveCampaign::class);

$mailchimp = new ActiveCampaign($payload);
// Assert
$block = $v3Form->blocks->findByName('give-activecampaign/activecampaign');
$this->assertNull($block);
}

$mailchimp->process();
/**
* @unreleased
*/
public function testFormConfiguredToUseCustomizedActiveCampaignSettingsIsMigrated()
{
// Arrange
$meta = [
'activecampaign_per_form_options' => 'customized',
'give_activecampaign_label' => __('Subscribe to our newsletter?'),
'give_activecampaign_lists' => ['1', '2'],
'give_activecampaign_tags' => ['tag 1', 'tag 2'],
'give_activecampaign_checkbox_default' => true,
];
$v2Form = $this->createSimpleDonationForm(['meta' => $meta]);

$block = $payload->formV3->blocks->findByName('give-activecampaign/activecampaign');
// Act
$v3Form = $this->migrateForm($v2Form, ActiveCampaign::class);

$this->assertSame(__('Subscribe to our newsletter?'), $block->getAttribute('label'));
$this->assertSame([], $block->getAttribute('selectedLists'));
$this->assertNull(null, $block->getAttribute('selectedTags'));
// Assert
$block = $v3Form->blocks->findByName('give-activecampaign/activecampaign');
$this->assertSame($meta['give_activecampaign_label'], $block->getAttribute('label'));
$this->assertSame($meta['give_activecampaign_lists'], $block->getAttribute('selectedLists'));
$this->assertSame($meta['give_activecampaign_tags'], $block->getAttribute('selectedTags'));
$this->assertTrue(true, $block->getAttribute('defaultChecked'));
}
}
Loading

0 comments on commit 5331257

Please sign in to comment.