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 +110 -23 1.3.12.0.0 View file →
@@ -1,27 +1,40 @@
1 1 <?php
2 -/*
3 -Plugin Name: Subscription 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: shamsbd71
9 -Author URI: https://wpsubscription.co/
10 -
11 -Version: 1.3.1
12 -Requires Plugins: woocommerce
13 -License: GPLv2
14 -License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 -Text Domain: sdevs_subscrpt
16 -Domain Path: /languages
17 -*/
18 -
19 29 // don't call the file directly.
20 30 if ( ! defined( 'ABSPATH' ) ) {
21 31 exit;
22 32 }
23 33
34 +use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
35 +use SpringDevs\Subscription\Illuminate\Gateways\Paypal\Paypal_Blocks_Integration;
36 +
24 37 require_once __DIR__ . '/vendor/autoload.php';
25 38
26 39 /**
27 40 * Sdevs_Subscription class
@@ -35,9 +48,9 @@
35 48 * Plugin version
36 49 *
37 50 * @var string
38 51 */
39 - const version = '1.3.1';
52 + const VERSION = '2.0.0';
40 53
41 54 /**
42 55 * Holds various class instances
43 56 *
@@ -109,9 +122,9 @@
109 122 *
110 123 * @return void
111 124 */
112 125 public function define_constants() {
113 - define( 'SUBSCRPT_VERSION', self::version );
126 + define( 'SUBSCRPT_VERSION', self::VERSION );
114 127 define( 'SUBSCRPT_FILE', __FILE__ );
115 128 define( 'SUBSCRPT_PATH', dirname( SUBSCRPT_FILE ) );
116 129 define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
117 130 define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
@@ -116,8 +129,12 @@
116 129 define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
117 130 define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
118 131 define( 'SUBSCRPT_URL', plugins_url( '', SUBSCRPT_FILE ) );
119 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';
120 137 }
121 138
122 139 /**
123 140 * Load the plugin after all plugins are loaded
@@ -142,9 +159,10 @@
142 159 *
143 160 * Nothing being called here yet.
144 161 */
145 162 public function deactivate() {
146 - 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
147 165 }
148 166
149 167 /**
150 168 * Include the required files
@@ -151,8 +169,12 @@
151 169 *
152 170 * @return void
153 171 */
154 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 +
155 177 if ( $this->is_request( 'admin' ) ) {
156 178 $this->container['admin'] = new SpringDevs\Subscription\Admin();
157 179 }
158 180
@@ -171,8 +193,41 @@
171 193 public function init_hooks() {
172 194 add_action( 'init', array( $this, 'init_classes' ) );
173 195 add_action( 'init', array( $this, 'localization_setup' ) );
174 196 add_action( 'init', array( $this, 'run_update' ) );
197 +
198 + // HPOS Compatibility: Declare support for custom order tables
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 + }
205 + }
206 + );
207 +
208 + // HPOS Compatibility: Register subscription post type with HPOS support
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 + );
175 230 }
176 231
177 232 /**
178 233 * Need to do some actions after update plugin
@@ -190,12 +245,13 @@
190 245 * @return void
191 246 */
192 247 public function init_classes() {
193 248 if ( $this->is_request( 'ajax' ) ) {
194 - $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();
195 251 }
196 252
197 - $this->container['api'] = new SpringDevs\Subscription\Api();
253 + $this->container['api'] = new SpringDevs\Subscription\API();
198 254 $this->container['assets'] = new SpringDevs\Subscription\Assets();
199 255 }
200 256
201 257 /**
@@ -200,12 +256,13 @@
200 256
201 257 /**
202 258 * Initialize plugin for localization
203 259 *
204 - * @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.
205 262 */
206 263 public function localization_setup() {
207 - load_plugin_textdomain( 'sdevs_subscrpt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
264 + // WordPress auto-loads translations for plugins hosted on WordPress.org since v4.6.
208 265 }
209 266
210 267 /**
211 268 * What type of request is this?
@@ -232,8 +289,38 @@
232 289 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
233 290 }
234 291 }
235 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 +}
236 323
237 324 /**
238 325 * Initialize the main plugin
239 326 *