PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.0.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.0.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 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
← All changes | includes/Admin/views/settings.php +132 -113 1.3.22.0.0 View file →
@@ -1,122 +1,141 @@
1 -<div class="wrap">
2 - <?php settings_errors(); ?>
3 - <h1><?php esc_html_e( 'Subscription Settings', 'sdevs_subscrpt' ); ?></h1>
4 - <p><?php esc_html_e( 'These settings can effect Subscription', 'sdevs_subscrpt' ); ?></p>
5 - <form method="post" action="options.php">
6 - <?php settings_fields( 'subscrpt_settings' ); ?>
7 - <?php do_settings_sections( 'subscrpt_settings' ); ?>
8 - <table class="form-table">
9 - <tbody>
10 - <tr>
11 - <th scope="row">
12 - <label for="subscrpt_renewal_process">
13 - <?php esc_html_e( 'Renewal Process', 'sdevs_subscrpt' ); ?>
14 - </label>
15 - </th>
16 - <td>
17 - <select name="subscrpt_renewal_process" id="subscrpt_renewal_process">
18 - <option value="auto">Automatic</option>
19 - <option value="manual"
20 - <?php
21 - if ( 'manual' === get_option( 'subscrpt_renewal_process', 'auto' ) ) {
22 - echo esc_attr( 'selected' );
23 - }
24 - ?>
25 - >Manual</option>
26 - </select>
27 - <p class="description"><?php esc_html_e( 'How renewal process will be done after Subscription Expired !!', 'sdevs_subscrpt' ); ?></p>
28 - </td>
29 - </tr>
30 - <tr id="sdevs_renewal_cart_tr">
31 - <th scope="row">
32 - <label for="subscrpt_manual_renew_cart_notice">
33 - <?php esc_html_e( 'Renewal Cart Notice', 'sdevs_subscrpt' ); ?>
34 - </label>
35 - </th>
36 - <td>
37 - <input id="subscrpt_manual_renew_cart_notice" name="subscrpt_manual_renew_cart_notice" class="large-text" value="<?php echo wp_kses_post( get_option( 'subscrpt_manual_renew_cart_notice' ) ); ?>" type="text"/>
38 - <p class="description"><?php echo wp_kses_post( 'Display Notice when Renewal Subscription product add to cart !! It\'s only available for <b>Manual Renewal Process</b>.', 'sdevs_subscrpt' ); ?></p>
39 - </td>
40 - </tr>
41 - <tr>
42 - <th scope="row">
43 - <label for="subscrpt_active_role">
44 - <?php esc_html_e( 'Subscriber Default Role', 'sdevs_subscrpt' ); ?>
45 - </label>
46 - </th>
47 - <td>
48 - <select name="subscrpt_active_role" id="subscrpt_active_role">
49 - <?php wp_dropdown_roles( get_option( 'subscrpt_active_role', 'subscriber' ) ); ?>
50 - </select>
51 - <p class="description"><?php esc_html_e( 'When a subscription is activated, either manually or after a successful purchase, new users will be assigned this role.', 'sdevs_subscrpt' ); ?></p>
52 - </td>
53 - </tr>
54 - <tr>
55 - <th scope="row">
56 - <label for="subscrpt_unactive_role">
57 - <?php esc_html_e( 'Subscriber Unactive Role', 'sdevs_subscrpt' ); ?>
58 - </label>
59 - </th>
60 - <td>
61 - <select name="subscrpt_unactive_role" id="subscrpt_unactive_role">
62 - <?php wp_dropdown_roles( get_option( 'subscrpt_unactive_role', 'customer' ) ); ?>
63 - </select>
64 - <p class="description"><?php esc_html_e( "If a subscriber's subscription is manually cancelled or expires, will be assigned this role.", 'sdevs_subscrpt' ); ?></p>
65 - </td>
66 - </tr>
67 - <tr id="subscrpt_stripe_auto_renew_tr" valign="top">
68 - <th scope="row" class="titledesc"><?php echo esc_html_e( 'Stripe Auto Renewal', 'sdevs_subscrpt' ); ?></th>
69 - <td class="forminp forminp-checkbox">
70 - <fieldset>
71 - <legend class="screen-reader-text"><span><?php echo esc_html_e( 'Accept Stripe Auto Renewals', 'sdevs_subscrpt' ); ?></span></legend>
72 - <label for="subscrpt_stripe_auto_renew">
73 - <input name="subscrpt_stripe_auto_renew" id="subscrpt_stripe_auto_renew" type="checkbox" value="1"
1 +<?php
2 +/**
3 + * Subscription settings admin view.
4 + *
5 + * One form, every panel rendered, one panel visible. The form posts to
6 + * `options.php`, which saves whatever it is given — so a panel that is not
7 + * rendered is a panel whose settings do not save. Hiding is therefore CSS, not
8 + * a conditional, and every one of the fields below submits on every save
9 + * whichever section happens to be open.
10 + *
11 + * One level of navigation: the rail picks a section and the section's panel
12 + * stacks whatever groups belong to it. A section holding a single group drops
13 + * that group's heading, because the rail item beside it already says the same
14 + * word.
15 + *
16 + * @package SpringDevs\Subscription\Admin
17 + *
18 + * @var array $settings_fields Grouped and sorted settings fields.
19 + * @var string $active_cat Section currently open.
20 + * @var array $category_groups Section key => ordered group keys (empty ones dropped).
21 + */
22 +
23 +// Exit if accessed directly.
24 +if ( ! defined( 'ABSPATH' ) ) {
25 + exit;
26 +}
27 +
28 +use SpringDevs\Subscription\Admin\SettingsHelper;
29 +
30 +wp_enqueue_style( 'wp-subscription-admin-settings', SUBSCRPT_ASSETS . '/css/admin-settings.css', [], SUBSCRPT_VERSION );
31 +wp_enqueue_script( 'wp-subscription-admin-settings', SUBSCRPT_ASSETS . '/js/admin-settings.js', [ 'jquery' ], SUBSCRPT_VERSION, true );
32 +
33 +$subscrpt_settings_base = admin_url( 'admin.php?page=wp-subscription-settings' );
34 +?>
35 +<div class="wp-subscription-admin-content list-page">
36 +
37 + <form method="post" action="options.php" class="subscrpt-settings" data-subscrpt-settings>
38 + <?php settings_fields( 'wp_subscription_settings' ); ?>
39 + <?php do_settings_sections( 'wp_subscription_settings' ); ?>
40 +
74 41 <?php
75 - if ( '1' === get_option( 'subscrpt_stripe_auto_renew', '1' ) ) {
76 - echo 'checked';
77 - }
78 - ?>
79 - > <?php echo esc_html_e( 'Accept Stripe Auto Renewals', 'sdevs_subscrpt' ); ?> </label>
80 - <p class="description">
81 - <?php
82 - echo wp_kses_post(
83 - sprintf(
84 - /* translators: HTML tags */
85 - __(
86 - '%1$s WooCommerce Stripe Payment Gateway %2$s plugin is required !',
87 - 'sdevs_subscrpt'
42 + // Shared page header (title + description + dashed rule) with the Save
43 + // button pinned to the right of the title row.
44 + wpsubs_render_page_header(
45 + array(
46 + 'title' => __( 'Settings', 'subscription' ),
47 + 'description' => __( 'Configure how subscriptions renew, charge and behave for your customers.', 'subscription' ),
48 + 'actions' => sprintf(
49 + '<button type="submit" class="wpsubs-btn wpsubs-btn--primary subscrpt-settings__save">%s</button>',
50 + esc_html__( 'Save changes', 'subscription' )
88 51 ),
89 - '<a href="https://wordpress.org/plugins/woocommerce-gateway-stripe/" target="_blank">',
90 - '</a>'
91 52 )
92 53 );
93 54 ?>
94 - </p>
95 - </fieldset>
96 - </td>
97 - </tr>
98 - <tr id="subscrpt_auto_renewal_toggle_tr" valign="top">
99 - <th scope="row" class="titledesc"><?php echo esc_html_e( 'Auto Renewal Toggle', 'sdevs_subscrpt' ); ?></th>
100 - <td class="forminp forminp-checkbox">
101 - <fieldset>
102 - <legend class="screen-reader-text"><span><?php echo esc_html_e( 'Auto Renewal Toggle', 'sdevs_subscrpt' ); ?></span></legend>
103 - <label for="subscrpt_auto_renewal_toggle">
104 - <input name="subscrpt_auto_renewal_toggle" id="subscrpt_auto_renewal_toggle" type="checkbox" value="1"
105 - <?php
106 - if ( '1' === get_option( 'subscrpt_auto_renewal_toggle', '1' ) ) {
107 - echo 'checked';
108 - }
109 - ?>
110 - > <?php echo esc_html_e( 'Display the auto renewal toggle', 'sdevs_subscrpt' ); ?> </label>
111 - <p class="description"><?php echo esc_html_e( 'Allow customers to turn on and off automatic renewals from their Subscription details page.', 'sdevs_subscrpt' ); ?></p>
112 - </fieldset>
113 - </td>
114 - </tr>
115 - <?php do_action( 'subscrpt_setting_fields' ); ?>
116 - </tbody>
117 - </table>
118 55
119 - <?php submit_button(); ?>
56 + <div class="subscrpt-settings__layout">
120 57
58 + <aside class="subscrpt-settings__sidebar">
59 + <nav class="wpsubs-vnav" aria-label="<?php esc_attr_e( 'Settings sections', 'subscription' ); ?>">
60 + <?php $subscrpt_all_active = 'all' === $active_cat; ?>
61 + <a
62 + class="wpsubs-vnav__item<?php echo $subscrpt_all_active ? ' is-active' : ''; ?>"
63 + href="<?php echo esc_url( add_query_arg( 'cat', 'all', $subscrpt_settings_base ) ); ?>"
64 + data-subscrpt-cat="all"
65 + aria-current="<?php echo $subscrpt_all_active ? 'page' : 'false'; ?>"
66 + >
67 + <span class="wpsubs-vnav__label"><?php esc_html_e( 'All Settings', 'subscription' ); ?></span>
68 + </a>
69 + <?php
70 + $subscrpt_cat_labels = SettingsHelper::categories();
71 + foreach ( $category_groups as $subscrpt_cat_id => $subscrpt_cat_group_ids ) :
72 + $subscrpt_cat_active = $subscrpt_cat_id === $active_cat;
73 + ?>
74 + <a
75 + class="wpsubs-vnav__item<?php echo $subscrpt_cat_active ? ' is-active' : ''; ?>"
76 + href="<?php echo esc_url( add_query_arg( 'cat', $subscrpt_cat_id, $subscrpt_settings_base ) ); ?>"
77 + data-subscrpt-cat="<?php echo esc_attr( $subscrpt_cat_id ); ?>"
78 + aria-current="<?php echo $subscrpt_cat_active ? 'page' : 'false'; ?>"
79 + >
80 + <span class="wpsubs-vnav__label"><?php echo esc_html( $subscrpt_cat_labels[ $subscrpt_cat_id ] ?? $subscrpt_cat_id ); ?></span>
81 + <?php if ( SettingsHelper::category_is_pro_locked( $subscrpt_cat_group_ids, $settings_fields ) ) : ?>
82 + <?php echo wp_kses_post( SettingsHelper::pro_badge_html() ); ?>
83 + <?php endif; ?>
84 + </a>
85 + <?php endforeach; ?>
86 + </nav>
87 + </aside>
88 +
89 + <div class="subscrpt-settings__content">
90 +
91 + <div class="subscrpt-settings__panels">
92 + <?php
93 + // One card per settings group, so groups stay visually separate
94 + // instead of running together in a single section card. The rail
95 + // shows a group's whole section; "All Settings" shows every card.
96 + foreach ( $category_groups as $subscrpt_cat_id => $subscrpt_cat_group_ids ) :
97 + $subscrpt_cat_open = 'all' === $active_cat || $subscrpt_cat_id === $active_cat;
98 + foreach ( $subscrpt_cat_group_ids as $subscrpt_group_id ) :
99 + $subscrpt_group = $settings_fields[ $subscrpt_group_id ] ?? array();
100 + $subscrpt_fields = array_values( $subscrpt_group['fields'] ?? array() );
101 + $subscrpt_count = count( $subscrpt_fields );
102 + if ( 0 === $subscrpt_count ) {
103 + continue;
104 + }
105 + $subscrpt_label = SettingsHelper::group_label( $subscrpt_group_id, $subscrpt_group );
106 + ?>
107 + <section
108 + class="subscrpt-settings__panel wpsubs-table-card"
109 + id="subscrpt-panel-<?php echo esc_attr( $subscrpt_group_id ); ?>"
110 + role="region"
111 + aria-label="<?php echo esc_attr( $subscrpt_label ); ?>"
112 + data-subscrpt-panel="<?php echo esc_attr( $subscrpt_group_id ); ?>"
113 + data-subscrpt-cat="<?php echo esc_attr( $subscrpt_cat_id ); ?>"
114 + <?php echo $subscrpt_cat_open ? '' : 'hidden'; ?>
115 + >
116 + <?php foreach ( $subscrpt_fields as $subscrpt_idx => $subscrpt_field ) : ?>
117 + <?php
118 + $subscrpt_type = $subscrpt_field['type'] ?? 'input';
119 + SettingsHelper::render_settings_field( $subscrpt_type, $subscrpt_field['field_data'] ?? array() );
120 +
121 + // No rule before a heading — the heading is itself the break.
122 + $subscrpt_next = $subscrpt_fields[ $subscrpt_idx + 1 ] ?? null;
123 + $subscrpt_rule = 'heading' !== $subscrpt_type
124 + && $subscrpt_idx + 1 < $subscrpt_count
125 + && 'heading' !== ( $subscrpt_next['type'] ?? '' );
126 + ?>
127 + <?php if ( $subscrpt_rule ) : ?>
128 + <div class="subscrpt-settings__rule"></div>
129 + <?php endif; ?>
130 + <?php endforeach; ?>
131 + </section>
132 + <?php endforeach; ?>
133 + <?php endforeach; ?>
134 + </div>
135 +
136 + </div>
137 +
138 + </div>
121 139 </form>
140 +
122 141 </div>