PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.1.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.1.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
← All changes | includes/Admin/Settings.php +6 -70 2.3.0 → 2.1.0 View file →
@@ -1,10 +1,8 @@
1 1 <?php
2 2
3 3 namespace SpringDevs\Subscription\Admin;
4 4
5 -use SpringDevs\Subscription\Ajax;
6 -
7 5 /**
8 6 * Class Settings
9 7 *
10 8 * @package SpringDevs\Subscription\Admin
@@ -26,9 +24,8 @@
26 24
27 25 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
28 26 add_action( 'admin_init', array( $this, 'register_settings' ) );
29 27 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_wc_admin_styles' ) );
30 - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_installer_script' ) );
31 28 }
32 29
33 30 /**
34 31 * Register submenu on `Subscriptions` menu.
@@ -104,22 +101,14 @@
104 101 'field_data' => [
105 102 'id' => 'wp_subscription_stripe_auto_renew',
106 103 'title' => __( 'Stripe Auto Renewal', 'subscription' ),
107 104 'label' => __( 'Accept Stripe Auto Renewals', 'subscription' ),
108 - 'description' => class_exists( 'WC_Stripe' )
109 - ? sprintf(
110 - /* translators: 1: opening plugin link tag, 2: closing link tag, 3: opening settings link tag */
111 - __( '&#10003; %1$sWooCommerce Stripe Payment Gateway%2$s is active. %3$sConfigure%2$s', 'subscription' ),
112 - '<a href="https://wordpress.org/plugins/woocommerce-gateway-stripe/" target="_blank">',
113 - '</a>',
114 - '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' ) ) . '">'
115 - )
116 - : sprintf(
117 - /* translators: HTML tags */
118 - __( '%1$s WooCommerce Stripe Payment Gateway %2$s plugin is required!', 'subscription' ),
119 - '<a href="https://wordpress.org/plugins/woocommerce-gateway-stripe/" target="_blank">',
120 - '</a>'
121 - ) . $this->get_stripe_plugin_action(),
105 + 'description' => sprintf(
106 + /* translators: HTML tags */
107 + __( '%1$s WooCommerce Stripe Payment Gateway %2$s plugin is required!', 'subscription' ),
108 + '<a href="https://wordpress.org/plugins/woocommerce-gateway-stripe/" target="_blank">',
109 + '</a>'
110 + ),
122 111 'value' => '1',
123 112 'checked' => '1' === get_option( 'wp_subscription_stripe_auto_renew', '1' ),
124 113 ],
125 114 ],
@@ -169,61 +158,8 @@
169 158 $settings_fields = apply_filters( 'process_subscrpt_settings_fields', $settings_fields );
170 159
171 160 // Set the settings fields.
172 161 $this->settings_fields = $settings_fields;
173 - }
174 -
175 - /**
176 - * Install / Activate link for the Stripe gateway plugin.
177 - *
178 - * Rendered inside a field description, which goes through `wp_kses_post()`,
179 - * so the link carries data attributes rather than an inline handler;
180 - * `integration_settings.js` picks it up.
181 - *
182 - * @return string Link HTML, or an empty string when the user cannot act on it.
183 - */
184 - private function get_stripe_plugin_action() {
185 - $slug = 'woocommerce-gateway-stripe';
186 - $installed = '' !== Ajax::get_installed_plugin_file( $slug );
187 -
188 - if ( $installed && current_user_can( 'activate_plugins' ) ) {
189 - $label = __( 'Activate', 'subscription' );
190 - $busy_label = __( 'Activating…', 'subscription' );
191 - } elseif ( ! $installed && current_user_can( 'install_plugins' ) ) {
192 - $label = __( 'Install & Activate', 'subscription' );
193 - $busy_label = __( 'Installing…', 'subscription' );
194 - } else {
195 - return '';
196 - }
197 -
198 - return sprintf(
199 - ' <a href="#" data-subscrpt-install-plugin="%1$s" data-busy-label="%2$s">%3$s</a>',
200 - esc_attr( $slug ),
201 - esc_attr( $busy_label ),
202 - esc_html( $label )
203 - );
204 - }
205 -
206 - /**
207 - * Enqueue the plugin installer on the settings page.
208 - *
209 - * @param string $hook The current admin page hook.
210 - */
211 - public function enqueue_installer_script( $hook ) {
212 - if ( false === strpos( $hook, 'wp-subscription-settings' ) ) {
213 - return;
214 - }
215 -
216 - wp_enqueue_script( 'subscrpt-integrations', SUBSCRPT_ASSETS . '/js/integration_settings.js', [], SUBSCRPT_VERSION, true );
217 -
218 - wp_localize_script(
219 - 'subscrpt-integrations',
220 - 'subscrptIntegrations',
221 - array(
222 - 'nonce' => wp_create_nonce( 'subscrpt_integration_install_nonce' ),
223 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
224 - )
225 - );
226 162 }
227 163
228 164 /**
229 165 * Register settings options.