PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.3.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.3.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | includes/Admin/ProSettingsFields.php +358 -161 1.10.3 → 2.3.0 View file →
@@ -31,9 +31,9 @@
31 31 /**
32 32 * Initialize the class.
33 33 */
34 34 public function __construct() {
35 - add_filter( 'subscrpt_settings_fields', array( $this, 'add_pro_preview_fields' ) );
35 + add_filter( 'subscrpt_settings_fields', [ $this, 'add_pro_preview_fields' ] );
36 36 }
37 37
38 38 /**
39 39 * Merge the Pro settings fields into the settings fields list.
@@ -45,8 +45,9 @@
45 45 */
46 46 public function add_pro_preview_fields( $settings_fields ) {
47 47 $pro_fields = array_merge(
48 48 $this->pro_core_fields(),
49 + $this->license_fields(),
49 50 $this->grace_period_fields(),
50 51 $this->payment_failure_fields(),
51 52 $this->api_fields(),
52 53 $this->health_queue_fields(),
@@ -75,29 +76,29 @@
75 76 *
76 77 * @return array
77 78 */
78 79 private function pro_core_fields() {
79 - return array(
80 - array(
80 + return [
81 + [
81 82 'type' => 'select',
82 - 'group' => 'main',
83 + 'group' => 'renewals',
83 84 'priority' => 7,
84 - 'field_data' => array(
85 + 'field_data' => [
85 86 'id' => 'subscrpt_renewal_price',
86 87 'title' => __( 'Renewal Price', 'subscription' ),
87 88 'description' => __( 'Choose a price that will be used for subscription renewal.', 'subscription' ),
88 - 'options' => array(
89 + 'options' => [
89 90 'subscribed' => __( 'Subscribed Price', 'subscription' ),
90 91 'updated' => __( 'New/Updated Price', 'subscription' ),
91 - ),
92 + ],
92 93 'selected' => esc_attr( get_option( 'subscrpt_renewal_price', 'subscribed' ) ),
93 - ),
94 - ),
95 - array(
94 + ],
95 + ],
96 + [
96 97 'type' => 'toggle',
97 - 'group' => 'main',
98 + 'group' => 'renewals',
98 99 'priority' => 8,
99 - 'field_data' => array(
100 + 'field_data' => [
100 101 'id' => 'subscrpt_early_renew',
101 102 'title' => __( 'Early Renewal', 'subscription' ),
102 103 'label' => __( 'Accept Early Renewal Payments', 'subscription' ),
103 104 'description' => __( 'With early renewals enabled, customers can renew their subscriptions before the next payment date.', 'subscription' ),
@@ -102,49 +103,155 @@
102 103 'label' => __( 'Accept Early Renewal Payments', 'subscription' ),
103 104 'description' => __( 'With early renewals enabled, customers can renew their subscriptions before the next payment date.', 'subscription' ),
104 105 'value' => '1',
105 106 'checked' => '1' === get_option( 'subscrpt_early_renew', '1' ),
106 - ),
107 - ),
108 - );
107 + ],
108 + ],
109 + [
110 + 'type' => 'select',
111 + 'group' => 'renewals',
112 + 'priority' => 9,
113 + 'field_data' => [
114 + 'id' => 'subscrpt_early_renew_visibility',
115 + 'title' => __( 'Early Renew Button Visibility', 'subscription' ),
116 + 'description' => __( 'Choose when customers see the Early Renew button on an active subscription.', 'subscription' ),
117 + 'options' => [
118 + 'always' => __( 'Always', 'subscription' ),
119 + 'before_days' => __( 'Before X days of the next renewal', 'subscription' ),
120 + 'day_of_month' => __( 'From a fixed day of the month', 'subscription' ),
121 + 'cycle_left' => __( 'When a percentage of the billing cycle remains', 'subscription' ),
122 + ],
123 + 'selected' => esc_attr( get_option( 'subscrpt_early_renew_visibility', 'always' ) ),
124 + ],
125 + ],
126 + [
127 + 'type' => 'input',
128 + 'group' => 'renewals',
129 + 'priority' => 10,
130 + 'field_data' => [
131 + 'id' => 'subscrpt_early_renew_before_days',
132 + 'title' => __( 'Early Renew: Days Before Renewal', 'subscription' ),
133 + 'description' => __( 'Used with "Before X days". The button shows this many days before the next renewal date.', 'subscription' ),
134 + 'value' => esc_attr( get_option( 'subscrpt_early_renew_before_days', '7' ) ),
135 + 'type' => 'number',
136 + 'attributes' => [
137 + 'min' => 1,
138 + ],
139 + ],
140 + ],
141 + [
142 + 'type' => 'input',
143 + 'group' => 'renewals',
144 + 'priority' => 11,
145 + 'field_data' => [
146 + 'id' => 'subscrpt_early_renew_day_of_month',
147 + 'title' => __( 'Early Renew: Day of Month', 'subscription' ),
148 + 'description' => __( 'Used with "From a fixed day of the month". The button shows from this day until the end of each month. Short months use their last day.', 'subscription' ),
149 + 'value' => esc_attr( get_option( 'subscrpt_early_renew_day_of_month', '25' ) ),
150 + 'type' => 'number',
151 + 'attributes' => [
152 + 'min' => 1,
153 + 'max' => 31,
154 + ],
155 + ],
156 + ],
157 + [
158 + 'type' => 'input',
159 + 'group' => 'renewals',
160 + 'priority' => 12,
161 + 'field_data' => [
162 + 'id' => 'subscrpt_early_renew_cycle_left',
163 + 'title' => __( 'Early Renew: Cycle Remaining (%)', 'subscription' ),
164 + 'description' => __( 'Used with "When a percentage of the billing cycle remains". The button shows once this percentage of the current cycle or less is left.', 'subscription' ),
165 + 'value' => esc_attr( get_option( 'subscrpt_early_renew_cycle_left', '20' ) ),
166 + 'type' => 'number',
167 + 'attributes' => [
168 + 'min' => 1,
169 + 'max' => 100,
170 + ],
171 + ],
172 + ],
173 + ];
109 174 }
110 175
111 176 /**
177 + * Module: License integrations (Integrations/LicenseManagerWoo.php).
178 + *
179 + * @return array
180 + */
181 + private function license_fields() {
182 + return [
183 + [
184 + 'type' => 'heading',
185 + 'group' => 'license_settings',
186 + 'priority' => 4,
187 + 'field_data' => [
188 + 'title' => __( 'License Settings', 'subscription' ),
189 + ],
190 + ],
191 + [
192 + 'type' => 'toggle',
193 + 'group' => 'license_settings',
194 + 'priority' => 1,
195 + 'field_data' => [
196 + 'id' => 'subscrpt_regenerate_license_on_renewal',
197 + 'title' => __( 'Regenerate License on Renewal', 'subscription' ),
198 + 'description' => __( 'Enable this option if you want to invalidate the old key and issue a fresh license key whenever a subscription renews.', 'subscription' ),
199 + 'value' => '1',
200 + 'checked' => '1' === get_option( 'subscrpt_regenerate_license_on_renewal', '0' ),
201 + ],
202 + ],
203 + [
204 + 'type' => 'toggle',
205 + 'group' => 'license_settings',
206 + 'priority' => 2,
207 + 'field_data' => [
208 + 'id' => 'subscrpt_deactivate_old_license_on_renewal',
209 + 'title' => __( 'Deactivate Previous License', 'subscription' ),
210 + 'description' => __( 'When a fresh license key is issued on renewal, deactivate the previous key. Turn off to let the previous key keep working until it expires.', 'subscription' ),
211 + 'value' => '1',
212 + 'checked' => '1' === get_option( 'subscrpt_deactivate_old_license_on_renewal', '1' ),
213 + ],
214 + ],
215 + ];
216 + }
217 +
218 + /**
112 219 * Module: Grace Period (Admin/Settings.php).
113 220 *
114 221 * @return array
115 222 */
116 223 private function grace_period_fields() {
117 - return array(
118 - array(
224 + return [
225 + [
119 226 'type' => 'heading',
120 227 'group' => 'grace_period',
121 - 'priority' => 3,
122 - 'field_data' => array(
228 + 'priority' => 5,
229 + 'field_data' => [
123 230 'title' => __( 'Grace Period Settings', 'subscription' ),
124 - ),
125 - ),
126 - array(
231 + ],
232 + ],
233 + [
127 234 'type' => 'input',
128 235 'group' => 'grace_period',
129 236 'priority' => 1,
130 - 'field_data' => array(
237 + 'field_data' => [
131 238 'id' => 'subscrpt_default_payment_grace_period',
132 239 'title' => __( 'Grace Period (Days)', 'subscription' ),
133 240 'description' => __( 'Days to maintain access after subscriptions expires. (0 = No grace period. Max 30 days)', 'subscription' ),
134 241 'value' => esc_attr( get_option( 'subscrpt_default_payment_grace_period', '7' ) ),
135 242 'type' => 'number',
136 - 'attributes' => array(
243 + 'attributes' => [
137 244 'min' => 0,
138 245 'max' => 30,
139 - ),
140 - ),
141 - ),
142 - array(
246 + ],
247 + ],
248 + ],
249 + [
143 250 'type' => 'toggle',
144 251 'group' => 'grace_period',
145 252 'priority' => 2,
146 - 'field_data' => array(
253 + 'field_data' => [
147 254 'id' => 'subscrpt_enable_grace_period_notifications',
148 255 'title' => __( 'Grace Period Notifications', 'subscription' ),
149 256 'label' => __( 'Send notifications during grace period', 'subscription' ),
150 257 'description' => __( 'Customers will receive warnings before their access is suspended.', 'subscription' ),
@@ -149,27 +256,27 @@
149 256 'label' => __( 'Send notifications during grace period', 'subscription' ),
150 257 'description' => __( 'Customers will receive warnings before their access is suspended.', 'subscription' ),
151 258 'value' => '1',
152 259 'checked' => '1' === get_option( 'subscrpt_enable_grace_period_notifications', '1' ),
153 - ),
154 - ),
155 - array(
260 + ],
261 + ],
262 + [
156 263 'type' => 'input',
157 264 'group' => 'grace_period',
158 265 'priority' => 3,
159 - 'field_data' => array(
266 + 'field_data' => [
160 267 'id' => 'subscrpt_grace_period_warning_days',
161 268 'title' => __( 'Grace Period Warning (Days Before)', 'subscription' ),
162 269 'description' => __( 'Send warning emails this many days before grace period expires. (1-7 days)', 'subscription' ),
163 270 'value' => esc_attr( get_option( 'subscrpt_grace_period_warning_days', '2' ) ),
164 271 'type' => 'number',
165 - 'attributes' => array(
272 + 'attributes' => [
166 273 'min' => 1,
167 274 'max' => 7,
168 - ),
169 - ),
170 - ),
171 - );
275 + ],
276 + ],
277 + ],
278 + ];
172 279 }
173 280
174 281 /**
175 282 * Module: Payment Failure Handling (Admin/Settings.php).
@@ -176,38 +283,38 @@
176 283 *
177 284 * @return array
178 285 */
179 286 private function payment_failure_fields() {
180 - return array(
181 - array(
287 + return [
288 + [
182 289 'type' => 'heading',
183 290 'group' => 'payment_failure',
184 - 'priority' => 4,
185 - 'field_data' => array(
291 + 'priority' => 6,
292 + 'field_data' => [
186 293 'title' => __( 'Payment Failure Handling', 'subscription' ),
187 - ),
188 - ),
189 - array(
294 + ],
295 + ],
296 + [
190 297 'type' => 'input',
191 298 'group' => 'payment_failure',
192 299 'priority' => 1,
193 - 'field_data' => array(
300 + 'field_data' => [
194 301 'id' => 'subscrpt_default_max_payment_retries',
195 302 'title' => __( 'Default Max Payment Retries', 'subscription' ),
196 303 'description' => __( 'Default number of automatic retry attempts for failed payments. (0 = No retries. Max 10 retries)', 'subscription' ),
197 304 'value' => esc_attr( get_option( 'subscrpt_default_max_payment_retries', '3' ) ),
198 305 'type' => 'number',
199 - 'attributes' => array(
306 + 'attributes' => [
200 307 'min' => 0,
201 308 'max' => 10,
202 - ),
203 - ),
204 - ),
205 - array(
309 + ],
310 + ],
311 + ],
312 + [
206 313 'type' => 'toggle',
207 314 'group' => 'payment_failure',
208 315 'priority' => 2,
209 - 'field_data' => array(
316 + 'field_data' => [
210 317 'id' => 'subscrpt_enable_payment_failure_emails',
211 318 'title' => __( 'Enable Payment Failure Emails', 'subscription' ),
212 319 'label' => __( 'Send email notifications when payments fail', 'subscription' ),
213 320 'description' => __( 'Customers will receive emails about failed payments and retry attempts.', 'subscription' ),
@@ -212,27 +319,27 @@
212 319 'label' => __( 'Send email notifications when payments fail', 'subscription' ),
213 320 'description' => __( 'Customers will receive emails about failed payments and retry attempts.', 'subscription' ),
214 321 'value' => '1',
215 322 'checked' => '1' === get_option( 'subscrpt_enable_payment_failure_emails', '1' ),
216 - ),
217 - ),
218 - array(
323 + ],
324 + ],
325 + [
219 326 'type' => 'input',
220 327 'group' => 'payment_failure',
221 328 'priority' => 3,
222 - 'field_data' => array(
329 + 'field_data' => [
223 330 'id' => 'subscrpt_payment_failure_email_delay',
224 331 'title' => __( 'Payment Failure Email Delay (Hours)', 'subscription' ),
225 332 'description' => __( 'Delay before sending payment failure emails to avoid spam during temporary issues. (0-168 hours)', 'subscription' ),
226 333 'value' => esc_attr( get_option( 'subscrpt_payment_failure_email_delay', '24' ) ),
227 334 'type' => 'number',
228 - 'attributes' => array(
335 + 'attributes' => [
229 336 'min' => 0,
230 337 'max' => 168,
231 - ),
232 - ),
233 - ),
234 - );
338 + ],
339 + ],
340 + ],
341 + ];
235 342 }
236 343
237 344 /**
238 345 * Module: API Settings (Admin/Settings.php).
@@ -239,47 +346,47 @@
239 346 *
240 347 * @return array
241 348 */
242 349 private function api_fields() {
243 - return array(
244 - array(
350 + return [
351 + [
245 352 'type' => 'heading',
246 353 'group' => 'api_settings',
247 354 'priority' => 99,
248 - 'field_data' => array(
355 + 'field_data' => [
249 356 'title' => __( 'API Settings', 'subscription' ),
250 - ),
251 - ),
252 - array(
357 + ],
358 + ],
359 + [
253 360 'type' => 'toggle',
254 361 'group' => 'api_settings',
255 362 'priority' => 1,
256 - 'field_data' => array(
363 + 'field_data' => [
257 364 'id' => 'wpsubscription_api_enabled',
258 365 'title' => __( 'Enable API', 'subscription' ),
259 366 'description' => __( 'Enable REST API endpoints for subscription actions', 'subscription' ),
260 367 'value' => 'on',
261 368 'checked' => 'on' === get_option( 'wpsubscription_api_enabled', 'on' ),
262 - ),
263 - ),
264 - array(
369 + ],
370 + ],
371 + [
265 372 'type' => 'join',
266 373 'group' => 'api_settings',
267 374 'priority' => 2,
268 - 'field_data' => array(
375 + 'field_data' => [
269 376 'title' => __( 'API Key', 'subscription' ),
270 377 'description' => __( 'API key for external integrations. Keep this secure.', 'subscription' ),
271 - 'elements' => array(
378 + 'elements' => [
272 379 SettingsHelper::inp_element(
273 - array(
380 + [
274 381 'id' => 'wpsubscription_api_key',
275 382 'value' => esc_attr( get_option( 'wpsubscription_api_key', '' ) ),
276 383 'type' => 'text',
277 384 'style' => 'min-width:366px;',
278 - 'attributes' => array(
385 + 'attributes' => [
279 386 'readonly' => true,
280 - ),
281 - ),
387 + ],
388 + ],
282 389 true
283 390 ),
284 391 '<span class="wpsubs-tooltip" data-tip="' . esc_attr__( 'Regenerate API Key', 'subscription' ) . '">'
285 392 . '<button type="button" class="wpsubs-btn wpsubs-btn--outline wpsubs-btn--icon" id="regenerate_api_key" aria-label="' . esc_attr__( 'Regenerate API Key', 'subscription' ) . '">'
@@ -285,27 +392,27 @@
285 392 . '<button type="button" class="wpsubs-btn wpsubs-btn--outline wpsubs-btn--icon" id="regenerate_api_key" aria-label="' . esc_attr__( 'Regenerate API Key', 'subscription' ) . '">'
286 393 . '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>'
287 394 . '</button>'
288 395 . '</span>',
289 - ),
290 - ),
291 - ),
292 - array(
396 + ],
397 + ],
398 + ],
399 + [
293 400 'type' => 'input',
294 401 'group' => 'api_settings',
295 402 'priority' => 3,
296 - 'field_data' => array(
403 + 'field_data' => [
297 404 'id' => 'subscrpt_api_endpoint_url',
298 405 'title' => __( 'REST API Endpoint URL', 'subscription' ),
299 406 'description' => __( 'Copy and use this endpoint for all API actions.', 'subscription' ),
300 407 'value' => esc_url( home_url( '/wp-json/wpsubscription/v1/action' ) ),
301 408 'type' => 'text',
302 - 'attributes' => array(
409 + 'attributes' => [
303 410 'readonly' => true,
304 - ),
305 - ),
306 - ),
307 - );
411 + ],
412 + ],
413 + ],
414 + ];
308 415 }
309 416
310 417 /**
311 418 * Module: Subscription Health (Admin/Settings.php).
@@ -312,35 +419,35 @@
312 419 *
313 420 * @return array
314 421 */
315 422 private function health_queue_fields() {
316 - return array(
317 - array(
423 + return [
424 + [
318 425 'type' => 'heading',
319 426 'group' => 'health_queue',
320 - 'priority' => 8,
321 - 'field_data' => array(
427 + 'priority' => 9,
428 + 'field_data' => [
322 429 'title' => __( 'Subscription Health', 'subscription' ),
323 - ),
324 - ),
325 - array(
430 + ],
431 + ],
432 + [
326 433 'type' => 'select',
327 434 'group' => 'health_queue',
328 435 'priority' => 2,
329 - 'field_data' => array(
436 + 'field_data' => [
330 437 'id' => 'subscrpt_health_queue_email_frequency',
331 438 'title' => __( 'Health Queue Email Frequency', 'subscription' ),
332 439 'description' => __( 'How often to send the admin health queue reminder email. The email is only sent when subscriptions need attention.', 'subscription' ),
333 - 'options' => array(
440 + 'options' => [
334 441 'daily' => __( 'Daily', 'subscription' ),
335 442 'subscrpt_weekly' => __( 'Weekly', 'subscription' ),
336 443 'subscrpt_monthly' => __( 'Monthly', 'subscription' ),
337 444 'never' => __( 'Never', 'subscription' ),
338 - ),
445 + ],
339 446 'selected' => esc_attr( get_option( 'subscrpt_health_queue_email_frequency', 'subscrpt_weekly' ) ),
340 - ),
341 - ),
342 - );
447 + ],
448 + ],
449 + ];
343 450 }
344 451
345 452 /**
346 453 * Module: Order (Illuminate/Order.php) — auto complete orders.
@@ -347,22 +454,35 @@
347 454 *
348 455 * @return array
349 456 */
350 457 private function order_fields() {
351 - return array(
352 - array(
458 + return [
459 + [
353 460 'type' => 'toggle',
354 461 'group' => 'payment_gateways',
355 462 'priority' => 1,
356 - 'field_data' => array(
463 + 'field_data' => [
357 464 'id' => 'wp_subscription_auto_complete_order',
358 465 'title' => __( 'Auto Complete Orders', 'subscription' ),
359 466 'description' => __( 'Automatically change status of processing orders to completed.', 'subscription' ),
360 467 'value' => '1',
361 468 'checked' => '1' === get_option( 'wp_subscription_auto_complete_order', '1' ),
362 - ),
363 - ),
364 - );
469 + ],
470 + ],
471 + [
472 + 'type' => 'toggle',
473 + 'group' => 'payment_gateways',
474 + 'priority' => 2,
475 + 'field_data' => [
476 + 'id' => 'subscrpt_require_payment_on_trial',
477 + 'title' => __( 'Require Payment for Free Trials', 'subscription' ),
478 + 'label' => __( 'Collect payment details at checkout for trial subscriptions', 'subscription' ),
479 + 'description' => __( 'Collect payment details up front on free trials so renewals charge automatically.', 'subscription' ),
480 + 'value' => '1',
481 + 'checked' => '1' === get_option( 'subscrpt_require_payment_on_trial', '1' ),
482 + ],
483 + ],
484 + ];
365 485 }
366 486
367 487 /**
368 488 * Module: Switch Subscription (Illuminate/SubscriptionSwitch.php).
@@ -369,23 +489,100 @@
369 489 *
370 490 * @return array
371 491 */
372 492 private function switch_fields() {
373 - return array(
374 - array(
493 + return [
494 + [
495 + 'type' => 'heading',
496 + 'group' => 'switching',
497 + 'priority' => 3,
498 + 'field_data' => [
499 + 'title' => __( 'Switching & Upgrades', 'subscription' ),
500 + ],
501 + ],
502 + [
375 503 'type' => 'toggle',
376 - 'group' => 'general',
504 + 'group' => 'switching',
377 505 'priority' => 9,
378 - 'field_data' => array(
506 + 'field_data' => [
379 507 'id' => 'subscrpt_switch_enabled',
380 508 'title' => __( 'Switch Subscription', 'subscription' ),
381 509 'label' => __( 'Allow users to upgrade/downgrade their subscriptions.', 'subscription' ),
382 - 'description' => __( 'Note: Downgrading subscription is not available at the moment.', 'subscription' ),
510 + 'description' => '',
383 511 'value' => '1',
384 512 'checked' => '1' === get_option( 'subscrpt_switch_enabled', '0' ),
385 - ),
386 - ),
387 - );
513 + ],
514 + ],
515 + [
516 + 'type' => 'toggle',
517 + 'group' => 'switching',
518 + 'priority' => 10,
519 + 'field_data' => [
520 + 'id' => 'subscrpt_downgrade_allowed',
521 + 'title' => __( 'Downgrade Subscription', 'subscription' ),
522 + 'label' => __( 'Allow users to downgrade their subscriptions.', 'subscription' ),
523 + 'description' => '',
524 + 'value' => '1',
525 + 'checked' => '1' === get_option( 'subscrpt_downgrade_allowed', '1' ),
526 + ],
527 + ],
528 + [
529 + 'type' => 'join',
530 + 'group' => 'switching',
531 + 'priority' => 11,
532 + 'field_data' => [
533 + 'title' => __( 'Switch Fee', 'subscription' ),
534 + 'description' => __( 'Optional fee charged when a customer switches plans. Use a flat amount or a percentage of the new plan price. (0 = no fee)', 'subscription' ),
535 + 'elements' => [
536 + SettingsHelper::inp_element(
537 + [
538 + 'id' => 'subscrpt_switch_fee_amount',
539 + 'value' => esc_attr( get_option( 'subscrpt_switch_fee_amount', '0' ) ),
540 + 'type' => 'number',
541 + 'style' => 'min-width:170px;width:170px;',
542 + 'attributes' => [
543 + 'min' => 0,
544 + 'step' => '0.01',
545 + ],
546 + ],
547 + true
548 + ),
549 + SettingsHelper::select_element(
550 + [
551 + 'id' => 'subscrpt_switch_fee_type',
552 + 'class' => 'subscrpt-switch-fee-type',
553 + 'options' => [
554 + 'flat' => sprintf(
555 + /* translators: %s: store currency symbol. */
556 + __( 'Flat (%s)', 'subscription' ),
557 + get_woocommerce_currency_symbol()
558 + ),
559 + 'percent' => __( 'Percentage (%)', 'subscription' ),
560 + ],
561 + 'selected' => esc_attr( get_option( 'subscrpt_switch_fee_type', 'flat' ) ),
562 + ],
563 + true
564 + ),
565 + ],
566 + ],
567 + ],
568 + [
569 + 'type' => 'select',
570 + 'group' => 'switching',
571 + 'priority' => 12,
572 + 'field_data' => [
573 + 'id' => 'subscrpt_switch_fee_apply_to',
574 + 'title' => __( 'Apply Fee To', 'subscription' ),
575 + 'description' => __( 'Choose which switch directions the fee applies to.', 'subscription' ),
576 + 'options' => [
577 + 'both' => __( 'Both upgrade and downgrade', 'subscription' ),
578 + 'upgrade' => __( 'Upgrade only', 'subscription' ),
579 + 'downgrade' => __( 'Downgrade only', 'subscription' ),
580 + ],
581 + 'selected' => esc_attr( get_option( 'subscrpt_switch_fee_apply_to', 'both' ) ),
582 + ],
583 + ],
584 + ];
388 585 }
389 586
390 587 /**
391 588 * Module: Role Management (Illuminate/RoleManagement.php).
@@ -392,30 +589,30 @@
392 589 *
393 590 * @return array
394 591 */
395 592 private function role_management_fields() {
396 - return array(
397 - array(
593 + return [
594 + [
398 595 'type' => 'heading',
399 596 'group' => 'role_based_settings',
400 - 'priority' => 6,
401 - 'field_data' => array(
597 + 'priority' => 7,
598 + 'field_data' => [
402 599 'title' => __( 'Role-Based Settings', 'subscription' ),
403 - ),
404 - ),
405 - array(
600 + ],
601 + ],
602 + [
406 603 'type' => 'toggle',
407 604 'group' => 'role_based_settings',
408 605 'priority' => 1,
409 - 'field_data' => array(
606 + 'field_data' => [
410 607 'id' => 'subscrpt_role_based_access',
411 608 'title' => __( 'Enable Role Based Access', 'subscription' ),
412 609 'description' => __( 'Show/Hide products based on user roles.', 'subscription' ),
413 610 'value' => '1',
414 611 'checked' => '1' === get_option( 'subscrpt_role_based_access', '1' ),
415 - ),
416 - ),
417 - );
612 + ],
613 + ],
614 + ];
418 615 }
419 616
420 617 /**
421 618 * Module: Live QR (Illuminate/LiveQR/LiveQR.php) — quick details QR.
@@ -422,66 +619,66 @@
422 619 *
423 620 * @return array
424 621 */
425 622 private function live_qr_fields() {
426 - return array(
427 - array(
623 + return [
624 + [
428 625 'type' => 'heading',
429 626 'group' => 'live_qr_settings',
430 - 'priority' => 5,
431 - 'field_data' => array(
627 + 'priority' => 8,
628 + 'field_data' => [
432 629 'title' => __( 'Quick Details QR Settings', 'subscription' ),
433 - ),
434 - ),
435 - array(
630 + ],
631 + ],
632 + [
436 633 'type' => 'toggle',
437 634 'group' => 'live_qr_settings',
438 635 'priority' => 1,
439 - 'field_data' => array(
636 + 'field_data' => [
440 637 'id' => 'subscrpt_live_qr_active',
441 638 'title' => __( 'Enable Quick Details QR', 'subscription' ),
442 639 'label' => '',
443 640 'value' => '1',
444 641 'checked' => '1' === get_option( 'subscrpt_live_qr_active', '1' ),
445 - ),
446 - ),
447 - array(
642 + ],
643 + ],
644 + [
448 645 'type' => 'toggle',
449 646 'group' => 'live_qr_settings',
450 647 'priority' => 2,
451 - 'field_data' => array(
648 + 'field_data' => [
452 649 'id' => 'subscrpt_live_qr_show_product',
453 650 'title' => __( 'Product Details', 'subscription' ),
454 651 'label' => __( 'Show product details in the subscription quick view', 'subscription' ),
455 652 'value' => '1',
456 653 'checked' => '1' === get_option( 'subscrpt_live_qr_show_product', '1' ),
457 - ),
458 - ),
459 - array(
654 + ],
655 + ],
656 + [
460 657 'type' => 'toggle',
461 658 'group' => 'live_qr_settings',
462 659 'priority' => 3,
463 - 'field_data' => array(
660 + 'field_data' => [
464 661 'id' => 'subscrpt_live_qr_show_billing',
465 662 'title' => __( 'Billing Details', 'subscription' ),
466 663 'label' => __( 'Show billing details in the subscription quick view', 'subscription' ),
467 664 'value' => '1',
468 665 'checked' => '1' === get_option( 'subscrpt_live_qr_show_billing', '0' ),
469 - ),
470 - ),
471 - array(
666 + ],
667 + ],
668 + [
472 669 'type' => 'toggle',
473 670 'group' => 'live_qr_settings',
474 671 'priority' => 4,
475 - 'field_data' => array(
672 + 'field_data' => [
476 673 'id' => 'subscrpt_live_qr_show_timeline',
477 674 'title' => __( 'Timeline', 'subscription' ),
478 675 'label' => __( 'Show subscription timeline in the subscription quick view', 'subscription' ),
479 676 'value' => '1',
480 677 'checked' => '1' === get_option( 'subscrpt_live_qr_show_timeline', '0' ),
481 - ),
482 - ),
483 - );
678 + ],
679 + ],
680 + ];
484 681 }
485 682
486 683 /**
487 684 * Module: Payment Gateways (Illuminate/Gateways/PaymentGateways.php).
@@ -488,9 +685,9 @@
488 685 *
489 686 * @return array
490 687 */
491 688 private function payment_gateway_fields() {
492 - $gateway_options = array();
689 + $gateway_options = [];
493 690 if ( function_exists( 'WC' ) && WC()->payment_gateways ) {
494 691 foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway_id => $gateway ) {
495 692 $gateway_options[ $gateway_id ] = $gateway->get_title();
496 693 }
@@ -495,28 +692,28 @@
495 692 $gateway_options[ $gateway_id ] = $gateway->get_title();
496 693 }
497 694 }
498 695
499 - return array(
500 - array(
696 + return [
697 + [
501 698 'type' => 'heading',
502 699 'group' => 'payment_gateways',
503 - 'priority' => 0.1,
504 - 'field_data' => array(
700 + 'priority' => 1,
701 + 'field_data' => [
505 702 'title' => __( 'Payment Gateway Settings', 'subscription' ),
506 - ),
507 - ),
508 - array(
703 + ],
704 + ],
705 + [
509 706 'type' => 'multi_select',
510 707 'group' => 'payment_gateways',
511 708 'priority' => 2,
512 - 'field_data' => array(
709 + 'field_data' => [
513 710 'id' => 'hidden_payment_gateways',
514 711 'title' => __( 'Hide Payment Gateways', 'subscription' ),
515 712 'description' => __( 'Select payment gateways to hide for subscription products. (keep empty for not hiding any)', 'subscription' ),
516 713 'options' => $gateway_options,
517 - 'selected' => get_option( 'hidden_payment_gateways', array() ),
518 - ),
519 - ),
520 - );
714 + 'selected' => get_option( 'hidden_payment_gateways', [] ),
715 + ],
716 + ],
717 + ];
521 718 }
522 719 }