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
← All changes | includes/admin/settings/class-settings-general.php +671 -537 2.3.14.16.9 View file →
@@ -2,582 +2,716 @@
2 2 /**
3 3 * Give Settings Page/Tab
4 4 *
5 5 * @package Give
6 - * @subpackage Classes/Give_Settings_General
6 + * @since 1.8
7 7 * @copyright Copyright (c) 2016, GiveWP
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 - * @since 1.8
9 + * @subpackage Classes/Give_Settings_General
10 10 */
11 11
12 -if ( ! defined( 'ABSPATH' ) ) {
13 - exit; // Exit if accessed directly.
12 +if (!defined('ABSPATH')) {
13 + exit; // Exit if accessed directly.
14 14 }
15 15
16 -if ( ! class_exists( 'Give_Settings_General' ) ) :
16 +if (!class_exists('Give_Settings_General')) :
17 17
18 - /**
19 - * Give_Settings_General.
20 - *
21 - * @sine 1.8
22 - */
23 - class Give_Settings_General extends Give_Settings_Page {
18 + /**
19 + * Give_Settings_General.
20 + *
21 + * @sine 1.8
22 + */
23 + class Give_Settings_General extends Give_Settings_Page
24 + {
24 25
25 - /**
26 - * Constructor.
27 - */
28 - public function __construct() {
29 - $this->id = 'general';
30 - $this->label = __( 'General', 'give' );
26 + /**
27 + * Constructor.
28 + */
29 + public function __construct()
30 + {
31 + $this->id = 'general';
32 + $this->label = __('General', 'give');
31 33
32 - $this->default_tab = 'general-settings';
34 + $this->default_tab = 'general-settings';
33 35
34 - if ( $this->id === give_get_current_setting_tab() ) {
35 - add_action( 'give_save_settings_give_settings', array( $this, '_give_change_donation_stating_number' ), 10, 3 );
36 - add_action( 'give_admin_field_give_sequential_donation_code_preview', array( $this, '_render_give_sequential_donation_code_preview' ), 10, 3 );
37 - add_action( 'give_admin_field_give_currency_preview', array( $this, '_render_give_currency_preview' ), 10, 2 );
38 - add_action( 'give_admin_field_give_unlock_all_settings', array( $this, '_render_give_unlock_all_settings' ), 10, 3 );
39 - }
36 + if ($this->id === give_get_current_setting_tab()) {
37 + add_action('give_save_settings_give_settings', [$this, '_give_change_donation_stating_number'], 10, 3);
38 + add_action(
39 + 'give_admin_field_give_sequential_donation_code_preview',
40 + [$this, '_render_give_sequential_donation_code_preview'],
41 + 10,
42 + 3
43 + );
44 + add_action('give_admin_field_give_currency_preview', [$this, '_render_give_currency_preview'], 10, 2);
45 + add_action(
46 + 'give_admin_field_give_unlock_all_settings',
47 + [$this, '_render_give_unlock_all_settings'],
48 + 10,
49 + 3
50 + );
51 + }
40 52
41 - parent::__construct();
42 - }
53 + parent::__construct();
54 + }
43 55
44 - /**
45 - * Get settings array.
46 - *
47 - * @since 1.8
48 - * @return array
49 - */
50 - public function get_settings() {
51 - $settings = array();
52 - $current_section = give_get_current_setting_section();
56 + /**
57 + * Get settings array.
58 + *
59 + * @since 2.24.2 add auto_format_currency setting
60 + * @since 1.8
61 + *
62 + * @return array
63 + */
64 + public function get_settings()
65 + {
66 + $settings = [];
67 + $current_section = give_get_current_setting_section();
53 68
54 - switch ( $current_section ) {
55 - case 'access-control':
56 - $settings = array(
57 - // Section 3: Access control.
58 - array(
59 - 'id' => 'give_title_session_control_1',
60 - 'type' => 'title',
61 - ),
62 - array(
63 - 'id' => 'session_lifetime',
64 - 'name' => __( 'Session Lifetime', 'give' ),
65 - 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ),
66 - 'type' => 'select',
67 - 'options' => array(
68 - '86400' => __( '24 Hours', 'give' ),
69 - '172800' => __( '48 Hours', 'give' ),
70 - '259200' => __( '72 Hours', 'give' ),
71 - '604800' => __( '1 Week', 'give' ),
72 - ),
73 - ),
74 - array(
75 - 'id' => 'limit_display_donations',
76 - 'name' => __( 'Limit Donations Displayed', 'give' ),
77 - 'desc' => __( 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give' ),
78 - 'default' => '1',
79 - 'type' => 'number',
80 - 'css' => 'width:50px;',
81 - 'attributes' => array(
82 - 'min' => '1',
83 - 'max' => '10',
84 - ),
85 - ),
86 - array(
87 - 'name' => __( 'Email Access', 'give' ),
88 - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
89 - 'id' => 'email_access',
90 - 'type' => 'radio_inline',
91 - 'default' => 'disabled',
92 - 'options' => array(
93 - 'enabled' => __( 'Enabled', 'give' ),
94 - 'disabled' => __( 'Disabled', 'give' ),
95 - ),
96 - ),
97 - array(
98 - 'name' => __( 'Enable reCAPTCHA', 'give' ),
99 - 'desc' => __( 'Would you like to enable the reCAPTCHA feature?', 'give' ),
100 - 'id' => 'enable_recaptcha',
101 - 'type' => 'radio_inline',
102 - 'default' => 'disabled',
103 - 'options' => array(
104 - 'enabled' => __( 'Enabled', 'give' ),
105 - 'disabled' => __( 'Disabled', 'give' ),
106 - ),
107 - ),
108 - array(
109 - 'id' => 'recaptcha_key',
110 - 'name' => __( 'reCAPTCHA Site Key', 'give' ),
111 - /* translators: %s: https://www.google.com/recaptcha/ */
112 - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ),
113 - 'default' => '',
114 - 'type' => 'text',
115 - ),
116 - array(
117 - 'id' => 'recaptcha_secret',
118 - 'name' => __( 'reCAPTCHA Secret Key', 'give' ),
119 - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ),
120 - 'default' => '',
121 - 'type' => 'text',
122 - ),
123 - array(
124 - 'name' => __( 'Access Control Docs Link', 'give' ),
125 - 'id' => 'access_control_docs_link',
126 - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ),
127 - 'title' => __( 'Access Control', 'give' ),
128 - 'type' => 'give_docs_link',
129 - ),
130 - array(
131 - 'id' => 'give_title_session_control_1',
132 - 'type' => 'sectionend',
133 - ),
134 - );
135 - break;
69 + switch ($current_section) {
70 + case 'access-control':
71 + $settings = [
72 + // Section 3: Access control.
73 + [
74 + 'id' => 'give_title_session_control_1',
75 + 'type' => 'title',
76 + ],
77 + [
78 + 'id' => 'session_lifetime',
79 + 'name' => __('Session Lifetime', 'give'),
80 + 'desc' => __(
81 + 'The length of time a user\'s session is kept alive. GiveWP starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.',
82 + 'give'
83 + ),
84 + 'type' => 'select',
85 + 'options' => [
86 + '86400' => __('24 Hours', 'give'),
87 + '172800' => __('48 Hours', 'give'),
88 + '259200' => __('72 Hours', 'give'),
89 + '604800' => __('1 Week', 'give'),
90 + ],
91 + ],
92 + [
93 + 'id' => 'limit_display_donations',
94 + 'name' => __('Limit Donations Displayed', 'give'),
95 + 'desc' => __(
96 + 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.',
97 + 'give'
98 + ),
99 + 'default' => '1',
100 + 'type' => 'number',
101 + 'css' => 'width:50px;',
102 + 'attributes' => [
103 + 'min' => '1',
104 + 'max' => '10',
105 + ],
106 + ],
107 + [
108 + 'name' => __('Email Access', 'give'),
109 + 'desc' => __(
110 + 'If enabled, donors can access their donation history by verifying access to the email address used to donate. When they visit the donation history page, they input their email address and can access the site from a link in the resulting email.',
111 + 'give'
112 + ),
113 + 'id' => 'email_access',
114 + 'type' => 'radio_inline',
115 + 'default' => 'disabled',
116 + 'options' => [
117 + 'enabled' => __('Enabled', 'give'),
118 + 'disabled' => __('Disabled', 'give'),
119 + ],
120 + ],
121 + [
122 + 'name' => __('Enable reCAPTCHA', 'give'),
123 + 'desc' => __(
124 + 'If enabled, this option adds a reCAPTCHA field to the email access form. Note: this does not add reCAPTCHA to donation forms.',
125 + 'give'
126 + ),
127 + 'id' => 'enable_recaptcha',
128 + 'type' => 'radio_inline',
129 + 'default' => 'disabled',
130 + 'options' => [
131 + 'enabled' => __('Enabled', 'give'),
132 + 'disabled' => __('Disabled', 'give'),
133 + ],
134 + ],
135 + [
136 + 'id' => 'recaptcha_key',
137 + 'name' => __('reCAPTCHA Site Key', 'give'),
138 + /* translators: %s: https://www.google.com/recaptcha/ */
139 + 'desc' => sprintf(
140 + __(
141 + 'Navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.',
142 + 'give'
143 + ),
144 + esc_url('http://docs.givewp.com/recaptcha')
145 + ),
146 + 'default' => '',
147 + 'type' => 'text',
148 + ],
149 + [
150 + 'id' => 'recaptcha_secret',
151 + 'name' => __('reCAPTCHA Secret Key', 'give'),
152 + 'desc' => __(
153 + 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.',
154 + 'give'
155 + ),
156 + 'default' => '',
157 + 'type' => 'text',
158 + ],
159 + [
160 + 'name' => __('Access Control Docs Link', 'give'),
161 + 'id' => 'access_control_docs_link',
162 + 'url' => esc_url('http://docs.givewp.com/settings-access-control'),
163 + 'title' => __('Access Control', 'give'),
164 + 'type' => 'give_docs_link',
165 + ],
166 + [
167 + 'id' => 'give_title_session_control_1',
168 + 'type' => 'sectionend',
169 + ],
170 + ];
171 + break;
136 172
137 - case 'currency-settings' :
138 - $currency_position_before = __( 'Before - %s&#x200e;10', 'give' );
139 - $currency_position_after = __( 'After - 10%s&#x200f;', 'give' );
173 + case 'currency-settings':
174 + $currency_position_before = __('Before - %s&#x200e;10', 'give');
175 + $currency_position_after = __('After - 10%s&#x200f;', 'give');
140 176
141 - $settings = array(
142 - // Section 2: Currency
143 - array(
144 - 'type' => 'title',
145 - 'id' => 'give_title_general_settings_2',
146 - ),
147 - array(
148 - 'name' => __( 'Currency Settings', 'give' ),
149 - 'desc' => '',
150 - 'type' => 'give_title',
151 - 'id' => 'give_title_general_settings_2',
152 - ),
153 - array(
154 - 'name' => __( 'Currency', 'give' ),
155 - 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ),
156 - 'id' => 'currency',
157 - 'class' => 'give-select-chosen',
158 - 'type' => 'select',
159 - 'options' => give_get_currencies(),
160 - 'default' => 'USD',
161 - ),
162 - array(
163 - 'name' => __( 'Currency Position', 'give' ),
164 - 'desc' => __( 'The position of the currency symbol.', 'give' ),
165 - 'id' => 'currency_position',
166 - 'type' => 'select',
167 - 'options' => array(
168 - /* translators: %s: currency symbol */
169 - 'before' => sprintf( $currency_position_before, give_currency_symbol( give_get_currency() ) ),
170 - /* translators: %s: currency symbol */
171 - 'after' => sprintf( $currency_position_after, give_currency_symbol( give_get_currency() ) ),
172 - ),
173 - 'default' => 'before',
174 - 'attributes' => array(
175 - 'data-before-template' => sprintf( $currency_position_before, '{currency_pos}' ),
176 - 'data-after-template' => sprintf( $currency_position_after, '{currency_pos}' ),
177 - ),
178 - ),
179 - array(
180 - 'name' => __( 'Thousands Separator', 'give' ),
181 - 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ),
182 - 'id' => 'thousands_separator',
183 - 'type' => 'text',
184 - 'default' => ',',
185 - 'css' => 'width:12em;',
186 - ),
187 - array(
188 - 'name' => __( 'Decimal Separator', 'give' ),
189 - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
190 - 'id' => 'decimal_separator',
191 - 'type' => 'text',
192 - 'default' => '.',
193 - 'css' => 'width:12em;',
194 - ),
195 - array(
196 - 'name' => __( 'Number of Decimals', 'give' ),
197 - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ),
198 - 'id' => 'number_decimals',
199 - 'type' => 'text',
200 - 'default' => 2,
201 - 'css' => 'width:12em;',
202 - ),
203 - array(
204 - 'name' => __( 'Currency Preview', 'give' ),
205 - 'desc' => __( 'A preview of the formatted currency. This preview cannot be edited directly as it is generated from the settings above.', 'give' ),
206 - 'id' => 'currency_preview',
207 - 'type' => 'give_currency_preview',
208 - 'default' => give_format_amount( 123456.12345,
209 - array(
210 - 'sanitize' => false,
211 - 'currency' => give_get_option( 'currency' ),
212 - )
213 - ),
214 - 'css' => 'width:12em;',
215 - ),
216 - array(
217 - 'name' => __( 'Currency Options Docs Link', 'give' ),
218 - 'id' => 'currency_settings_docs_link',
219 - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ),
220 - 'title' => __( 'Currency Settings', 'give' ),
221 - 'type' => 'give_docs_link',
222 - ),
223 - array(
224 - 'type' => 'sectionend',
225 - 'id' => 'give_title_general_settings_2',
226 - ),
227 - );
177 + $hasIntlExtension = class_exists(NumberFormatter::class);
178 + $formatDisabledAttribute = $hasIntlExtension || give_get_option('auto_format_currency') ? [] : [
179 + 'disabled' => 'disabled',
180 + 'title' => __('This option is disabled because the PHP Intl extension is not installed.', 'give'),
181 + ];
228 182
229 - break;
183 + $settings = [
184 + // Section 2: Currency
185 + [
186 + 'type' => 'title',
187 + 'id' => 'give_title_general_settings_2',
188 + ],
189 + [
190 + 'name' => __('Currency Settings', 'give'),
191 + 'desc' => '',
192 + 'type' => 'give_title',
193 + 'id' => 'give_title_general_settings_2',
194 + ],
195 + [
196 + 'name' => __('Currency', 'give'),
197 + 'desc' => __(
198 + 'The donation currency. Note that some payment gateways have currency restrictions.',
199 + 'give'
200 + ),
201 + 'id' => 'currency',
202 + 'class' => 'give-select-chosen',
203 + 'type' => 'select',
204 + 'options' => give_get_currencies(),
205 + 'default' => 'USD',
206 + 'attributes' => [
207 + 'data-formatting-setting' => esc_js(wp_json_encode(give_get_currencies_list())),
208 + ],
209 + ],
210 + [
211 + 'name' => __('Auto-format server currency amounts', 'give'),
212 + 'desc' => sprintf(
213 + /* translators: %s: Link to the GiveWP docs. */
214 + __(
215 + 'If enabled, amounts are automatically formatted based on the selected currency. This option requires the intl extension for PHP. Read more about <a href="%s" target="_blank">this option and how GiveWP values internationalization in web applications.</a>',
216 + 'give'
217 + ),
218 + 'https://docs.givewp.com/currency-format'
219 + ),
220 + 'id' => 'auto_format_currency',
221 + 'type' => 'checkbox',
222 + 'attributes' => $formatDisabledAttribute,
223 + ],
224 + [
225 + 'name' => __('Currency Position', 'give'),
226 + 'desc' => __('The position of the currency symbol.', 'give'),
227 + 'id' => 'currency_position',
228 + 'type' => 'select',
229 + 'options' => [
230 + /* translators: %s: currency symbol */
231 + 'before' => sprintf(
232 + $currency_position_before,
233 + give_currency_symbol(give_get_currency())
234 + ),
235 + /* translators: %s: currency symbol */
236 + 'after' => sprintf($currency_position_after, give_currency_symbol(give_get_currency())),
237 + ],
238 + 'default' => 'before',
239 + 'attributes' => [
240 + 'data-before-template' => sprintf($currency_position_before, '{currency_pos}'),
241 + 'data-after-template' => sprintf($currency_position_after, '{currency_pos}'),
242 + ],
243 + ],
244 + [
245 + 'name' => __('Thousands Separator', 'give'),
246 + 'desc' => __('The symbol (typically , or .) to separate thousands.', 'give'),
247 + 'id' => 'thousands_separator',
248 + 'type' => 'text',
249 + 'default' => ',',
250 + 'css' => 'width:12em;',
251 + ],
252 + [
253 + 'name' => __('Decimal Separator', 'give'),
254 + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'),
255 + 'id' => 'decimal_separator',
256 + 'type' => 'text',
257 + 'default' => '.',
258 + 'css' => 'width:12em;',
259 + ],
260 + [
261 + 'name' => __('Number of Decimals', 'give'),
262 + 'desc' => __('The number of decimal points displayed in amounts.', 'give'),
263 + 'id' => 'number_decimals',
264 + 'type' => 'text',
265 + 'default' => 2,
266 + 'css' => 'width:12em;',
267 + ],
268 + [
269 + 'name' => __('Currency Preview', 'give'),
270 + 'desc' => __(
271 + 'A preview of the formatted currency. This preview cannot be edited directly as it is generated from the settings above.',
272 + 'give'
273 + ),
274 + 'id' => 'currency_preview',
275 + 'type' => 'give_currency_preview',
276 + 'default' => give_format_amount(
277 + 123456.12345,
278 + [
279 + 'sanitize' => false,
280 + 'currency' => give_get_option('currency'),
281 + ]
282 + ),
283 + 'css' => 'width:12em;',
284 + ],
285 + [
286 + 'name' => __('Currency Options Docs Link', 'give'),
287 + 'id' => 'currency_settings_docs_link',
288 + 'url' => esc_url('http://docs.givewp.com/settings-currency'),
289 + 'title' => __('Currency Settings', 'give'),
290 + 'type' => 'give_docs_link',
291 + ],
292 + [
293 + 'type' => 'sectionend',
294 + 'id' => 'give_title_general_settings_2',
295 + ],
296 + ];
230 297
231 - case 'general-settings':
232 - // Get default country code.
233 - $countries = give_get_country();
298 + break;
234 299
235 - // get the list of the states of which default country is selected.
236 - $states = give_get_states( $countries );
300 + case 'general-settings':
301 + // Get default country code.
302 + $countries = give_get_country();
237 303
238 - // Get the country list that does not have any states init.
239 - $no_states_country = give_no_states_country_list();
304 + // get the list of the states of which default country is selected.
305 + $states = give_get_states($countries);
240 306
241 - $states_label = give_get_states_label();
242 - $country = give_get_country();
243 - $label = __( 'State', 'give' );
244 - // Check if $country code exists in the array key for states label.
245 - if ( array_key_exists( $country, $states_label ) ) {
246 - $label = $states_label[ $country ];
247 - }
307 + // Get the country list that does not have any states init.
308 + $no_states_country = give_no_states_country_list();
248 309
310 + $states_label = give_get_states_label();
311 + $country = give_get_country();
312 + $label = __('State', 'give');
313 + // Check if $country code exists in the array key for states label.
314 + if (array_key_exists($country, $states_label)) {
315 + $label = $states_label[$country];
316 + }
249 317
250 - $settings = array(
251 - // Section 1: General.
252 - array(
253 - 'type' => 'title',
254 - 'id' => 'give_title_general_settings_1',
255 - ),
256 - array(
257 - 'name' => __( 'General Settings', 'give' ),
258 - 'desc' => '',
259 - 'type' => 'give_title',
260 - 'id' => 'give_title_general_settings_1',
261 - ),
262 - array(
263 - 'name' => __( 'Success Page', 'give' ),
264 - /* translators: %s: [give_receipt] */
265 - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
266 - 'id' => 'success_page',
267 - 'class' => 'give-select give-select-chosen',
268 - 'type' => 'select',
269 - 'options' => give_cmb2_get_post_options( array(
270 - 'post_type' => 'page',
271 - 'numberposts' => 30,
272 - ) ),
273 - 'attributes' => array(
274 - 'data-search-type' => 'pages',
275 - 'data-placeholder' => esc_html__('Choose a page', 'give'),
276 - )
277 - ),
278 - array(
279 - 'name' => __( 'Failed Donation Page', 'give' ),
280 - 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ),
281 - 'class' => 'give-select give-select-chosen',
282 - 'id' => 'failure_page',
283 - 'type' => 'select',
284 - 'options' => give_cmb2_get_post_options( array(
285 - 'post_type' => 'page',
286 - 'numberposts' => 30,
287 - ) ),
288 - 'attributes' => array(
289 - 'data-search-type' => 'pages',
290 - 'data-placeholder' => esc_html__('Choose a page', 'give'),
291 - )
292 - ),
293 - array(
294 - 'name' => __( 'Donation History Page', 'give' ),
295 - /* translators: %s: [donation_history] */
296 - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
297 - 'id' => 'history_page',
298 - 'class' => 'give-select give-select-chosen',
299 - 'type' => 'select',
300 - 'options' => give_cmb2_get_post_options( array(
301 - 'post_type' => 'page',
302 - 'numberposts' => 30,
303 - ) ),
304 - 'attributes' => array(
305 - 'data-search-type' => 'pages',
306 - 'data-placeholder' => esc_html__('Choose a page', 'give'),
307 - )
308 - ),
309 - array(
310 - 'name' => __( 'Base Country', 'give' ),
311 - 'desc' => __( 'The country your site operates from.', 'give' ),
312 - 'id' => 'base_country',
313 - 'type' => 'select',
314 - 'options' => give_get_country_list(),
315 - 'class' => 'give-select give-select-chosen',
316 - 'attributes' => array(
317 - 'data-search-type' => 'no_ajax'
318 - ),
319 - 'default' => $country,
320 - ),
321 - /**
322 - * Add base state to give setting
323 - *
324 - * @since 1.8.14
325 - */
326 - array(
327 - 'wrapper_class' => ( array_key_exists( $countries, $no_states_country ) ? 'give-hidden' : '' ),
328 - 'name' => __( 'Base State/Province', 'give' ),
329 - 'desc' => __( 'The state/province your site operates from.', 'give' ),
330 - 'id' => 'base_state',
331 - 'type' => ( empty( $states ) ? 'text' : 'select' ),
332 - 'class' => ( empty( $states ) ? '' : 'give-select give-select-chosen' ),
333 - 'options' => $states,
334 - 'attributes' => array(
335 - 'data-search-type' => 'no_ajax',
336 - 'data-placeholder' => $label,
337 - ),
338 - ),
339 - array(
340 - 'name' => __( 'General Options Docs Link', 'give' ),
341 - 'id' => 'general_options_docs_link',
342 - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ),
343 - 'title' => __( 'General Options', 'give' ),
344 - 'type' => 'give_docs_link',
345 - ),
346 - array(
347 - 'type' => 'sectionend',
348 - 'id' => 'give_title_general_settings_1',
349 - ),
350 - );
351 - break;
318 + $settings = [
319 + // Section 1: General.
320 + [
321 + 'type' => 'title',
322 + 'id' => 'give_title_general_settings_1',
323 + ],
324 + [
325 + 'name' => __('General Settings', 'give'),
326 + 'desc' => '',
327 + 'type' => 'give_title',
328 + 'id' => 'give_title_general_settings_1',
329 + ],
330 + [
331 + 'name' => __('Success Page', 'give'),
332 + /* translators: %s: [give_receipt] */
333 + 'desc' => sprintf(
334 + __(
335 + 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.',
336 + 'give'
337 + ),
338 + '<code>[give_receipt]</code>'
339 + ),
340 + 'id' => 'success_page',
341 + 'class' => 'give-select give-select-chosen',
342 + 'type' => 'select',
343 + 'options' => give_cmb2_get_post_options(
344 + [
345 + 'post_type' => 'page',
346 + 'numberposts' => 30,
347 + ]
348 + ),
349 + 'attributes' => [
350 + 'data-search-type' => 'pages',
351 + 'data-placeholder' => esc_html__('Choose a page', 'give'),
352 + ],
353 + ],
354 + [
355 + 'name' => __('Failed Donation Page', 'give'),
356 + 'desc' => __(
357 + 'The page donors are sent to if their donation is cancelled or fails.',
358 + 'give'
359 + ),
360 + 'class' => 'give-select give-select-chosen',
361 + 'id' => 'failure_page',
362 + 'type' => 'select',
363 + 'options' => give_cmb2_get_post_options(
364 + [
365 + 'post_type' => 'page',
366 + 'numberposts' => 30,
367 + ]
368 + ),
369 + 'attributes' => [
370 + 'data-search-type' => 'pages',
371 + 'data-placeholder' => esc_html__('Choose a page', 'give'),
372 + ],
373 + ],
374 + [
375 + 'name' => __('Donation History Page', 'give'),
376 + /* translators: %s: [donation_history] */
377 + 'desc' => sprintf(
378 + __(
379 + 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.',
380 + 'give'
381 + ),
382 + '<code>[donation_history]</code>'
383 + ),
384 + 'id' => 'history_page',
385 + 'class' => 'give-select give-select-chosen',
386 + 'type' => 'select',
387 + 'options' => give_cmb2_get_post_options(
388 + [
389 + 'post_type' => 'page',
390 + 'numberposts' => 30,
391 + ]
392 + ),
393 + 'attributes' => [
394 + 'data-search-type' => 'pages',
395 + 'data-placeholder' => esc_html__('Choose a page', 'give'),
396 + ],
397 + ],
398 + [
399 + 'name' => __('Base Country', 'give'),
400 + 'desc' => __('The country your site operates from.', 'give'),
401 + 'id' => 'base_country',
402 + 'type' => 'select',
403 + 'options' => give_get_country_list(),
404 + 'class' => 'give-select give-select-chosen',
405 + 'attributes' => [
406 + 'data-search-type' => 'no_ajax',
407 + 'data-placeholder' => esc_html__('Choose a country', 'give'),
408 + ],
409 + 'default' => $country,
410 + ],
411 + /**
412 + * Add base state to give setting
413 + *
414 + * @since 1.8.14
415 + */
416 + [
417 + 'wrapper_class' => (array_key_exists($countries, $no_states_country) ? 'give-hidden' : ''),
418 + 'name' => __('Base State/Province', 'give'),
419 + 'desc' => __('The state/province your site operates from.', 'give'),
420 + 'id' => 'base_state',
421 + 'type' => (empty($states) ? 'text' : 'select'),
422 + 'class' => (empty($states) ? '' : 'give-select give-select-chosen'),
423 + 'options' => $states,
424 + 'attributes' => [
425 + 'data-search-type' => 'no_ajax',
426 + 'data-placeholder' => $label,
427 + ],
428 + ],
429 + [
430 + 'name' => __('General Options Docs Link', 'give'),
431 + 'id' => 'general_options_docs_link',
432 + 'url' => esc_url('http://docs.givewp.com/settings-general'),
433 + 'title' => __('General Options', 'give'),
434 + 'type' => 'give_docs_link',
435 + ],
436 + [
437 + 'type' => 'sectionend',
438 + 'id' => 'give_title_general_settings_1',
439 + ],
440 + ];
441 + break;
352 442
353 - case 'sequential-ordering':
354 - $settings = array(
443 + case 'sequential-ordering':
444 + $settings = [
355 445
356 - // Section 4: Sequential Ordering
446 + // Section 4: Sequential Ordering
357 447
358 - array(
359 - 'id' => 'give_title_general_settings_4',
360 - 'type' => 'title'
361 - ),
362 - array(
363 - 'name' => __( 'Sequential Ordering', 'give' ),
364 - 'id' => "{$current_section}_status",
365 - 'desc' => __( 'Custom donation numbering that increases sequentially to prevent gaps between donation IDs. If disabled, then donation numbers are generated from WordPress post IDs, which will result in gaps between numbers.', 'give' ),
366 - 'type' => 'radio_inline',
367 - 'default' => 'disabled',
368 - 'options' => array(
369 - 'enabled' => __( 'Enabled', 'give' ),
370 - 'disabled' => __( 'Disabled', 'give' )
371 - )
372 - ),
373 - array(
374 - 'name' => __( 'Next Donation Number', 'give' ),
375 - 'id' => "{$current_section}_number",
376 - 'desc' => sprintf(
377 - __( 'The number used to generate the next donation ID. This value must be greater than or equal to %s to avoid conflicts with existing donation IDs.', 'give' ),
378 - '<code>' . Give()->seq_donation_number->get_next_number() . '</code>'
379 - ),
380 - 'type' => 'number',
381 - ),
382 - array(
383 - 'name' => __( 'Number Prefix', 'give' ),
384 - 'id' => "{$current_section}_number_prefix",
385 - 'desc' => sprintf(
386 - __( 'The prefix appended to all sequential donation numbers. Spaces are replaced by %s.', 'give' ),
387 - '<code>-</code>'
388 - ),
389 - 'type' => 'text',
390 - ),
391 - array(
392 - 'name' => __( 'Number Suffix', 'give' ),
393 - 'id' => "{$current_section}_number_suffix",
394 - 'desc' => sprintf(
395 - __( 'The suffix appended to all sequential donation numbers. Spaces are replaced by %s.', 'give' ),
396 - '<code>-</code>'
397 - ),
398 - 'type' => 'text',
399 - ),
400 - array(
401 - 'name' => __( 'Number Padding', 'give' ),
402 - 'id' => "{$current_section}_number_padding",
403 - 'desc' => sprintf(
404 - __( 'The minimum number of digits in the sequential donation number. Enter %s to display %s as %s.', 'give' ),
405 - '<code>4</code>',
406 - '<code>1</code>',
407 - '<code>0001</code>'
408 - ),
409 - 'type' => 'number',
410 - 'default' => '0',
411 - ),
412 - array(
413 - 'name' => __( 'Donation ID Preview', 'give' ),
414 - 'id' => "{$current_section}_preview",
415 - 'type' => 'give_sequential_donation_code_preview',
416 - 'desc' => __( 'A preview of the next sequential donation ID. This preview cannot be edited directly as it is generated from the settings above.', 'give' ),
417 - ),
418 - array(
419 - 'name' => __( 'Sequential Ordering Docs Link', 'give' ),
420 - 'id' => "{$current_section}_doc link",
421 - 'url' => esc_url( 'http://docs.givewp.com/settings-sequential-ordering' ),
422 - 'title' => __( 'Sequential Ordering', 'give' ),
423 - 'type' => 'give_docs_link',
424 - ),
425 - array(
426 - 'id' => 'give_title_general_settings_4',
427 - 'type' => 'sectionend'
428 - )
429 - );
430 - }
448 + [
449 + 'id' => 'give_title_general_settings_4',
450 + 'type' => 'title',
451 + ],
452 + [
453 + 'name' => __('Sequential Ordering', 'give'),
454 + 'id' => "{$current_section}_status",
455 + 'desc' => __(
456 + 'Custom donation numbering that increases sequentially to prevent gaps between donation IDs. If disabled, then donation numbers are generated from WordPress post IDs, which will result in gaps between numbers.',
457 + 'give'
458 + ),
459 + 'type' => 'radio_inline',
460 + 'default' => 'disabled',
461 + 'options' => [
462 + 'enabled' => __('Enabled', 'give'),
463 + 'disabled' => __('Disabled', 'give'),
464 + ],
465 + ],
466 + [
467 + 'name' => __('Next Donation Number', 'give'),
468 + 'id' => "{$current_section}_number",
469 + 'desc' => sprintf(
470 + __(
471 + 'The number used to generate the next donation ID. This value must be greater than or equal to %s to avoid conflicts with existing donation IDs.',
472 + 'give'
473 + ),
474 + '<code>' . Give()->seq_donation_number->get_next_number() . '</code>'
475 + ),
476 + 'type' => 'number',
477 + ],
478 + [
479 + 'name' => __('Number Prefix', 'give'),
480 + 'id' => "{$current_section}_number_prefix",
481 + 'desc' => sprintf(
482 + __(
483 + 'The prefix appended to all sequential donation numbers. Spaces are replaced by %s.',
484 + 'give'
485 + ),
486 + '<code>-</code>'
487 + ),
488 + 'type' => 'text',
489 + ],
490 + [
491 + 'name' => __('Number Suffix', 'give'),
492 + 'id' => "{$current_section}_number_suffix",
493 + 'desc' => sprintf(
494 + __(
495 + 'The suffix appended to all sequential donation numbers. Spaces are replaced by %s.',
496 + 'give'
497 + ),
498 + '<code>-</code>'
499 + ),
500 + 'type' => 'text',
501 + ],
502 + [
503 + 'name' => __('Number Padding', 'give'),
504 + 'id' => "{$current_section}_number_padding",
505 + 'desc' => sprintf(
506 + __(
507 + 'The minimum number of digits in the sequential donation number. Enter %1$s to display %2$s as %3$s.',
508 + 'give'
509 + ),
510 + '<code>4</code>',
511 + '<code>1</code>',
512 + '<code>0001</code>'
513 + ),
514 + 'type' => 'number',
515 + 'default' => '0',
516 + ],
517 + [
518 + 'name' => __('Donation ID Preview', 'give'),
519 + 'id' => "{$current_section}_preview",
520 + 'type' => 'give_sequential_donation_code_preview',
521 + 'desc' => __(
522 + 'A preview of the next sequential donation ID. This preview cannot be edited directly as it is generated from the settings above.',
523 + 'give'
524 + ),
525 + ],
526 + [
527 + 'name' => __('Sequential Ordering Docs Link', 'give'),
528 + 'id' => "{$current_section}_doc link",
529 + 'url' => esc_url('http://docs.givewp.com/settings-sequential-ordering'),
530 + 'title' => __('Sequential Ordering', 'give'),
531 + 'type' => 'give_docs_link',
532 + ],
533 + [
534 + 'id' => 'give_title_general_settings_4',
535 + 'type' => 'sectionend',
536 + ],
537 + ];
538 + }
431 539
432 - /**
433 - * Filter the general settings.
434 - * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
435 - */
436 - $settings = apply_filters( 'give_settings_general', $settings );
540 + /**
541 + * Filter the general settings.
542 + * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
543 + */
544 + $settings = apply_filters('give_settings_general', $settings);
437 545
438 - /**
439 - * Filter the settings.
440 - *
441 - * @since 1.8
442 - *
443 - * @param array $settings
444 - */
445 - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
546 + /**
547 + * Filter the settings.
548 + *
549 + * @since 1.8
550 + *
551 + * @param array $settings
552 + */
553 + $settings = apply_filters('give_get_settings_' . $this->id, $settings);
446 554
447 - // Output.
448 - return $settings;
449 - }
555 + // Output.
556 + return $settings;
557 + }
450 558
451 - /**
452 - * Get sections.
453 - *
454 - * @since 1.8
455 - * @return array
456 - */
457 - public function get_sections() {
458 - $sections = array(
459 - 'general-settings' => __( 'General', 'give' ),
460 - 'currency-settings' => __( 'Currency', 'give' ),
461 - 'access-control' => __( 'Access Control', 'give' ),
462 - 'sequential-ordering' => __( 'Sequential Ordering', 'give' ),
463 - );
559 + /**
560 + * Get sections.
561 + *
562 + * @since 1.8
563 + * @return array
564 + */
565 + public function get_sections()
566 + {
567 + $sections = [
568 + 'general-settings' => __('General', 'give'),
569 + 'currency-settings' => __('Currency', 'give'),
570 + 'access-control' => __('Access Control', 'give'),
571 + 'sequential-ordering' => __('Sequential Ordering', 'give'),
572 + ];
464 573
465 - return apply_filters( 'give_get_sections_' . $this->id, $sections );
466 - }
574 + return apply_filters('give_get_sections_' . $this->id, $sections);
575 + }
467 576
577 + /**
578 + * Set flag to reset sequestion donation number starting point when "Sequential Starting Number" value changes
579 + *
580 + * @since 2.1
581 + * @access public
582 + *
583 + * @param $update_options
584 + * @param $option_name
585 + * @param $old_options
586 + *
587 + * @return bool
588 + */
589 + public function _give_change_donation_stating_number($update_options, $option_name, $old_options)
590 + {
591 + if (!isset($_POST['sequential-ordering_number'])) {
592 + return false;
593 + }
468 594
469 - /**
470 - * Set flag to reset sequestion donation number starting point when "Sequential Starting Number" value changes
471 - *
472 - * @since 2.1
473 - * @access public
474 - *
475 - * @param $update_options
476 - * @param $option_name
477 - * @param $old_options
478 - *
479 - * @return bool
480 - */
481 - public function _give_change_donation_stating_number( $update_options, $option_name, $old_options ) {
482 - if ( ! isset( $_POST['sequential-ordering_number'] ) ) {
483 - return false;
484 - }
595 + if (($next_number = Give()->seq_donation_number->get_next_number(
596 + )) > $update_options['sequential-ordering_number']) {
597 + give_update_option('sequential-ordering_number', $next_number);
485 598
486 - if ( ( $next_number = Give()->seq_donation_number->get_next_number() ) > $update_options['sequential-ordering_number'] ) {
487 - give_update_option( 'sequential-ordering_number', $next_number );
599 + Give_Admin_Settings::add_error(
600 + 'give-invalid-sequential-starting-number',
601 + sprintf(
602 + __(
603 + 'Next Donation Number must be equal to or larger than %s to avoid conflicts with existing donation IDs.',
604 + 'give'
605 + ),
606 + $next_number
607 + )
608 + );
609 + } elseif ($update_options['sequential-ordering_number'] !== $old_options['sequential-ordering_number']) {
610 + update_option('_give_reset_sequential_number', 1, false);
611 + }
488 612
489 - Give_Admin_Settings::add_error(
490 - 'give-invalid-sequential-starting-number',
491 - sprintf(
492 - __( 'Next Donation Number must be equal to or larger than %s to avoid conflicts with existing donation IDs.', 'give' ),
493 - $next_number
494 - )
495 - );
496 - } elseif ( $update_options['sequential-ordering_number'] !== $old_options['sequential-ordering_number'] ) {
497 - update_option( '_give_reset_sequential_number', 1, false );
498 - }
613 + return true;
614 + }
499 615
500 - return true;
501 - }
616 + /**
617 + * Render give_sequential_donation_code_preview field type
618 + *
619 + * @since 2.1.0
620 + * @access public
621 + *
622 + * @param $field
623 + */
624 + public function _render_give_sequential_donation_code_preview($field)
625 + {
626 + ?>
627 + <tr valign="top" <?php
628 + echo !empty($field['wrapper_class']) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
629 + <th scope="row" class="titledesc">
630 + <label
631 + for="<?php
632 + echo esc_attr($field['id']); ?>"><?php
633 + echo esc_html($field['name']); ?></label>
634 + </th>
635 + <td class="give-forminp">
636 + <input id="<?php
637 + echo esc_attr($field['id']); ?>" class="give-input-field" type="text" disabled>
638 + <?php
639 + echo Give_Admin_Settings::get_field_description($field); ?>
640 + </td>
641 + </tr>
642 + <?php
643 + }
502 644
503 - /**
504 - * Render give_sequential_donation_code_preview field type
505 - *
506 - * @since 2.1.0
507 - * @access public
508 - *
509 - * @param $field
510 - */
511 - public function _render_give_sequential_donation_code_preview( $field ) {
512 - ?>
513 - <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
514 - <th scope="row" class="titledesc">
515 - <label
516 - for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
517 - </th>
518 - <td class="give-forminp">
519 - <input id="<?php echo esc_attr( $field['id'] ); ?>" class="give-input-field" type="text" disabled>
520 - <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
521 - </td>
522 - </tr>
523 - <?php
524 - }
645 + /**
646 + * Render give_currency_code_preview field type
647 + *
648 + * @since 2.3.0
649 + * @access public
650 + *
651 + * @param array $field Field Attributes array.
652 + *
653 + * @return void
654 + */
655 + public function _render_give_currency_preview($field, $value)
656 + {
657 + $currency = give_get_currency();
658 + $currency_position = give_get_currency_position();
659 + $currency_symbol = give_currency_symbol($currency, false);
660 + $formatted_currency = ('before' === $currency_position)
661 + ? sprintf('%1$s%2$s', esc_html($currency_symbol), esc_html($field['default']))
662 + : sprintf('%1$s%2$s', esc_html($field['default']), esc_html($currency_symbol));
663 + ?>
664 + <tr valign="top" <?php
665 + echo !empty($field['wrapper_class']) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
666 + <th scope="row" class="titledesc">
667 + <label
668 + for="<?php
669 + echo esc_attr($field['id']); ?>"><?php
670 + echo wp_kses_post($field['name']); ?></label>
671 + </th>
672 + <td class="give-forminp">
673 + <input id="<?php
674 + echo esc_attr($field['id']); ?>" class="give-input-field" type="text" disabled value="<?php
675 + echo esc_attr($formatted_currency); ?>">
676 + <?php
677 + echo Give_Admin_Settings::get_field_description($field); ?>
678 + </td>
679 + </tr>
680 + <?php
681 + }
525 682
526 - /**
527 - * Render give_currency_code_preview field type
528 - *
529 - * @since 2.3.0
530 - * @access public
531 - *
532 - * @param array $field Field Attributes array.
533 - *
534 - * @return void
535 - */
536 - public function _render_give_currency_preview( $field, $value ) {
537 - $currency = give_get_currency();
538 - $currency_position = give_get_currency_position();
539 - $currency_symbol = give_currency_symbol( $currency, false );
540 - $formatted_currency = ( 'before' === $currency_position )
541 - ? sprintf( '%1$s%2$s', esc_html( $currency_symbol ), esc_html( $field['default'] ) )
542 - : sprintf( '%1$s%2$s', esc_html( $field['default'] ), esc_html( $currency_symbol ) );
543 - ?>
544 - <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
545 - <th scope="row" class="titledesc">
546 - <label
547 - for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
548 - </th>
549 - <td class="give-forminp">
550 - <input id="<?php echo esc_attr( $field['id'] ); ?>" class="give-input-field" type="text" disabled value="<?php echo esc_attr( $formatted_currency ); ?>">
551 - <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
552 - </td>
553 - </tr>
554 - <?php
555 - }
556 -
557 - /**
558 - * Render give_unlock_all_settings field type
559 - *
560 - * @since 2.1.0
561 - * @access public
562 - *
563 - * @param $field
564 - */
565 - public function _render_give_unlock_all_settings( $field ) {
566 - ?>
567 - <tr valign="top" <?php echo ! empty( $field['wrapper_class'] ) ? 'class="' . $field['wrapper_class'] . '"' : '' ?>>
568 - <th scope="row" class="titledesc">
569 - <label
570 - for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['name'] ) ?></label>
571 - </th>
572 - <td class="give-forminp">
573 - <?php echo Give_Admin_Settings::get_field_description( $field ); ?>
574 - <a href="" id="<?php echo $field['id']; ?>" data-message="<?php echo $field['confirmation_msg'] ?>"><?php echo __( 'Unlock all settings', 'give' ); ?></a>
575 - </td>
576 - </tr>
577 - <?php
578 - }
579 - }
683 + /**
684 + * Render give_unlock_all_settings field type
685 + *
686 + * @since 2.1.0
687 + * @access public
688 + *
689 + * @param $field
690 + */
691 + public function _render_give_unlock_all_settings($field)
692 + {
693 + ?>
694 + <tr valign="top" <?php
695 + echo !empty($field['wrapper_class']) ? 'class="' . $field['wrapper_class'] . '"' : ''; ?>>
696 + <th scope="row" class="titledesc">
697 + <label
698 + for="<?php
699 + echo esc_attr($field['id']); ?>"><?php
700 + echo esc_html($field['name']); ?></label>
701 + </th>
702 + <td class="give-forminp">
703 + <?php
704 + echo Give_Admin_Settings::get_field_description($field); ?>
705 + <a href="" id="<?php
706 + echo $field['id']; ?>" data-message="<?php
707 + echo $field['confirmation_msg']; ?>"><?php
708 + echo __('Unlock all settings', 'give'); ?></a>
709 + </td>
710 + </tr>
711 + <?php
712 + }
713 + }
580 714
581 715 endif;
582 716
583 717 return new Give_Settings_General();