PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.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
subscription / includes / Admin / ProSettingsFields.php

ProSettingsFields.php in Subscriptions for WooCommerce with Stripe Recurring Payments 2.4.0, at includes/Admin/ProSettingsFields.php

720 lines 23.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Pro Settings Fields — the single source of the Pro settings UI.
4 *
5 * Defines every Pro settings field (the UI only — no options are registered or
6 * saved here; the real settings are registered and processed by the Pro plugin).
7 * The fields are always added to the settings page via the
8 * `subscrpt_settings_fields` filter. When Pro is **not** active they render
9 * locked (disabled, with a "Pro" badge); when Pro is active they become
10 * interactive and the Pro plugin saves their values.
11 *
12 * The lock state is derived from `subscrpt_pro_activated()` and injected onto
13 * every field as `pro_locked`, which SettingsHelper uses for the badge and the
14 * non-interactive styling.
15 *
16 * @package SpringDevs\Subscription\Admin
17 */
18
19 namespace SpringDevs\Subscription\Admin;
20
21 // Exit if accessed directly.
22 defined( 'ABSPATH' ) || exit;
23
24 /**
25 * Class ProSettingsFields
26 *
27 * @package SpringDevs\Subscription\Admin
28 */
29 class ProSettingsFields {
30
31 /**
32 * Initialize the class.
33 */
34 public function __construct() {
35 add_filter( 'subscrpt_settings_fields', [ $this, 'add_pro_preview_fields' ] );
36 }
37
38 /**
39 * Merge the Pro settings fields into the settings fields list.
40 *
41 * Fields are locked (disabled + Pro badge) only while Pro is inactive.
42 *
43 * @param array $settings_fields Existing settings fields.
44 * @return array
45 */
46 public function add_pro_preview_fields( $settings_fields ) {
47 $pro_fields = array_merge(
48 $this->pro_core_fields(),
49 $this->license_fields(),
50 $this->grace_period_fields(),
51 $this->payment_failure_fields(),
52 $this->api_fields(),
53 $this->health_queue_fields(),
54 $this->order_fields(),
55 $this->switch_fields(),
56 $this->role_management_fields(),
57 $this->live_qr_fields(),
58 $this->payment_gateway_fields()
59 );
60
61 // Lock the fields only when Pro is not active.
62 $locked = ! subscrpt_pro_activated();
63 foreach ( $pro_fields as &$field ) {
64 $field['field_data']['pro_locked'] = $locked;
65 if ( $locked ) {
66 $field['field_data']['disabled'] = true;
67 }
68 }
69 unset( $field );
70
71 return array_merge( $settings_fields, $pro_fields );
72 }
73
74 /**
75 * Module: Pro Core (Admin/Settings.php) — general settings additions.
76 *
77 * @return array
78 */
79 private function pro_core_fields() {
80 return [
81 [
82 'type' => 'select',
83 'group' => 'renewals',
84 'priority' => 7,
85 'field_data' => [
86 'id' => 'subscrpt_renewal_price',
87 'title' => __( 'Renewal Price', 'subscription' ),
88 'description' => __( 'Choose a price that will be used for subscription renewal.', 'subscription' ),
89 'options' => [
90 'subscribed' => __( 'Subscribed Price', 'subscription' ),
91 'updated' => __( 'New/Updated Price', 'subscription' ),
92 ],
93 'selected' => esc_attr( get_option( 'subscrpt_renewal_price', 'subscribed' ) ),
94 ],
95 ],
96 [
97 'type' => 'toggle',
98 'group' => 'renewals',
99 'priority' => 8,
100 'field_data' => [
101 'id' => 'subscrpt_early_renew',
102 'title' => __( 'Early Renewal', 'subscription' ),
103 'label' => __( 'Accept Early Renewal Payments', 'subscription' ),
104 'description' => __( 'With early renewals enabled, customers can renew their subscriptions before the next payment date.', 'subscription' ),
105 'value' => '1',
106 'checked' => '1' === get_option( 'subscrpt_early_renew', '1' ),
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 ];
174 }
175
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 /**
219 * Module: Grace Period (Admin/Settings.php).
220 *
221 * @return array
222 */
223 private function grace_period_fields() {
224 return [
225 [
226 'type' => 'heading',
227 'group' => 'grace_period',
228 'priority' => 5,
229 'field_data' => [
230 'title' => __( 'Grace Period Settings', 'subscription' ),
231 ],
232 ],
233 [
234 'type' => 'input',
235 'group' => 'grace_period',
236 'priority' => 1,
237 'field_data' => [
238 'id' => 'subscrpt_default_payment_grace_period',
239 'title' => __( 'Grace Period (Days)', 'subscription' ),
240 'description' => __( 'Days to maintain access after subscriptions expires. (0 = No grace period. Max 30 days)', 'subscription' ),
241 'value' => esc_attr( get_option( 'subscrpt_default_payment_grace_period', '7' ) ),
242 'type' => 'number',
243 'attributes' => [
244 'min' => 0,
245 'max' => 30,
246 ],
247 ],
248 ],
249 [
250 'type' => 'toggle',
251 'group' => 'grace_period',
252 'priority' => 2,
253 'field_data' => [
254 'id' => 'subscrpt_enable_grace_period_notifications',
255 'title' => __( 'Grace Period Notifications', 'subscription' ),
256 'label' => __( 'Send notifications during grace period', 'subscription' ),
257 'description' => __( 'Customers will receive warnings before their access is suspended.', 'subscription' ),
258 'value' => '1',
259 'checked' => '1' === get_option( 'subscrpt_enable_grace_period_notifications', '1' ),
260 ],
261 ],
262 [
263 'type' => 'input',
264 'group' => 'grace_period',
265 'priority' => 3,
266 'field_data' => [
267 'id' => 'subscrpt_grace_period_warning_days',
268 'title' => __( 'Grace Period Warning (Days Before)', 'subscription' ),
269 'description' => __( 'Send warning emails this many days before grace period expires. (1-7 days)', 'subscription' ),
270 'value' => esc_attr( get_option( 'subscrpt_grace_period_warning_days', '2' ) ),
271 'type' => 'number',
272 'attributes' => [
273 'min' => 1,
274 'max' => 7,
275 ],
276 ],
277 ],
278 ];
279 }
280
281 /**
282 * Module: Payment Failure Handling (Admin/Settings.php).
283 *
284 * @return array
285 */
286 private function payment_failure_fields() {
287 return [
288 [
289 'type' => 'heading',
290 'group' => 'payment_failure',
291 'priority' => 6,
292 'field_data' => [
293 'title' => __( 'Payment Failure Handling', 'subscription' ),
294 ],
295 ],
296 [
297 'type' => 'input',
298 'group' => 'payment_failure',
299 'priority' => 1,
300 'field_data' => [
301 'id' => 'subscrpt_default_max_payment_retries',
302 'title' => __( 'Default Max Payment Retries', 'subscription' ),
303 'description' => __( 'Default number of automatic retry attempts for failed payments. (0 = No retries. Max 10 retries)', 'subscription' ),
304 'value' => esc_attr( get_option( 'subscrpt_default_max_payment_retries', '3' ) ),
305 'type' => 'number',
306 'attributes' => [
307 'min' => 0,
308 'max' => 10,
309 ],
310 ],
311 ],
312 [
313 'type' => 'toggle',
314 'group' => 'payment_failure',
315 'priority' => 2,
316 'field_data' => [
317 'id' => 'subscrpt_enable_payment_failure_emails',
318 'title' => __( 'Enable Payment Failure Emails', 'subscription' ),
319 'label' => __( 'Send email notifications when payments fail', 'subscription' ),
320 'description' => __( 'Customers will receive emails about failed payments and retry attempts.', 'subscription' ),
321 'value' => '1',
322 'checked' => '1' === get_option( 'subscrpt_enable_payment_failure_emails', '1' ),
323 ],
324 ],
325 [
326 'type' => 'input',
327 'group' => 'payment_failure',
328 'priority' => 3,
329 'field_data' => [
330 'id' => 'subscrpt_payment_failure_email_delay',
331 'title' => __( 'Payment Failure Email Delay (Hours)', 'subscription' ),
332 'description' => __( 'Delay before sending payment failure emails to avoid spam during temporary issues. (0-168 hours)', 'subscription' ),
333 'value' => esc_attr( get_option( 'subscrpt_payment_failure_email_delay', '24' ) ),
334 'type' => 'number',
335 'attributes' => [
336 'min' => 0,
337 'max' => 168,
338 ],
339 ],
340 ],
341 ];
342 }
343
344 /**
345 * Module: API Settings (Admin/Settings.php).
346 *
347 * @return array
348 */
349 private function api_fields() {
350 return [
351 [
352 'type' => 'heading',
353 'group' => 'api_settings',
354 'priority' => 99,
355 'field_data' => [
356 'title' => __( 'API Settings', 'subscription' ),
357 ],
358 ],
359 [
360 'type' => 'toggle',
361 'group' => 'api_settings',
362 'priority' => 1,
363 'field_data' => [
364 'id' => 'wpsubscription_api_enabled',
365 'title' => __( 'Enable API', 'subscription' ),
366 'description' => __( 'Enable REST API endpoints for subscription actions', 'subscription' ),
367 'value' => 'on',
368 'checked' => 'on' === get_option( 'wpsubscription_api_enabled', 'on' ),
369 ],
370 ],
371 [
372 'type' => 'join',
373 'group' => 'api_settings',
374 'priority' => 2,
375 'field_data' => [
376 'title' => __( 'API Key', 'subscription' ),
377 'description' => __( 'API key for external integrations. Keep this secure.', 'subscription' ),
378 'elements' => [
379 SettingsHelper::inp_element(
380 [
381 'id' => 'wpsubscription_api_key',
382 'value' => esc_attr( get_option( 'wpsubscription_api_key', '' ) ),
383 'type' => 'text',
384 'style' => 'min-width:366px;',
385 'attributes' => [
386 'readonly' => true,
387 ],
388 ],
389 true
390 ),
391 '<span class="wpsubs-tooltip" data-tip="' . esc_attr__( 'Regenerate API Key', 'subscription' ) . '">'
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' ) . '">'
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>'
394 . '</button>'
395 . '</span>',
396 ],
397 ],
398 ],
399 [
400 'type' => 'input',
401 'group' => 'api_settings',
402 'priority' => 3,
403 'field_data' => [
404 'id' => 'subscrpt_api_endpoint_url',
405 'title' => __( 'REST API Endpoint URL', 'subscription' ),
406 'description' => __( 'Copy and use this endpoint for all API actions.', 'subscription' ),
407 'value' => esc_url( home_url( '/wp-json/wpsubscription/v1/action' ) ),
408 'type' => 'text',
409 'attributes' => [
410 'readonly' => true,
411 ],
412 ],
413 ],
414 ];
415 }
416
417 /**
418 * Module: Subscription Health (Admin/Settings.php).
419 *
420 * @return array
421 */
422 private function health_queue_fields() {
423 return [
424 [
425 'type' => 'heading',
426 'group' => 'health_queue',
427 'priority' => 9,
428 'field_data' => [
429 'title' => __( 'Subscription Health', 'subscription' ),
430 ],
431 ],
432 [
433 'type' => 'select',
434 'group' => 'health_queue',
435 'priority' => 2,
436 'field_data' => [
437 'id' => 'subscrpt_health_queue_email_frequency',
438 'title' => __( 'Health Queue Email Frequency', 'subscription' ),
439 'description' => __( 'How often to send the admin health queue reminder email. The email is only sent when subscriptions need attention.', 'subscription' ),
440 'options' => [
441 'daily' => __( 'Daily', 'subscription' ),
442 'subscrpt_weekly' => __( 'Weekly', 'subscription' ),
443 'subscrpt_monthly' => __( 'Monthly', 'subscription' ),
444 'never' => __( 'Never', 'subscription' ),
445 ],
446 'selected' => esc_attr( get_option( 'subscrpt_health_queue_email_frequency', 'subscrpt_weekly' ) ),
447 ],
448 ],
449 ];
450 }
451
452 /**
453 * Module: Order (Illuminate/Order.php) — auto complete orders.
454 *
455 * @return array
456 */
457 private function order_fields() {
458 return [
459 [
460 'type' => 'toggle',
461 'group' => 'payment_gateways',
462 'priority' => 1,
463 'field_data' => [
464 'id' => 'wp_subscription_auto_complete_order',
465 'title' => __( 'Auto Complete Orders', 'subscription' ),
466 'description' => __( 'Automatically change status of processing orders to completed.', 'subscription' ),
467 'value' => '1',
468 'checked' => '1' === get_option( 'wp_subscription_auto_complete_order', '1' ),
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 ];
485 }
486
487 /**
488 * Module: Switch Subscription (Illuminate/SubscriptionSwitch.php).
489 *
490 * @return array
491 */
492 private function switch_fields() {
493 return [
494 [
495 'type' => 'heading',
496 'group' => 'switching',
497 'priority' => 3,
498 'field_data' => [
499 'title' => __( 'Switching & Upgrades', 'subscription' ),
500 ],
501 ],
502 [
503 'type' => 'toggle',
504 'group' => 'switching',
505 'priority' => 9,
506 'field_data' => [
507 'id' => 'subscrpt_switch_enabled',
508 'title' => __( 'Switch Subscription', 'subscription' ),
509 'label' => __( 'Allow users to upgrade/downgrade their subscriptions.', 'subscription' ),
510 'description' => '',
511 'value' => '1',
512 'checked' => '1' === get_option( 'subscrpt_switch_enabled', '0' ),
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 ];
585 }
586
587 /**
588 * Module: Role Management (Illuminate/RoleManagement.php).
589 *
590 * @return array
591 */
592 private function role_management_fields() {
593 return [
594 [
595 'type' => 'heading',
596 'group' => 'role_based_settings',
597 'priority' => 7,
598 'field_data' => [
599 'title' => __( 'Role-Based Settings', 'subscription' ),
600 ],
601 ],
602 [
603 'type' => 'toggle',
604 'group' => 'role_based_settings',
605 'priority' => 1,
606 'field_data' => [
607 'id' => 'subscrpt_role_based_access',
608 'title' => __( 'Enable Role Based Access', 'subscription' ),
609 'description' => __( 'Show/Hide products based on user roles.', 'subscription' ),
610 'value' => '1',
611 'checked' => '1' === get_option( 'subscrpt_role_based_access', '1' ),
612 ],
613 ],
614 ];
615 }
616
617 /**
618 * Module: Live QR (Illuminate/LiveQR/LiveQR.php) — quick details QR.
619 *
620 * @return array
621 */
622 private function live_qr_fields() {
623 return [
624 [
625 'type' => 'heading',
626 'group' => 'live_qr_settings',
627 'priority' => 8,
628 'field_data' => [
629 'title' => __( 'Quick Details QR Settings', 'subscription' ),
630 ],
631 ],
632 [
633 'type' => 'toggle',
634 'group' => 'live_qr_settings',
635 'priority' => 1,
636 'field_data' => [
637 'id' => 'subscrpt_live_qr_active',
638 'title' => __( 'Enable Quick Details QR', 'subscription' ),
639 'label' => '',
640 'value' => '1',
641 'checked' => '1' === get_option( 'subscrpt_live_qr_active', '1' ),
642 ],
643 ],
644 [
645 'type' => 'toggle',
646 'group' => 'live_qr_settings',
647 'priority' => 2,
648 'field_data' => [
649 'id' => 'subscrpt_live_qr_show_product',
650 'title' => __( 'Product Details', 'subscription' ),
651 'label' => __( 'Show product details in the subscription quick view', 'subscription' ),
652 'value' => '1',
653 'checked' => '1' === get_option( 'subscrpt_live_qr_show_product', '1' ),
654 ],
655 ],
656 [
657 'type' => 'toggle',
658 'group' => 'live_qr_settings',
659 'priority' => 3,
660 'field_data' => [
661 'id' => 'subscrpt_live_qr_show_billing',
662 'title' => __( 'Billing Details', 'subscription' ),
663 'label' => __( 'Show billing details in the subscription quick view', 'subscription' ),
664 'value' => '1',
665 'checked' => '1' === get_option( 'subscrpt_live_qr_show_billing', '0' ),
666 ],
667 ],
668 [
669 'type' => 'toggle',
670 'group' => 'live_qr_settings',
671 'priority' => 4,
672 'field_data' => [
673 'id' => 'subscrpt_live_qr_show_timeline',
674 'title' => __( 'Timeline', 'subscription' ),
675 'label' => __( 'Show subscription timeline in the subscription quick view', 'subscription' ),
676 'value' => '1',
677 'checked' => '1' === get_option( 'subscrpt_live_qr_show_timeline', '0' ),
678 ],
679 ],
680 ];
681 }
682
683 /**
684 * Module: Payment Gateways (Illuminate/Gateways/PaymentGateways.php).
685 *
686 * @return array
687 */
688 private function payment_gateway_fields() {
689 $gateway_options = [];
690 if ( function_exists( 'WC' ) && WC()->payment_gateways ) {
691 foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway_id => $gateway ) {
692 $gateway_options[ $gateway_id ] = $gateway->get_title();
693 }
694 }
695
696 return [
697 [
698 'type' => 'heading',
699 'group' => 'payment_gateways',
700 'priority' => 1,
701 'field_data' => [
702 'title' => __( 'Payment Gateway Settings', 'subscription' ),
703 ],
704 ],
705 [
706 'type' => 'multi_select',
707 'group' => 'payment_gateways',
708 'priority' => 2,
709 'field_data' => [
710 'id' => 'hidden_payment_gateways',
711 'title' => __( 'Hide Payment Gateways', 'subscription' ),
712 'description' => __( 'Select payment gateways to hide for subscription products. (keep empty for not hiding any)', 'subscription' ),
713 'options' => $gateway_options,
714 'selected' => get_option( 'hidden_payment_gateways', [] ),
715 ],
716 ],
717 ];
718 }
719 }
720