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