| @@ -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,91 @@ | ||
| 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 | + ]; | |
| 109 | 110 | } |
| 110 | 111 | |
| 111 | 112 | /** |
| 113 | + * Module: License integrations (Integrations/LicenseManagerWoo.php). | |
| 114 | + * | |
| 115 | + * @return array | |
| 116 | + */ | |
| 117 | + private function license_fields() { | |
| 118 | + return [ | |
| 119 | + [ | |
| 120 | + 'type' => 'heading', | |
| 121 | + 'group' => 'license_settings', | |
| 122 | + 'priority' => 4, | |
| 123 | + 'field_data' => [ | |
| 124 | + 'title' => __( 'License Settings', 'subscription' ), | |
| 125 | + ], | |
| 126 | + ], | |
| 127 | + [ | |
| 128 | + 'type' => 'toggle', | |
| 129 | + 'group' => 'license_settings', | |
| 130 | + 'priority' => 1, | |
| 131 | + 'field_data' => [ | |
| 132 | + 'id' => 'subscrpt_regenerate_license_on_renewal', | |
| 133 | + 'title' => __( 'Regenerate License on Renewal', 'subscription' ), | |
| 134 | + 'description' => __( 'Enable this option if you want to invalidate the old key and issue a fresh license key whenever a subscription renews.', 'subscription' ), | |
| 135 | + 'value' => '1', | |
| 136 | + 'checked' => '1' === get_option( 'subscrpt_regenerate_license_on_renewal', '0' ), | |
| 137 | + ], | |
| 138 | + ], | |
| 139 | + [ | |
| 140 | + 'type' => 'toggle', | |
| 141 | + 'group' => 'license_settings', | |
| 142 | + 'priority' => 2, | |
| 143 | + 'field_data' => [ | |
| 144 | + 'id' => 'subscrpt_deactivate_old_license_on_renewal', | |
| 145 | + 'title' => __( 'Deactivate Previous License', 'subscription' ), | |
| 146 | + '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' ), | |
| 147 | + 'value' => '1', | |
| 148 | + 'checked' => '1' === get_option( 'subscrpt_deactivate_old_license_on_renewal', '1' ), | |
| 149 | + ], | |
| 150 | + ], | |
| 151 | + ]; | |
| 152 | + } | |
| 153 | + | |
| 154 | + /** | |
| 112 | 155 | * Module: Grace Period (Admin/Settings.php). |
| 113 | 156 | * |
| 114 | 157 | * @return array |
| 115 | 158 | */ |
| 116 | 159 | private function grace_period_fields() { |
| 117 | - return array( | |
| 118 | - array( | |
| 160 | + return [ | |
| 161 | + [ | |
| 119 | 162 | 'type' => 'heading', |
| 120 | 163 | 'group' => 'grace_period', |
| 121 | - 'priority' => 3, | |
| 122 | - 'field_data' => array( | |
| 164 | + 'priority' => 5, | |
| 165 | + 'field_data' => [ | |
| 123 | 166 | 'title' => __( 'Grace Period Settings', 'subscription' ), |
| 124 | - ), | |
| 125 | - ), | |
| 126 | - array( | |
| 167 | + ], | |
| 168 | + ], | |
| 169 | + [ | |
| 127 | 170 | 'type' => 'input', |
| 128 | 171 | 'group' => 'grace_period', |
| 129 | 172 | 'priority' => 1, |
| 130 | - 'field_data' => array( | |
| 173 | + 'field_data' => [ | |
| 131 | 174 | 'id' => 'subscrpt_default_payment_grace_period', |
| 132 | 175 | 'title' => __( 'Grace Period (Days)', 'subscription' ), |
| 133 | 176 | 'description' => __( 'Days to maintain access after subscriptions expires. (0 = No grace period. Max 30 days)', 'subscription' ), |
| 134 | 177 | 'value' => esc_attr( get_option( 'subscrpt_default_payment_grace_period', '7' ) ), |
| 135 | 178 | 'type' => 'number', |
| 136 | - 'attributes' => array( | |
| 179 | + 'attributes' => [ | |
| 137 | 180 | 'min' => 0, |
| 138 | 181 | 'max' => 30, |
| 139 | - ), | |
| 140 | - ), | |
| 141 | - ), | |
| 142 | - array( | |
| 182 | + ], | |
| 183 | + ], | |
| 184 | + ], | |
| 185 | + [ | |
| 143 | 186 | 'type' => 'toggle', |
| 144 | 187 | 'group' => 'grace_period', |
| 145 | 188 | 'priority' => 2, |
| 146 | - 'field_data' => array( | |
| 189 | + 'field_data' => [ | |
| 147 | 190 | 'id' => 'subscrpt_enable_grace_period_notifications', |
| 148 | 191 | 'title' => __( 'Grace Period Notifications', 'subscription' ), |
| 149 | 192 | 'label' => __( 'Send notifications during grace period', 'subscription' ), |
| 150 | 193 | 'description' => __( 'Customers will receive warnings before their access is suspended.', 'subscription' ), |
| @@ -149,27 +192,27 @@ | ||
| 149 | 192 | 'label' => __( 'Send notifications during grace period', 'subscription' ), |
| 150 | 193 | 'description' => __( 'Customers will receive warnings before their access is suspended.', 'subscription' ), |
| 151 | 194 | 'value' => '1', |
| 152 | 195 | 'checked' => '1' === get_option( 'subscrpt_enable_grace_period_notifications', '1' ), |
| 153 | - ), | |
| 154 | - ), | |
| 155 | - array( | |
| 196 | + ], | |
| 197 | + ], | |
| 198 | + [ | |
| 156 | 199 | 'type' => 'input', |
| 157 | 200 | 'group' => 'grace_period', |
| 158 | 201 | 'priority' => 3, |
| 159 | - 'field_data' => array( | |
| 202 | + 'field_data' => [ | |
| 160 | 203 | 'id' => 'subscrpt_grace_period_warning_days', |
| 161 | 204 | 'title' => __( 'Grace Period Warning (Days Before)', 'subscription' ), |
| 162 | 205 | 'description' => __( 'Send warning emails this many days before grace period expires. (1-7 days)', 'subscription' ), |
| 163 | 206 | 'value' => esc_attr( get_option( 'subscrpt_grace_period_warning_days', '2' ) ), |
| 164 | 207 | 'type' => 'number', |
| 165 | - 'attributes' => array( | |
| 208 | + 'attributes' => [ | |
| 166 | 209 | 'min' => 1, |
| 167 | 210 | 'max' => 7, |
| 168 | - ), | |
| 169 | - ), | |
| 170 | - ), | |
| 171 | - ); | |
| 211 | + ], | |
| 212 | + ], | |
| 213 | + ], | |
| 214 | + ]; | |
| 172 | 215 | } |
| 173 | 216 | |
| 174 | 217 | /** |
| 175 | 218 | * Module: Payment Failure Handling (Admin/Settings.php). |
| @@ -176,38 +219,38 @@ | ||
| 176 | 219 | * |
| 177 | 220 | * @return array |
| 178 | 221 | */ |
| 179 | 222 | private function payment_failure_fields() { |
| 180 | - return array( | |
| 181 | - array( | |
| 223 | + return [ | |
| 224 | + [ | |
| 182 | 225 | 'type' => 'heading', |
| 183 | 226 | 'group' => 'payment_failure', |
| 184 | - 'priority' => 4, | |
| 185 | - 'field_data' => array( | |
| 227 | + 'priority' => 6, | |
| 228 | + 'field_data' => [ | |
| 186 | 229 | 'title' => __( 'Payment Failure Handling', 'subscription' ), |
| 187 | - ), | |
| 188 | - ), | |
| 189 | - array( | |
| 230 | + ], | |
| 231 | + ], | |
| 232 | + [ | |
| 190 | 233 | 'type' => 'input', |
| 191 | 234 | 'group' => 'payment_failure', |
| 192 | 235 | 'priority' => 1, |
| 193 | - 'field_data' => array( | |
| 236 | + 'field_data' => [ | |
| 194 | 237 | 'id' => 'subscrpt_default_max_payment_retries', |
| 195 | 238 | 'title' => __( 'Default Max Payment Retries', 'subscription' ), |
| 196 | 239 | 'description' => __( 'Default number of automatic retry attempts for failed payments. (0 = No retries. Max 10 retries)', 'subscription' ), |
| 197 | 240 | 'value' => esc_attr( get_option( 'subscrpt_default_max_payment_retries', '3' ) ), |
| 198 | 241 | 'type' => 'number', |
| 199 | - 'attributes' => array( | |
| 242 | + 'attributes' => [ | |
| 200 | 243 | 'min' => 0, |
| 201 | 244 | 'max' => 10, |
| 202 | - ), | |
| 203 | - ), | |
| 204 | - ), | |
| 205 | - array( | |
| 245 | + ], | |
| 246 | + ], | |
| 247 | + ], | |
| 248 | + [ | |
| 206 | 249 | 'type' => 'toggle', |
| 207 | 250 | 'group' => 'payment_failure', |
| 208 | 251 | 'priority' => 2, |
| 209 | - 'field_data' => array( | |
| 252 | + 'field_data' => [ | |
| 210 | 253 | 'id' => 'subscrpt_enable_payment_failure_emails', |
| 211 | 254 | 'title' => __( 'Enable Payment Failure Emails', 'subscription' ), |
| 212 | 255 | 'label' => __( 'Send email notifications when payments fail', 'subscription' ), |
| 213 | 256 | 'description' => __( 'Customers will receive emails about failed payments and retry attempts.', 'subscription' ), |
| @@ -212,27 +255,27 @@ | ||
| 212 | 255 | 'label' => __( 'Send email notifications when payments fail', 'subscription' ), |
| 213 | 256 | 'description' => __( 'Customers will receive emails about failed payments and retry attempts.', 'subscription' ), |
| 214 | 257 | 'value' => '1', |
| 215 | 258 | 'checked' => '1' === get_option( 'subscrpt_enable_payment_failure_emails', '1' ), |
| 216 | - ), | |
| 217 | - ), | |
| 218 | - array( | |
| 259 | + ], | |
| 260 | + ], | |
| 261 | + [ | |
| 219 | 262 | 'type' => 'input', |
| 220 | 263 | 'group' => 'payment_failure', |
| 221 | 264 | 'priority' => 3, |
| 222 | - 'field_data' => array( | |
| 265 | + 'field_data' => [ | |
| 223 | 266 | 'id' => 'subscrpt_payment_failure_email_delay', |
| 224 | 267 | 'title' => __( 'Payment Failure Email Delay (Hours)', 'subscription' ), |
| 225 | 268 | 'description' => __( 'Delay before sending payment failure emails to avoid spam during temporary issues. (0-168 hours)', 'subscription' ), |
| 226 | 269 | 'value' => esc_attr( get_option( 'subscrpt_payment_failure_email_delay', '24' ) ), |
| 227 | 270 | 'type' => 'number', |
| 228 | - 'attributes' => array( | |
| 271 | + 'attributes' => [ | |
| 229 | 272 | 'min' => 0, |
| 230 | 273 | 'max' => 168, |
| 231 | - ), | |
| 232 | - ), | |
| 233 | - ), | |
| 234 | - ); | |
| 274 | + ], | |
| 275 | + ], | |
| 276 | + ], | |
| 277 | + ]; | |
| 235 | 278 | } |
| 236 | 279 | |
| 237 | 280 | /** |
| 238 | 281 | * Module: API Settings (Admin/Settings.php). |
| @@ -239,47 +282,47 @@ | ||
| 239 | 282 | * |
| 240 | 283 | * @return array |
| 241 | 284 | */ |
| 242 | 285 | private function api_fields() { |
| 243 | - return array( | |
| 244 | - array( | |
| 286 | + return [ | |
| 287 | + [ | |
| 245 | 288 | 'type' => 'heading', |
| 246 | 289 | 'group' => 'api_settings', |
| 247 | 290 | 'priority' => 99, |
| 248 | - 'field_data' => array( | |
| 291 | + 'field_data' => [ | |
| 249 | 292 | 'title' => __( 'API Settings', 'subscription' ), |
| 250 | - ), | |
| 251 | - ), | |
| 252 | - array( | |
| 293 | + ], | |
| 294 | + ], | |
| 295 | + [ | |
| 253 | 296 | 'type' => 'toggle', |
| 254 | 297 | 'group' => 'api_settings', |
| 255 | 298 | 'priority' => 1, |
| 256 | - 'field_data' => array( | |
| 299 | + 'field_data' => [ | |
| 257 | 300 | 'id' => 'wpsubscription_api_enabled', |
| 258 | 301 | 'title' => __( 'Enable API', 'subscription' ), |
| 259 | 302 | 'description' => __( 'Enable REST API endpoints for subscription actions', 'subscription' ), |
| 260 | 303 | 'value' => 'on', |
| 261 | 304 | 'checked' => 'on' === get_option( 'wpsubscription_api_enabled', 'on' ), |
| 262 | - ), | |
| 263 | - ), | |
| 264 | - array( | |
| 305 | + ], | |
| 306 | + ], | |
| 307 | + [ | |
| 265 | 308 | 'type' => 'join', |
| 266 | 309 | 'group' => 'api_settings', |
| 267 | 310 | 'priority' => 2, |
| 268 | - 'field_data' => array( | |
| 311 | + 'field_data' => [ | |
| 269 | 312 | 'title' => __( 'API Key', 'subscription' ), |
| 270 | 313 | 'description' => __( 'API key for external integrations. Keep this secure.', 'subscription' ), |
| 271 | - 'elements' => array( | |
| 314 | + 'elements' => [ | |
| 272 | 315 | SettingsHelper::inp_element( |
| 273 | - array( | |
| 316 | + [ | |
| 274 | 317 | 'id' => 'wpsubscription_api_key', |
| 275 | 318 | 'value' => esc_attr( get_option( 'wpsubscription_api_key', '' ) ), |
| 276 | 319 | 'type' => 'text', |
| 277 | 320 | 'style' => 'min-width:366px;', |
| 278 | - 'attributes' => array( | |
| 321 | + 'attributes' => [ | |
| 279 | 322 | 'readonly' => true, |
| 280 | - ), | |
| 281 | - ), | |
| 323 | + ], | |
| 324 | + ], | |
| 282 | 325 | true |
| 283 | 326 | ), |
| 284 | 327 | '<span class="wpsubs-tooltip" data-tip="' . esc_attr__( 'Regenerate API Key', 'subscription' ) . '">' |
| 285 | 328 | . '<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 +328,27 @@ | ||
| 285 | 328 | . '<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 | 329 | . '<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 | 330 | . '</button>' |
| 288 | 331 | . '</span>', |
| 289 | - ), | |
| 290 | - ), | |
| 291 | - ), | |
| 292 | - array( | |
| 332 | + ], | |
| 333 | + ], | |
| 334 | + ], | |
| 335 | + [ | |
| 293 | 336 | 'type' => 'input', |
| 294 | 337 | 'group' => 'api_settings', |
| 295 | 338 | 'priority' => 3, |
| 296 | - 'field_data' => array( | |
| 339 | + 'field_data' => [ | |
| 297 | 340 | 'id' => 'subscrpt_api_endpoint_url', |
| 298 | 341 | 'title' => __( 'REST API Endpoint URL', 'subscription' ), |
| 299 | 342 | 'description' => __( 'Copy and use this endpoint for all API actions.', 'subscription' ), |
| 300 | 343 | 'value' => esc_url( home_url( '/wp-json/wpsubscription/v1/action' ) ), |
| 301 | 344 | 'type' => 'text', |
| 302 | - 'attributes' => array( | |
| 345 | + 'attributes' => [ | |
| 303 | 346 | 'readonly' => true, |
| 304 | - ), | |
| 305 | - ), | |
| 306 | - ), | |
| 307 | - ); | |
| 347 | + ], | |
| 348 | + ], | |
| 349 | + ], | |
| 350 | + ]; | |
| 308 | 351 | } |
| 309 | 352 | |
| 310 | 353 | /** |
| 311 | 354 | * Module: Subscription Health (Admin/Settings.php). |
| @@ -312,35 +355,35 @@ | ||
| 312 | 355 | * |
| 313 | 356 | * @return array |
| 314 | 357 | */ |
| 315 | 358 | private function health_queue_fields() { |
| 316 | - return array( | |
| 317 | - array( | |
| 359 | + return [ | |
| 360 | + [ | |
| 318 | 361 | 'type' => 'heading', |
| 319 | 362 | 'group' => 'health_queue', |
| 320 | - 'priority' => 8, | |
| 321 | - 'field_data' => array( | |
| 363 | + 'priority' => 9, | |
| 364 | + 'field_data' => [ | |
| 322 | 365 | 'title' => __( 'Subscription Health', 'subscription' ), |
| 323 | - ), | |
| 324 | - ), | |
| 325 | - array( | |
| 366 | + ], | |
| 367 | + ], | |
| 368 | + [ | |
| 326 | 369 | 'type' => 'select', |
| 327 | 370 | 'group' => 'health_queue', |
| 328 | 371 | 'priority' => 2, |
| 329 | - 'field_data' => array( | |
| 372 | + 'field_data' => [ | |
| 330 | 373 | 'id' => 'subscrpt_health_queue_email_frequency', |
| 331 | 374 | 'title' => __( 'Health Queue Email Frequency', 'subscription' ), |
| 332 | 375 | 'description' => __( 'How often to send the admin health queue reminder email. The email is only sent when subscriptions need attention.', 'subscription' ), |
| 333 | - 'options' => array( | |
| 376 | + 'options' => [ | |
| 334 | 377 | 'daily' => __( 'Daily', 'subscription' ), |
| 335 | 378 | 'subscrpt_weekly' => __( 'Weekly', 'subscription' ), |
| 336 | 379 | 'subscrpt_monthly' => __( 'Monthly', 'subscription' ), |
| 337 | 380 | 'never' => __( 'Never', 'subscription' ), |
| 338 | - ), | |
| 381 | + ], | |
| 339 | 382 | 'selected' => esc_attr( get_option( 'subscrpt_health_queue_email_frequency', 'subscrpt_weekly' ) ), |
| 340 | - ), | |
| 341 | - ), | |
| 342 | - ); | |
| 383 | + ], | |
| 384 | + ], | |
| 385 | + ]; | |
| 343 | 386 | } |
| 344 | 387 | |
| 345 | 388 | /** |
| 346 | 389 | * Module: Order (Illuminate/Order.php) — auto complete orders. |
| @@ -347,22 +390,35 @@ | ||
| 347 | 390 | * |
| 348 | 391 | * @return array |
| 349 | 392 | */ |
| 350 | 393 | private function order_fields() { |
| 351 | - return array( | |
| 352 | - array( | |
| 394 | + return [ | |
| 395 | + [ | |
| 353 | 396 | 'type' => 'toggle', |
| 354 | 397 | 'group' => 'payment_gateways', |
| 355 | 398 | 'priority' => 1, |
| 356 | - 'field_data' => array( | |
| 399 | + 'field_data' => [ | |
| 357 | 400 | 'id' => 'wp_subscription_auto_complete_order', |
| 358 | 401 | 'title' => __( 'Auto Complete Orders', 'subscription' ), |
| 359 | 402 | 'description' => __( 'Automatically change status of processing orders to completed.', 'subscription' ), |
| 360 | 403 | 'value' => '1', |
| 361 | 404 | 'checked' => '1' === get_option( 'wp_subscription_auto_complete_order', '1' ), |
| 362 | - ), | |
| 363 | - ), | |
| 364 | - ); | |
| 405 | + ], | |
| 406 | + ], | |
| 407 | + [ | |
| 408 | + 'type' => 'toggle', | |
| 409 | + 'group' => 'payment_gateways', | |
| 410 | + 'priority' => 2, | |
| 411 | + 'field_data' => [ | |
| 412 | + 'id' => 'subscrpt_require_payment_on_trial', | |
| 413 | + 'title' => __( 'Require Payment for Free Trials', 'subscription' ), | |
| 414 | + 'label' => __( 'Collect payment details at checkout for trial subscriptions', 'subscription' ), | |
| 415 | + 'description' => __( 'Collect payment details up front on free trials so renewals charge automatically.', 'subscription' ), | |
| 416 | + 'value' => '1', | |
| 417 | + 'checked' => '1' === get_option( 'subscrpt_require_payment_on_trial', '1' ), | |
| 418 | + ], | |
| 419 | + ], | |
| 420 | + ]; | |
| 365 | 421 | } |
| 366 | 422 | |
| 367 | 423 | /** |
| 368 | 424 | * Module: Switch Subscription (Illuminate/SubscriptionSwitch.php). |
| @@ -369,23 +425,100 @@ | ||
| 369 | 425 | * |
| 370 | 426 | * @return array |
| 371 | 427 | */ |
| 372 | 428 | private function switch_fields() { |
| 373 | - return array( | |
| 374 | - array( | |
| 429 | + return [ | |
| 430 | + [ | |
| 431 | + 'type' => 'heading', | |
| 432 | + 'group' => 'switching', | |
| 433 | + 'priority' => 3, | |
| 434 | + 'field_data' => [ | |
| 435 | + 'title' => __( 'Switching & Upgrades', 'subscription' ), | |
| 436 | + ], | |
| 437 | + ], | |
| 438 | + [ | |
| 375 | 439 | 'type' => 'toggle', |
| 376 | - 'group' => 'general', | |
| 440 | + 'group' => 'switching', | |
| 377 | 441 | 'priority' => 9, |
| 378 | - 'field_data' => array( | |
| 442 | + 'field_data' => [ | |
| 379 | 443 | 'id' => 'subscrpt_switch_enabled', |
| 380 | 444 | 'title' => __( 'Switch Subscription', 'subscription' ), |
| 381 | 445 | 'label' => __( 'Allow users to upgrade/downgrade their subscriptions.', 'subscription' ), |
| 382 | - 'description' => __( 'Note: Downgrading subscription is not available at the moment.', 'subscription' ), | |
| 446 | + 'description' => '', | |
| 383 | 447 | 'value' => '1', |
| 384 | 448 | 'checked' => '1' === get_option( 'subscrpt_switch_enabled', '0' ), |
| 385 | - ), | |
| 386 | - ), | |
| 387 | - ); | |
| 449 | + ], | |
| 450 | + ], | |
| 451 | + [ | |
| 452 | + 'type' => 'toggle', | |
| 453 | + 'group' => 'switching', | |
| 454 | + 'priority' => 10, | |
| 455 | + 'field_data' => [ | |
| 456 | + 'id' => 'subscrpt_downgrade_allowed', | |
| 457 | + 'title' => __( 'Downgrade Subscription', 'subscription' ), | |
| 458 | + 'label' => __( 'Allow users to downgrade their subscriptions.', 'subscription' ), | |
| 459 | + 'description' => '', | |
| 460 | + 'value' => '1', | |
| 461 | + 'checked' => '1' === get_option( 'subscrpt_downgrade_allowed', '1' ), | |
| 462 | + ], | |
| 463 | + ], | |
| 464 | + [ | |
| 465 | + 'type' => 'join', | |
| 466 | + 'group' => 'switching', | |
| 467 | + 'priority' => 11, | |
| 468 | + 'field_data' => [ | |
| 469 | + 'title' => __( 'Switch Fee', 'subscription' ), | |
| 470 | + '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' ), | |
| 471 | + 'elements' => [ | |
| 472 | + SettingsHelper::inp_element( | |
| 473 | + [ | |
| 474 | + 'id' => 'subscrpt_switch_fee_amount', | |
| 475 | + 'value' => esc_attr( get_option( 'subscrpt_switch_fee_amount', '0' ) ), | |
| 476 | + 'type' => 'number', | |
| 477 | + 'style' => 'min-width:170px;width:170px;', | |
| 478 | + 'attributes' => [ | |
| 479 | + 'min' => 0, | |
| 480 | + 'step' => '0.01', | |
| 481 | + ], | |
| 482 | + ], | |
| 483 | + true | |
| 484 | + ), | |
| 485 | + SettingsHelper::select_element( | |
| 486 | + [ | |
| 487 | + 'id' => 'subscrpt_switch_fee_type', | |
| 488 | + 'class' => 'subscrpt-switch-fee-type', | |
| 489 | + 'options' => [ | |
| 490 | + 'flat' => sprintf( | |
| 491 | + /* translators: %s: store currency symbol. */ | |
| 492 | + __( 'Flat (%s)', 'subscription' ), | |
| 493 | + get_woocommerce_currency_symbol() | |
| 494 | + ), | |
| 495 | + 'percent' => __( 'Percentage (%)', 'subscription' ), | |
| 496 | + ], | |
| 497 | + 'selected' => esc_attr( get_option( 'subscrpt_switch_fee_type', 'flat' ) ), | |
| 498 | + ], | |
| 499 | + true | |
| 500 | + ), | |
| 501 | + ], | |
| 502 | + ], | |
| 503 | + ], | |
| 504 | + [ | |
| 505 | + 'type' => 'select', | |
| 506 | + 'group' => 'switching', | |
| 507 | + 'priority' => 12, | |
| 508 | + 'field_data' => [ | |
| 509 | + 'id' => 'subscrpt_switch_fee_apply_to', | |
| 510 | + 'title' => __( 'Apply Fee To', 'subscription' ), | |
| 511 | + 'description' => __( 'Choose which switch directions the fee applies to.', 'subscription' ), | |
| 512 | + 'options' => [ | |
| 513 | + 'both' => __( 'Both upgrade and downgrade', 'subscription' ), | |
| 514 | + 'upgrade' => __( 'Upgrade only', 'subscription' ), | |
| 515 | + 'downgrade' => __( 'Downgrade only', 'subscription' ), | |
| 516 | + ], | |
| 517 | + 'selected' => esc_attr( get_option( 'subscrpt_switch_fee_apply_to', 'both' ) ), | |
| 518 | + ], | |
| 519 | + ], | |
| 520 | + ]; | |
| 388 | 521 | } |
| 389 | 522 | |
| 390 | 523 | /** |
| 391 | 524 | * Module: Role Management (Illuminate/RoleManagement.php). |
| @@ -392,30 +525,30 @@ | ||
| 392 | 525 | * |
| 393 | 526 | * @return array |
| 394 | 527 | */ |
| 395 | 528 | private function role_management_fields() { |
| 396 | - return array( | |
| 397 | - array( | |
| 529 | + return [ | |
| 530 | + [ | |
| 398 | 531 | 'type' => 'heading', |
| 399 | 532 | 'group' => 'role_based_settings', |
| 400 | - 'priority' => 6, | |
| 401 | - 'field_data' => array( | |
| 533 | + 'priority' => 7, | |
| 534 | + 'field_data' => [ | |
| 402 | 535 | 'title' => __( 'Role-Based Settings', 'subscription' ), |
| 403 | - ), | |
| 404 | - ), | |
| 405 | - array( | |
| 536 | + ], | |
| 537 | + ], | |
| 538 | + [ | |
| 406 | 539 | 'type' => 'toggle', |
| 407 | 540 | 'group' => 'role_based_settings', |
| 408 | 541 | 'priority' => 1, |
| 409 | - 'field_data' => array( | |
| 542 | + 'field_data' => [ | |
| 410 | 543 | 'id' => 'subscrpt_role_based_access', |
| 411 | 544 | 'title' => __( 'Enable Role Based Access', 'subscription' ), |
| 412 | 545 | 'description' => __( 'Show/Hide products based on user roles.', 'subscription' ), |
| 413 | 546 | 'value' => '1', |
| 414 | 547 | 'checked' => '1' === get_option( 'subscrpt_role_based_access', '1' ), |
| 415 | - ), | |
| 416 | - ), | |
| 417 | - ); | |
| 548 | + ], | |
| 549 | + ], | |
| 550 | + ]; | |
| 418 | 551 | } |
| 419 | 552 | |
| 420 | 553 | /** |
| 421 | 554 | * Module: Live QR (Illuminate/LiveQR/LiveQR.php) — quick details QR. |
| @@ -422,66 +555,66 @@ | ||
| 422 | 555 | * |
| 423 | 556 | * @return array |
| 424 | 557 | */ |
| 425 | 558 | private function live_qr_fields() { |
| 426 | - return array( | |
| 427 | - array( | |
| 559 | + return [ | |
| 560 | + [ | |
| 428 | 561 | 'type' => 'heading', |
| 429 | 562 | 'group' => 'live_qr_settings', |
| 430 | - 'priority' => 5, | |
| 431 | - 'field_data' => array( | |
| 563 | + 'priority' => 8, | |
| 564 | + 'field_data' => [ | |
| 432 | 565 | 'title' => __( 'Quick Details QR Settings', 'subscription' ), |
| 433 | - ), | |
| 434 | - ), | |
| 435 | - array( | |
| 566 | + ], | |
| 567 | + ], | |
| 568 | + [ | |
| 436 | 569 | 'type' => 'toggle', |
| 437 | 570 | 'group' => 'live_qr_settings', |
| 438 | 571 | 'priority' => 1, |
| 439 | - 'field_data' => array( | |
| 572 | + 'field_data' => [ | |
| 440 | 573 | 'id' => 'subscrpt_live_qr_active', |
| 441 | 574 | 'title' => __( 'Enable Quick Details QR', 'subscription' ), |
| 442 | 575 | 'label' => '', |
| 443 | 576 | 'value' => '1', |
| 444 | 577 | 'checked' => '1' === get_option( 'subscrpt_live_qr_active', '1' ), |
| 445 | - ), | |
| 446 | - ), | |
| 447 | - array( | |
| 578 | + ], | |
| 579 | + ], | |
| 580 | + [ | |
| 448 | 581 | 'type' => 'toggle', |
| 449 | 582 | 'group' => 'live_qr_settings', |
| 450 | 583 | 'priority' => 2, |
| 451 | - 'field_data' => array( | |
| 584 | + 'field_data' => [ | |
| 452 | 585 | 'id' => 'subscrpt_live_qr_show_product', |
| 453 | 586 | 'title' => __( 'Product Details', 'subscription' ), |
| 454 | 587 | 'label' => __( 'Show product details in the subscription quick view', 'subscription' ), |
| 455 | 588 | 'value' => '1', |
| 456 | 589 | 'checked' => '1' === get_option( 'subscrpt_live_qr_show_product', '1' ), |
| 457 | - ), | |
| 458 | - ), | |
| 459 | - array( | |
| 590 | + ], | |
| 591 | + ], | |
| 592 | + [ | |
| 460 | 593 | 'type' => 'toggle', |
| 461 | 594 | 'group' => 'live_qr_settings', |
| 462 | 595 | 'priority' => 3, |
| 463 | - 'field_data' => array( | |
| 596 | + 'field_data' => [ | |
| 464 | 597 | 'id' => 'subscrpt_live_qr_show_billing', |
| 465 | 598 | 'title' => __( 'Billing Details', 'subscription' ), |
| 466 | 599 | 'label' => __( 'Show billing details in the subscription quick view', 'subscription' ), |
| 467 | 600 | 'value' => '1', |
| 468 | 601 | 'checked' => '1' === get_option( 'subscrpt_live_qr_show_billing', '0' ), |
| 469 | - ), | |
| 470 | - ), | |
| 471 | - array( | |
| 602 | + ], | |
| 603 | + ], | |
| 604 | + [ | |
| 472 | 605 | 'type' => 'toggle', |
| 473 | 606 | 'group' => 'live_qr_settings', |
| 474 | 607 | 'priority' => 4, |
| 475 | - 'field_data' => array( | |
| 608 | + 'field_data' => [ | |
| 476 | 609 | 'id' => 'subscrpt_live_qr_show_timeline', |
| 477 | 610 | 'title' => __( 'Timeline', 'subscription' ), |
| 478 | 611 | 'label' => __( 'Show subscription timeline in the subscription quick view', 'subscription' ), |
| 479 | 612 | 'value' => '1', |
| 480 | 613 | 'checked' => '1' === get_option( 'subscrpt_live_qr_show_timeline', '0' ), |
| 481 | - ), | |
| 482 | - ), | |
| 483 | - ); | |
| 614 | + ], | |
| 615 | + ], | |
| 616 | + ]; | |
| 484 | 617 | } |
| 485 | 618 | |
| 486 | 619 | /** |
| 487 | 620 | * Module: Payment Gateways (Illuminate/Gateways/PaymentGateways.php). |
| @@ -488,9 +621,9 @@ | ||
| 488 | 621 | * |
| 489 | 622 | * @return array |
| 490 | 623 | */ |
| 491 | 624 | private function payment_gateway_fields() { |
| 492 | - $gateway_options = array(); | |
| 625 | + $gateway_options = []; | |
| 493 | 626 | if ( function_exists( 'WC' ) && WC()->payment_gateways ) { |
| 494 | 627 | foreach ( WC()->payment_gateways->get_available_payment_gateways() as $gateway_id => $gateway ) { |
| 495 | 628 | $gateway_options[ $gateway_id ] = $gateway->get_title(); |
| 496 | 629 | } |
| @@ -495,28 +628,28 @@ | ||
| 495 | 628 | $gateway_options[ $gateway_id ] = $gateway->get_title(); |
| 496 | 629 | } |
| 497 | 630 | } |
| 498 | 631 | |
| 499 | - return array( | |
| 500 | - array( | |
| 632 | + return [ | |
| 633 | + [ | |
| 501 | 634 | 'type' => 'heading', |
| 502 | 635 | 'group' => 'payment_gateways', |
| 503 | - 'priority' => 0.1, | |
| 504 | - 'field_data' => array( | |
| 636 | + 'priority' => 1, | |
| 637 | + 'field_data' => [ | |
| 505 | 638 | 'title' => __( 'Payment Gateway Settings', 'subscription' ), |
| 506 | - ), | |
| 507 | - ), | |
| 508 | - array( | |
| 639 | + ], | |
| 640 | + ], | |
| 641 | + [ | |
| 509 | 642 | 'type' => 'multi_select', |
| 510 | 643 | 'group' => 'payment_gateways', |
| 511 | 644 | 'priority' => 2, |
| 512 | - 'field_data' => array( | |
| 645 | + 'field_data' => [ | |
| 513 | 646 | 'id' => 'hidden_payment_gateways', |
| 514 | 647 | 'title' => __( 'Hide Payment Gateways', 'subscription' ), |
| 515 | 648 | 'description' => __( 'Select payment gateways to hide for subscription products. (keep empty for not hiding any)', 'subscription' ), |
| 516 | 649 | 'options' => $gateway_options, |
| 517 | - 'selected' => get_option( 'hidden_payment_gateways', array() ), | |
| 518 | - ), | |
| 519 | - ), | |
| 520 | - ); | |
| 650 | + 'selected' => get_option( 'hidden_payment_gateways', [] ), | |
| 651 | + ], | |
| 652 | + ], | |
| 653 | + ]; | |
| 521 | 654 | } |
| 522 | 655 | } |