| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\FormMigration\Steps; |
| 4 |
|
| 5 |
use Give\FormMigration\Contracts\FormMigrationStep; |
| 6 |
use Give\Framework\Blocks\BlockModel; |
| 7 |
|
| 8 |
/** |
| 9 |
* @since 3.3.0 |
| 10 |
*/ |
| 11 |
class Mailchimp extends FormMigrationStep |
| 12 |
{ |
| 13 |
/** |
| 14 |
* @since 3.3.0 |
| 15 |
*/ |
| 16 |
public function canHandle(): bool |
| 17 |
{ |
| 18 |
return $this->formV2->isMailchimpEnabled(); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* @since 3.3.0 |
| 23 |
*/ |
| 24 |
public function process(): void |
| 25 |
{ |
| 26 |
$block = BlockModel::make([ |
| 27 |
'name' => 'givewp/mailchimp', |
| 28 |
'attributes' => $this->getAttributes(), |
| 29 |
]); |
| 30 |
|
| 31 |
$this->fieldBlocks->insertAfter('givewp/email', $block); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @since 3.3.0 |
| 36 |
*/ |
| 37 |
private function getAttributes(): array |
| 38 |
{ |
| 39 |
return [ |
| 40 |
'label' => $this->formV2->getMailchimpLabel(), |
| 41 |
'checked' => $this->formV2->getMailchimpDefaultChecked(), |
| 42 |
'doubleOptIn' => give_get_option('give_mailchimp_double_opt_in', true), |
| 43 |
'subscriberTags' => $this->formV2->getMailchimpSubscriberTags(), |
| 44 |
'sendDonationData' => $this->formV2->getMailchimpSendDonationData(), |
| 45 |
'sendFFMData' => $this->formV2->getMailchimpSendFFMData(), |
| 46 |
'defaultAudiences' => $this->formV2->getMailchimpDefaultAudiences(), |
| 47 |
]; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
|