| @@ -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(), |
| @@ -78,9 +79,9 @@ | ||
| 78 | 79 | private function pro_core_fields() { |
| 79 | 80 | return [ |
| 80 | 81 | [ |
| 81 | 82 | 'type' => 'select', |
| 82 | - 'group' => 'main', | |
| 83 | + 'group' => 'renewals', | |
| 83 | 84 | 'priority' => 7, |
| 84 | 85 | 'field_data' => [ |
| 85 | 86 | 'id' => 'subscrpt_renewal_price', |
| 86 | 87 | 'title' => __( 'Renewal Price', 'subscription' ), |
| @@ -93,9 +94,9 @@ | ||
| 93 | 94 | ], |
| 94 | 95 | ], |
| 95 | 96 | [ |
| 96 | 97 | 'type' => 'toggle', |
| 97 | - 'group' => 'main', | |
| 98 | + 'group' => 'renewals', | |
| 98 | 99 | 'priority' => 8, |
| 99 | 100 | 'field_data' => [ |
| 100 | 101 | 'id' => 'subscrpt_early_renew', |
| 101 | 102 | 'title' => __( 'Early Renewal', 'subscription' ), |
| @@ -104,12 +105,118 @@ | ||
| 104 | 105 | 'value' => '1', |
| 105 | 106 | 'checked' => '1' === get_option( 'subscrpt_early_renew', '1' ), |
| 106 | 107 | ], |
| 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 | + ], | |
| 108 | 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 | */ |
| @@ -117,9 +224,9 @@ | ||
| 117 | 224 | return [ |
| 118 | 225 | [ |
| 119 | 226 | 'type' => 'heading', |
| 120 | 227 | 'group' => 'grace_period', |
| 121 | - 'priority' => 3, | |
| 228 | + 'priority' => 5, | |
| 122 | 229 | 'field_data' => [ |
| 123 | 230 | 'title' => __( 'Grace Period Settings', 'subscription' ), |
| 124 | 231 | ], |
| 125 | 232 | ], |
| @@ -180,9 +287,9 @@ | ||
| 180 | 287 | return [ |
| 181 | 288 | [ |
| 182 | 289 | 'type' => 'heading', |
| 183 | 290 | 'group' => 'payment_failure', |
| 184 | - 'priority' => 4, | |
| 291 | + 'priority' => 6, | |
| 185 | 292 | 'field_data' => [ |
| 186 | 293 | 'title' => __( 'Payment Failure Handling', 'subscription' ), |
| 187 | 294 | ], |
| 188 | 295 | ], |
| @@ -316,9 +423,9 @@ | ||
| 316 | 423 | return [ |
| 317 | 424 | [ |
| 318 | 425 | 'type' => 'heading', |
| 319 | 426 | 'group' => 'health_queue', |
| 320 | - 'priority' => 8, | |
| 427 | + 'priority' => 9, | |
| 321 | 428 | 'field_data' => [ |
| 322 | 429 | 'title' => __( 'Subscription Health', 'subscription' ), |
| 323 | 430 | ], |
| 324 | 431 | ], |
| @@ -360,8 +467,21 @@ | ||
| 360 | 467 | 'value' => '1', |
| 361 | 468 | 'checked' => '1' === get_option( 'wp_subscription_auto_complete_order', '1' ), |
| 362 | 469 | ], |
| 363 | 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 | + ], | |
| 364 | 484 | ]; |
| 365 | 485 | } |
| 366 | 486 | |
| 367 | 487 | /** |
| @@ -371,10 +491,18 @@ | ||
| 371 | 491 | */ |
| 372 | 492 | private function switch_fields() { |
| 373 | 493 | return [ |
| 374 | 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 | 506 | 'field_data' => [ |
| 379 | 507 | 'id' => 'subscrpt_switch_enabled', |
| 380 | 508 | 'title' => __( 'Switch Subscription', 'subscription' ), |
| @@ -385,9 +513,9 @@ | ||
| 385 | 513 | ], |
| 386 | 514 | ], |
| 387 | 515 | [ |
| 388 | 516 | 'type' => 'toggle', |
| 389 | - 'group' => 'general', | |
| 517 | + 'group' => 'switching', | |
| 390 | 518 | 'priority' => 10, |
| 391 | 519 | 'field_data' => [ |
| 392 | 520 | 'id' => 'subscrpt_downgrade_allowed', |
| 393 | 521 | 'title' => __( 'Downgrade Subscription', 'subscription' ), |
| @@ -398,9 +526,9 @@ | ||
| 398 | 526 | ], |
| 399 | 527 | ], |
| 400 | 528 | [ |
| 401 | 529 | 'type' => 'join', |
| 402 | - 'group' => 'general', | |
| 530 | + 'group' => 'switching', | |
| 403 | 531 | 'priority' => 11, |
| 404 | 532 | 'field_data' => [ |
| 405 | 533 | 'title' => __( 'Switch Fee', 'subscription' ), |
| 406 | 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' ), |
| @@ -438,9 +566,9 @@ | ||
| 438 | 566 | ], |
| 439 | 567 | ], |
| 440 | 568 | [ |
| 441 | 569 | 'type' => 'select', |
| 442 | - 'group' => 'general', | |
| 570 | + 'group' => 'switching', | |
| 443 | 571 | 'priority' => 12, |
| 444 | 572 | 'field_data' => [ |
| 445 | 573 | 'id' => 'subscrpt_switch_fee_apply_to', |
| 446 | 574 | 'title' => __( 'Apply Fee To', 'subscription' ), |
| @@ -465,9 +593,9 @@ | ||
| 465 | 593 | return [ |
| 466 | 594 | [ |
| 467 | 595 | 'type' => 'heading', |
| 468 | 596 | 'group' => 'role_based_settings', |
| 469 | - 'priority' => 6, | |
| 597 | + 'priority' => 7, | |
| 470 | 598 | 'field_data' => [ |
| 471 | 599 | 'title' => __( 'Role-Based Settings', 'subscription' ), |
| 472 | 600 | ], |
| 473 | 601 | ], |
| @@ -495,9 +623,9 @@ | ||
| 495 | 623 | return [ |
| 496 | 624 | [ |
| 497 | 625 | 'type' => 'heading', |
| 498 | 626 | 'group' => 'live_qr_settings', |
| 499 | - 'priority' => 5, | |
| 627 | + 'priority' => 8, | |
| 500 | 628 | 'field_data' => [ |
| 501 | 629 | 'title' => __( 'Quick Details QR Settings', 'subscription' ), |
| 502 | 630 | ], |
| 503 | 631 | ], |
| @@ -568,9 +696,9 @@ | ||
| 568 | 696 | return [ |
| 569 | 697 | [ |
| 570 | 698 | 'type' => 'heading', |
| 571 | 699 | 'group' => 'payment_gateways', |
| 572 | - 'priority' => 0.1, | |
| 700 | + 'priority' => 1, | |
| 573 | 701 | 'field_data' => [ |
| 574 | 702 | 'title' => __( 'Payment Gateway Settings', 'subscription' ), |
| 575 | 703 | ], |
| 576 | 704 | ], |