PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.2
GiveWP – Donation Plugin and Fundraising Platform v4.15.2
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 2.31.0 2.31.1 All 253 releases
give / src / FormMigration / DataTransferObjects / DonationSummarySettings.php
DonationSummarySettings.php
63 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\FormMigration\DataTransferObjects;
4
5 /**
6 * The `Sequoia` and `Classic` templates share a structure for Donation Summary settings.
7 *
8 * @since 3.0.0
9 */
10 class DonationSummarySettings
11 {
12 /** @var bool */
13 protected $enabled;
14
15 /** @var string */
16 protected $heading;
17
18 /** @var string */
19 protected $location;
20
21 /**
22 * @param string $enabled `donation_summary_enabled` A string value of `enabled` or `disabled`.
23 * @param string $heading `donation_summary_heading` ie 'Here\'s what you\'re about to donate:'
24 * @param string $location `donation_summary_location` A string representing a corresponding template hook.
25 */
26 public function __construct($enabled, $heading, $location)
27 {
28 $this->enabled = give_is_setting_enabled($enabled);
29 $this->heading = $heading;
30 $this->location = $location;
31 }
32
33 public static function make($settings)
34 {
35 return new self(
36 $settings['donation_summary_enabled'],
37 $settings['donation_summary_enabled'],
38 $settings['donation_summary_location']
39 );
40 }
41
42 public function getHeading(): string
43 {
44 return $this->heading ?: __('Donation Summary', 'give');
45 }
46
47 public function isEnabled(): bool
48 {
49 return $this->enabled;
50 }
51
52 /**
53 * @since 3.0.0
54 *
55 * @note `give_donation_form_user_info` is presented as "Before payment fields".
56 * @note `give_donation_form_before_submit` is the default location, presented as "After payment fields".
57 */
58 public function isBeforePaymentFields(): bool
59 {
60 return 'give_donation_form_user_info' === $this->location;
61 }
62 }
63