Completed
Push — issues/1122 ( 0db41a )
by Ravinder
16:39
created

Give_Settings_Gateways   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 198
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 198
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
B get_settings() 0 161 4
A get_sections() 0 9 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 13.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Give Settings Page/Tab
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Settings_Gateways
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       1.8
10
 */
11
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Settings_Gateways' ) ) :
17
18
	/**
19
	 * Give_Settings_Gateways.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Settings_Gateways extends Give_Settings_Page {
24
25
		/**
26
		 * Constructor.
27
		 */
28
		public function __construct() {
29
			$this->id    = 'gateways';
30
			$this->label = esc_html__( 'Payment Gateways', 'give' );
31
32
			$this->default_tab = 'gateways-settings';
33
34
			parent::__construct();
35
		}
36
37
		/**
38
		 * Get settings array.
39
		 *
40
		 * @since  1.8
41
		 * @return array
42
		 */
43
		public function get_settings() {
44
			$settings        = array();
45
			$current_section = give_get_current_setting_section();
46
47
			switch ( $current_section ) {
48
				case 'paypal-standard':
49
					$settings = array(
50
						// Section 2: Paypal Standard.
51
						array(
52
							'type' => 'title',
53
							'id'   => 'give_title_gateway_settings_2',
54
						),
55
						array(
56
							'name' => esc_html__( 'PayPal Email', 'give' ),
57
							'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ),
58
							'id'   => 'paypal_email',
59
							'type' => 'email',
60
						),
61
						array(
62
							'name' => esc_html__( 'PayPal Page Style', 'give' ),
63
							'desc' => esc_html__( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ),
64
							'id'   => 'paypal_page_style',
65
							'type' => 'text',
66
						),
67
						array(
68
							'name'    => esc_html__( 'PayPal Transaction Type', 'give' ),
69
							'desc'    => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
70
							'id'      => 'paypal_button_type',
71
							'type'    => 'radio_inline',
72
							'options' => array(
73
								'donation' => esc_html__( 'Donation', 'give' ),
74
								'standard' => esc_html__( 'Standard Transaction', 'give' )
75
							),
76
							'default' => 'donation',
77
						),
78
						array(
79
							'name'    => esc_html__( 'PayPal IPN Verification', 'give' ),
80
							'desc'    => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
81
							'id'      => 'paypal_verification',
82
							'type'    => 'radio_inline',
83
							'default' => 'enabled',
84
							'options' => array(
85
								'enabled'  => __( 'Enabled', 'give' ),
86
								'disabled' => __( 'Disabled', 'give' ),
87
							)
88
						),
89
						array(
90
							'type' => 'sectionend',
91
							'id'   => 'give_title_gateway_settings_2',
92
						)
93
					);
94
					break;
95
96
				case 'offline-donations' :
97
					$settings = array(
98
						// Section 3: Offline gateway.
99
						array(
100
							'type' => 'title',
101
							'id'   => 'give_title_gateway_settings_3',
102
						),
103
						array(
104
							'name'    => esc_html__( 'Collect Billing Details', 'give' ),
105
							'desc'    => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
106
							'id'      => 'give_offline_donation_enable_billing_fields',
107
							'type'    => 'radio_inline',
108
							'default' => 'disabled',
109
							'options' => array(
110
								'enabled'  => __( 'Enabled', 'give' ),
111
								'disabled' => __( 'Disabled', 'give' )
112
							)
113
						),
114
						array(
115
							'name'    => esc_html__( 'Offline Donation Instructions', 'give' ),
116
							'desc'    => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
117
							'id'      => 'global_offline_donation_content',
118
							'default' => give_get_default_offline_donation_content(),
119
							'type'    => 'wysiwyg',
120
							'options' => array(
121
								'textarea_rows' => 6,
122
							)
123
						),
124
						array(
125
							'name'    => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ),
126
							'desc'    => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ),
127
							'id'      => 'offline_donation_subject',
128
							'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
129
							'type'    => 'text'
130
						),
131
						array(
132
							'name'    => esc_html__( 'Offline Donation Email Instructions', 'give' ),
133
							'desc'    => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
134
							'id'      => 'global_offline_donation_email',
135
							'default' => give_get_default_offline_donation_email_content(),
136
							'type'    => 'wysiwyg',
137
							'options' => array(
138
								'textarea_rows' => 6,
139
							)
140
						),
141
						array(
142
							'type' => 'sectionend',
143
							'id'   => 'give_title_gateway_settings_3',
144
						)
145
					);
146
					break;
147
148
				case 'gateways-settings':
149
					$settings = array(
150
						// Section 1: Gateways.
151
						array(
152
							'id'   => 'give_title_gateway_settings_1',
153
							'type' => 'title'
154
						),
155
						array(
156
							'name'    => esc_html__( 'Test Mode', 'give' ),
157
							'desc'    => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
158
							'id'      => 'test_mode',
159
							'type'    => 'radio_inline',
160
							'default' => 'disabled',
161
							'options' => array(
162
								'enabled'  => __( 'Enabled', 'give' ),
163
								'disabled' => __( 'Disabled', 'give' ),
164
							)
165
						),
166
						array(
167
							'name' => esc_html__( 'Enabled Gateways', 'give' ),
168
							'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
169
							'id'   => 'gateways',
170
							'type' => 'enabled_gateways'
171
						),
172
						array(
173
							'name' => esc_html__( 'Default Gateway', 'give' ),
174
							'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ),
175
							'id'   => 'default_gateway',
176
							'type' => 'default_gateway'
177
						),
178
						array(
179
							'id'   => 'give_title_gateway_settings_1',
180
							'type' => 'sectionend'
181
						),
182
					);
183
					break;
184
			}
185
186
			/**
187
			 * Filter the payment gateways settings.
188
			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
189
			 */
190
			$settings = apply_filters( 'give_settings_gateways', $settings );
191
192
			/**
193
			 * Filter the settings.
194
			 *
195
			 * @since  1.8
196
			 *
197
			 * @param  array $settings
198
			 */
199
			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
200
201
			// Output.
202
			return $settings;
203
		}
204
205
		/**
206
		 * Get sections.
207
		 *
208
		 * @since 1.8
209
		 * @return array
210
		 */
211
		public function get_sections() {
212
			$sections = array(
213
				'gateways-settings' => esc_html__( 'Gateways', 'give' ),
214
				'paypal-standard'   => esc_html__( 'Paypal Standard', 'give' ),
215
				'offline-donations' => esc_html__( 'Offline', 'give' )
216
			);
217
218
			return apply_filters( 'give_get_sections_' . $this->id, $sections );
219
		}
220
	}
221
222
endif;
223
224
return new Give_Settings_Gateways();
225