| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\FormMigration\Steps; |
| 4 |
|
| 5 |
use Give\FormMigration\Contracts\FormMigrationStep; |
| 6 |
use Give\Framework\Blocks\BlockModel; |
| 7 |
|
| 8 |
class GiftAid extends FormMigrationStep |
| 9 |
{ |
| 10 |
|
| 11 |
/** |
| 12 |
* @since 3.4.0 |
| 13 |
* |
| 14 |
* @return void |
| 15 |
*/ |
| 16 |
public function process() |
| 17 |
{ |
| 18 |
$giftAidStatus = $this->formV2->getGiftAidStatus(); |
| 19 |
$useGlobalSettings = $giftAidStatus === 'global'; |
| 20 |
|
| 21 |
if (empty($giftAidStatus) || ( |
| 22 |
$useGlobalSettings === true && |
| 23 |
!give_is_setting_enabled(give_get_option('give_gift_aid_enable_disable', 'disabled')) |
| 24 |
) || !in_array($giftAidStatus, ['enabled', 'global'], true)) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
$giftAidSettings = [ |
| 29 |
'useGlobalSettings' => $useGlobalSettings, |
| 30 |
'title' => $this->formV2->getGiftAidTitle(), |
| 31 |
'description' => $this->formV2->getGiftAidDescription(), |
| 32 |
'longExplanationEnabled' => $this->formV2->getGiftAidLongExplanationEnabled(), |
| 33 |
'linkText' => __('Tell me more', 'give-gift-aid'), |
| 34 |
'modalHeader' => __('What is Gift Aid?', 'give-gift-aid'), |
| 35 |
'longExplanation' => $this->formV2->getGiftAidLongExplanation(), |
| 36 |
'checkboxLabel' => $this->formV2->getGiftAidCheckboxLabel(), |
| 37 |
'agreementText' => $this->formV2->getGiftAidAgreementText(), |
| 38 |
'declarationForm' => $this->formV2->getGiftAidDeclarationForm(), |
| 39 |
]; |
| 40 |
|
| 41 |
$giftAidBlock = BlockModel::make([ |
| 42 |
'name' => 'givewp-gift-aid/gift-aid', |
| 43 |
'attributes' => $giftAidSettings, |
| 44 |
]); |
| 45 |
$this->fieldBlocks->insertAfter('givewp/donation-amount', $giftAidBlock); |
| 46 |
} |
| 47 |
} |
| 48 |
|