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 | subscription.php +112 -47 1.4.02.0.0 View file →
@@ -1,26 +1,40 @@
1 1 <?php
2 -/*
3 -Plugin Name: Subscriptions for WooCommerce
4 -Plugin URI: https://wordpress.org/plugins/subscription
5 -Description: Enable WooCommerce Subscriptions and Start Recurring Revenue in Minutes.
6 -Plugin URI: https://wpsubscription.co/
2 +/**
3 + * Plugin Name: Subscriptions for WooCommerce with Stripe Recurring Payments
4 + * Plugin URI: https://wpsubscription.co/
5 + * Description: WPSubscription allows WooCommerce to enable recurring payments, subscriptions, and auto-renewals for digital and physical products. Supports Stripe, PayPal, Paddle, and more.
6 + *
7 + * Version: 2.0.0
8 + *
9 + * Author: ConversWP
10 + * Author URI: https://wpsubscription.co/
11 + *
12 + * Text Domain: subscription
13 + * Domain Path: /languages
14 + *
15 + * Requires PHP: 7.4
16 + *
17 + * Requires at least: 6.2
18 + * Tested up to: 7.1
19 + *
20 + * WC requires at least: 6.0
21 + * WC tested up to: 10.3
22 + *
23 + * License: GPLv2 or later
24 + * License URI: https://www.gnu.org/licenses/gpl-2.0.html
25 + *
26 + * @package Subscription
27 + */
7 28
8 -Author: converswp
9 -Author URI: https://wpsubscription.co/
10 -
11 -Version: 1.4.0
12 -License: GPLv2
13 -License URI: https://www.gnu.org/licenses/gpl-2.0.html
14 -Text Domain: wp_subscription
15 -Domain Path: /languages
16 -*/
17 -
18 29 // don't call the file directly.
19 30 if ( ! defined( 'ABSPATH' ) ) {
20 31 exit;
21 32 }
22 33
34 +use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
35 +use SpringDevs\Subscription\Illuminate\Gateways\Paypal\Paypal_Blocks_Integration;
36 +
23 37 require_once __DIR__ . '/vendor/autoload.php';
24 38
25 39 /**
26 40 * Sdevs_Subscription class
@@ -34,9 +48,9 @@
34 48 * Plugin version
35 49 *
36 50 * @var string
37 51 */
38 - const version = '1.3.2';
52 + const VERSION = '2.0.0';
39 53
40 54 /**
41 55 * Holds various class instances
42 56 *
@@ -108,15 +122,19 @@
108 122 *
109 123 * @return void
110 124 */
111 125 public function define_constants() {
112 - define( 'WP_SUBSCRIPTION_VERSION', self::version );
113 - define( 'WP_SUBSCRIPTION_FILE', __FILE__ );
114 - define( 'WP_SUBSCRIPTION_PATH', dirname( WP_SUBSCRIPTION_FILE ) );
115 - define( 'WP_SUBSCRIPTION_INCLUDES', WP_SUBSCRIPTION_PATH . '/includes' );
116 - define( 'WP_SUBSCRIPTION_TEMPLATES', WP_SUBSCRIPTION_PATH . '/templates/' );
117 - define( 'WP_SUBSCRIPTION_URL', plugins_url( '', WP_SUBSCRIPTION_FILE ) );
118 - define( 'WP_SUBSCRIPTION_ASSETS', WP_SUBSCRIPTION_URL . '/assets' );
126 + define( 'SUBSCRPT_VERSION', self::VERSION );
127 + define( 'SUBSCRPT_FILE', __FILE__ );
128 + define( 'SUBSCRPT_PATH', dirname( SUBSCRPT_FILE ) );
129 + define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
130 + define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
131 + define( 'SUBSCRPT_URL', plugins_url( '', SUBSCRPT_FILE ) );
132 + define( 'SUBSCRPT_ASSETS', SUBSCRPT_URL . '/assets' );
133 +
134 + // Load legacy constant aliases (WP_SUBSCRIPTION_* → SUBSCRPT_*) for
135 + // backwards compatibility with subscription-pro and third-party code.
136 + require_once SUBSCRPT_INCLUDES . '/LegacyCompat.php';
119 137 }
120 138
121 139 /**
122 140 * Load the plugin after all plugins are loaded
@@ -141,9 +159,10 @@
141 159 *
142 160 * Nothing being called here yet.
143 161 */
144 162 public function deactivate() {
145 - wp_clear_scheduled_hook( 'subscrpt_daily_cron' );
163 + wp_clear_scheduled_hook( 'subscrpt_hourly_cron' );
164 + wp_clear_scheduled_hook( 'subscrpt_daily_cron' ); // legacy cleanup for sites migrating from old hook name
146 165 }
147 166
148 167 /**
149 168 * Include the required files
@@ -150,8 +169,12 @@
150 169 *
151 170 * @return void
152 171 */
153 172 public function includes() {
173 + // Include functions file first to ensure global functions are available
174 + require_once SUBSCRPT_INCLUDES . '/functions.php';
175 + require_once SUBSCRPT_INCLUDES . '/Admin/AdminComponents.php';
176 +
154 177 if ( $this->is_request( 'admin' ) ) {
155 178 $this->container['admin'] = new SpringDevs\Subscription\Admin();
156 179 }
157 180
@@ -170,31 +193,41 @@
170 193 public function init_hooks() {
171 194 add_action( 'init', array( $this, 'init_classes' ) );
172 195 add_action( 'init', array( $this, 'localization_setup' ) );
173 196 add_action( 'init', array( $this, 'run_update' ) );
174 -
197 +
175 198 // HPOS Compatibility: Declare support for custom order tables
176 - add_action('before_woocommerce_init', function() {
177 - if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
178 - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
199 + add_action(
200 + 'before_woocommerce_init',
201 + function () {
202 + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
203 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
204 + }
179 205 }
180 - });
206 + );
181 207
182 208 // HPOS Compatibility: Register subscription post type with HPOS support
183 - add_action('init', function() {
184 - register_post_type('subscrpt_order', array(
185 - 'hpos' => true,
186 - 'public' => false,
187 - 'show_ui' => true,
188 - 'show_in_menu' => false,
189 - 'supports' => array('title'),
190 - 'capability_type' => 'post',
191 - 'capabilities' => array(
192 - 'create_posts' => false,
193 - ),
194 - 'map_meta_cap' => true,
195 - ));
196 - }, 0);
209 + add_action(
210 + 'init',
211 + function () {
212 + register_post_type(
213 + 'subscrpt_order',
214 + array(
215 + 'hpos' => true,
216 + 'public' => false,
217 + 'show_ui' => true,
218 + 'show_in_menu' => false,
219 + 'supports' => array( 'title' ),
220 + 'capability_type' => 'post',
221 + 'capabilities' => array(
222 + 'create_posts' => false,
223 + ),
224 + 'map_meta_cap' => true,
225 + )
226 + );
227 + },
228 + 0
229 + );
197 230 }
198 231
199 232 /**
200 233 * Need to do some actions after update plugin
@@ -212,12 +245,13 @@
212 245 * @return void
213 246 */
214 247 public function init_classes() {
215 248 if ( $this->is_request( 'ajax' ) ) {
216 - $this->container['ajax'] = new SpringDevs\Subscription\Ajax();
249 + $this->container['ajax'] = new SpringDevs\Subscription\Ajax();
250 + $this->container['onboarding_ajax'] = new SpringDevs\Subscription\Admin\OnboardingAjax();
217 251 }
218 252
219 - $this->container['api'] = new SpringDevs\Subscription\Api();
253 + $this->container['api'] = new SpringDevs\Subscription\API();
220 254 $this->container['assets'] = new SpringDevs\Subscription\Assets();
221 255 }
222 256
223 257 /**
@@ -222,12 +256,13 @@
222 256
223 257 /**
224 258 * Initialize plugin for localization
225 259 *
226 - * @uses load_plugin_textdomain()
260 + * Note: WordPress automatically loads translations for plugins hosted on WordPress.org
261 + * since version 4.6, so manual loading is not required.
227 262 */
228 263 public function localization_setup() {
229 - load_plugin_textdomain( 'wp_subscription', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
264 + // WordPress auto-loads translations for plugins hosted on WordPress.org since v4.6.
230 265 }
231 266
232 267 /**
233 268 * What type of request is this?
@@ -254,8 +289,38 @@
254 289 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
255 290 }
256 291 }
257 292 } // Sdevs_Wc_Subscription
293 +
294 +// Add Paypal Gateway Blocks.
295 +if ( ! function_exists( 'subscrpt_register_paypal_block' ) ) {
296 + /**
297 + * Register the PayPal block for WooCommerce Blocks.
298 + */
299 + function subscrpt_register_paypal_block() {
300 + // Check if the required class exists.
301 + if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
302 + return;
303 + }
304 +
305 + // Hook the registration function to the 'woocommerce_blocks_payment_method_type_registration' action.
306 + add_action(
307 + 'woocommerce_blocks_payment_method_type_registration',
308 + function ( PaymentMethodRegistry $payment_method_registry ) {
309 + $payment_method_registry->register( new Paypal_Blocks_Integration() );
310 + }
311 + );
312 + }
313 +
314 + // Register PayPal integration only if WordPress functions are available
315 + if ( function_exists( 'get_option' ) ) {
316 + // Is PayPal integration enabled?
317 + $is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' );
318 + if ( $is_paypal_integration_enabled ) {
319 + add_action( 'woocommerce_blocks_loaded', 'subscrpt_register_paypal_block' );
320 + }
321 + }
322 +}
258 323
259 324 /**
260 325 * Initialize the main plugin
261 326 *