PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationForms / Actions / ConvertConsentBlockToFieldsApi.php

ConvertConsentBlockToFieldsApi.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/Actions/ConvertConsentBlockToFieldsApi.php

61 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\Actions;
4
5 use Give\Framework\Blocks\BlockModel;
6 use Give\Framework\FieldsAPI\Consent;
7
8 class ConvertConsentBlockToFieldsApi
9 {
10 /**
11 * @since 3.0.0
12 */
13 public function __invoke(BlockModel $block, int $blockIndex)
14 {
15 return Consent::make('consent' . '-' . $blockIndex)
16 ->tap(function (Consent $consentField) use ($block) {
17 if ($block->getAttribute('useGlobalSettings')) {
18 $this->setGlobalAttributes($consentField);
19 } else {
20 $this->setPerFormAttributes($consentField, $block);
21 }
22
23 return $consentField;
24 });
25 }
26
27 /**
28 * @since 3.0.0
29 *
30 * @return void
31 */
32 private function setGlobalAttributes(Consent $field)
33 {
34 $field
35 ->useGlobalSettings(true)
36 ->checkboxLabel(give_get_option('agree_to_terms_label'))
37 ->displayType('showFormTerms')
38 ->linkText(__('Show terms', 'give'))
39 ->agreementText(give_get_option('agreement_text'));
40 }
41
42 /**
43 * @since 3.0.0
44 *
45 * @return void
46 */
47 private function setPerFormAttributes(Consent $field, BlockModel $block)
48 {
49 $field
50 ->useGlobalSettings(false)
51 ->checkboxLabel($block->getAttribute('checkboxLabel'))
52 ->displayType($block->getAttribute('displayType'))
53 ->linkText($block->getAttribute('linkText'))
54 ->linkUrl($block->getAttribute('linkUrl'))
55 ->modalHeading($block->getAttribute('modalHeading'))
56 ->modalAcceptanceText($block->getAttribute('modalAcceptanceText'))
57 ->agreementText($block->getAttribute('agreementText'));
58 }
59
60 }
61