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 / PaymentGateways / PaypalSettingPage.php

PaypalSettingPage.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/PaymentGateways/PaypalSettingPage.php

137 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\PaymentGateways;
4
5 use Give\PaymentGateways\Gateways\PayPalStandard\PayPalStandard;
6 use Give\PaymentGateways\PayPalCommerce\AdminSettingFields;
7 use Give\PaymentGateways\PayPalCommerce\PayPalCommerce;
8
9 use function give_get_current_setting_section as getCurrentSettingSection;
10
11 /**
12 * Class PaypalSettingSection
13 * @package Give\PaymentGateways
14 *
15 * @sicne 2.9.0
16 */
17 class PaypalSettingPage implements SettingPage
18 {
19 /**
20 * @var PayPalCommerce
21 */
22 private $payPalCommerce;
23
24 /**
25 * @var PayPalStandard
26 */
27 private $paypalStandard;
28
29 /**
30 * Register properties
31 *
32 * @since 2.9.0
33 *
34 * @param PayPalStandard $paypalStandard
35 *
36 * @param PayPalCommerce $payPalCommerce
37 */
38 public function __construct(PayPalCommerce $payPalCommerce, PayPalStandard $paypalStandard)
39 {
40 $this->payPalCommerce = $payPalCommerce;
41 $this->paypalStandard = $paypalStandard;
42 }
43
44 /**
45 * @inheritDoc
46 */
47 public function boot()
48 {
49 add_action('give_get_groups_paypal', [$this, 'getGroups']);
50 add_filter('give_get_settings_gateways', [$this, 'registerPaypalSettings']);
51 add_filter('give_get_sections_gateways', [$this, 'registerPaypalSettingSection'], 5);
52
53 // Load custom setting fields.
54 /* @var AdminSettingFields $adminSettingFields */
55 $adminSettingFields = give(AdminSettingFields::class);
56 $adminSettingFields->boot();
57 }
58
59 /**
60 * @inheritDoc
61 */
62 public function getId()
63 {
64 return 'paypal';
65 }
66
67 /**
68 * @inheritDoc
69 */
70 public function getName()
71 {
72 return esc_html__('PayPal', 'give');
73 }
74
75 /**
76 * @inheritDoc
77 */
78 public function getSettings()
79 {
80 $settings[$this->payPalCommerce::id()] = $this->payPalCommerce->getOptions();
81 $settings[$this->paypalStandard::id()] = $this->paypalStandard->getOptions();
82
83 return $settings;
84 }
85
86 /**
87 * Get groups.
88 *
89 * @since 2.9.0
90 *
91 * @return array
92 */
93 public function getGroups()
94 {
95 return [
96 $this->payPalCommerce::id() => $this->payPalCommerce->getName(),
97 $this->paypalStandard::id() => $this->paypalStandard->getName(),
98 ];
99 }
100
101 /**
102 * Register settings.
103 *
104 * @since 2.9.0
105 *
106 * @param array $settings
107 *
108 * @return array
109 */
110 public function registerPaypalSettings($settings)
111 {
112 $currentSection = getCurrentSettingSection();
113
114 if ($currentSection === $this->getId()) {
115 $settings = $this->getSettings();
116 }
117
118 return $settings;
119 }
120
121 /**
122 * Register setting section.
123 *
124 * @since 2.9.0
125 *
126 * @param array $sections
127 *
128 * @return array
129 */
130 public function registerPaypalSettingSection($sections)
131 {
132 $sections[$this->getId()] = $this->getName();
133
134 return $sections;
135 }
136 }
137