-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add Gift Aid migration step (#7186)
- Loading branch information
1 parent
6ee0c8c
commit f1784a3
Showing
3 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Give\FormMigration\Steps; | ||
|
||
use Give\FormMigration\Contracts\FormMigrationStep; | ||
use Give\Framework\Blocks\BlockModel; | ||
|
||
class GiftAid extends FormMigrationStep | ||
{ | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @return void | ||
*/ | ||
public function process() | ||
{ | ||
$giftAidStatus = $this->formV2->getGiftAidStatus(); | ||
$useGlobalSettings = $giftAidStatus === 'global'; | ||
|
||
if (empty($giftAidStatus) || ( | ||
$useGlobalSettings === true && | ||
!give_is_setting_enabled(give_get_option('give_gift_aid_enable_disable', 'disabled')) | ||
) || !in_array($giftAidStatus, ['enabled', 'global'], true)) { | ||
return; | ||
} | ||
|
||
$giftAidSettings = [ | ||
'useGlobalSettings' => $useGlobalSettings, | ||
'title' => $this->formV2->getGiftAidTitle(), | ||
'description' => $this->formV2->getGiftAidDescription(), | ||
'longExplanationEnabled' => $this->formV2->getGiftAidLongExplanationEnabled(), | ||
'linkText' => __('Tell me more', 'give-gift-aid'), | ||
'modalHeader' => __('What is Gift Aid?', 'give-gift-aid'), | ||
'longExplanation' => $this->formV2->getGiftAidLongExplanation(), | ||
'checkboxLabel' => $this->formV2->getGiftAidCheckboxLabel(), | ||
'agreementText' => $this->formV2->getGiftAidAgreementText(), | ||
'declarationForm' => $this->formV2->getGiftAidDeclarationForm(), | ||
]; | ||
|
||
$giftAidBlock = BlockModel::make([ | ||
'name' => 'givewp-gift-aid/gift-aid', | ||
'attributes' => $giftAidSettings, | ||
]); | ||
$this->fieldBlocks->insertAfter('givewp/donation-amount', $giftAidBlock); | ||
} | ||
} |