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 +104 -42 1.3.02.0.0 View file →
@@ -1,43 +1,30 @@
1 1 <?php
2 -/*
3 -Plugin Name: Subscription for WooCommerce
4 -Plugin URI: https://wordpress.org/plugins/subscription
5 -Description: Allow your customers to order once and get their products and services every month/week.
6 -Version: 1.3.0
7 -Author: SpringDevs
8 -Author URI: https://springdevs.com/
9 -Requires Plugins: woocommerce
10 -License: GPLv2
11 -License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 -Text Domain: sdevs_subscrpt
13 -Domain Path: /languages
14 -*/
15 -
16 2 /**
17 - * Copyright (c) 2021 SpringDevs (email: contact@springdevs.com). All rights reserved.
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.
18 6 *
19 - * Released under the GPL license
20 - * http://www.opensource.org/licenses/gpl-license.php
7 + * Version: 2.0.0
21 8 *
22 - * This is an add-on for WordPress
23 - * http://wordpress.org/
9 + * Author: ConversWP
10 + * Author URI: https://wpsubscription.co/
24 11 *
25 - * **********************************************************************
26 - * This program is free software; you can redistribute it and/or modify
27 - * it under the terms of the GNU General Public License as published by
28 - * the Free Software Foundation; either version 2 of the License, or
29 - * (at your option) any later version.
12 + * Text Domain: subscription
13 + * Domain Path: /languages
30 14 *
31 - * This program is distributed in the hope that it will be useful,
32 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 - * GNU General Public License for more details.
15 + * Requires PHP: 7.4
35 16 *
36 - * You should have received a copy of the GNU General Public License
37 - * along with this program; if not, write to the Free Software
38 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39 - * **********************************************************************
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
40 27 */
41 28
42 29 // don't call the file directly.
43 30 if ( ! defined( 'ABSPATH' ) ) {
@@ -43,8 +30,11 @@
43 30 if ( ! defined( 'ABSPATH' ) ) {
44 31 exit;
45 32 }
46 33
34 +use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
35 +use SpringDevs\Subscription\Illuminate\Gateways\Paypal\Paypal_Blocks_Integration;
36 +
47 37 require_once __DIR__ . '/vendor/autoload.php';
48 38
49 39 /**
50 40 * Sdevs_Subscription class
@@ -58,9 +48,9 @@
58 48 * Plugin version
59 49 *
60 50 * @var string
61 51 */
62 - const version = '1.3.0';
52 + const VERSION = '2.0.0';
63 53
64 54 /**
65 55 * Holds various class instances
66 56 *
@@ -65,9 +55,9 @@
65 55 * Holds various class instances
66 56 *
67 57 * @var array
68 58 */
69 - private array $container = array();
59 + private $container = array();
70 60
71 61 /**
72 62 * Constructor for the Sdevs_Wc_Subscription class
73 63 *
@@ -132,9 +122,9 @@
132 122 *
133 123 * @return void
134 124 */
135 125 public function define_constants() {
136 - define( 'SUBSCRPT_VERSION', self::version );
126 + define( 'SUBSCRPT_VERSION', self::VERSION );
137 127 define( 'SUBSCRPT_FILE', __FILE__ );
138 128 define( 'SUBSCRPT_PATH', dirname( SUBSCRPT_FILE ) );
139 129 define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
140 130 define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
@@ -139,8 +129,12 @@
139 129 define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
140 130 define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
141 131 define( 'SUBSCRPT_URL', plugins_url( '', SUBSCRPT_FILE ) );
142 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';
143 137 }
144 138
145 139 /**
146 140 * Load the plugin after all plugins are loaded
@@ -153,10 +147,8 @@
153 147 }
154 148
155 149 /**
156 150 * Placeholder for activation function
157 - *
158 - * Nothing being called here yet.
159 151 */
160 152 public function activate() {
161 153 $installer = new SpringDevs\Subscription\Installer();
162 154 $installer->run();
@@ -167,9 +159,10 @@
167 159 *
168 160 * Nothing being called here yet.
169 161 */
170 162 public function deactivate() {
171 - 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
172 165 }
173 166
174 167 /**
175 168 * Include the required files
@@ -176,8 +169,12 @@
176 169 *
177 170 * @return void
178 171 */
179 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 +
180 177 if ( $this->is_request( 'admin' ) ) {
181 178 $this->container['admin'] = new SpringDevs\Subscription\Admin();
182 179 }
183 180
@@ -196,8 +193,41 @@
196 193 public function init_hooks() {
197 194 add_action( 'init', array( $this, 'init_classes' ) );
198 195 add_action( 'init', array( $this, 'localization_setup' ) );
199 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 + );
200 230 }
201 231
202 232 /**
203 233 * Need to do some actions after update plugin
@@ -215,12 +245,13 @@
215 245 * @return void
216 246 */
217 247 public function init_classes() {
218 248 if ( $this->is_request( 'ajax' ) ) {
219 - $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();
220 251 }
221 252
222 - $this->container['api'] = new SpringDevs\Subscription\Api();
253 + $this->container['api'] = new SpringDevs\Subscription\API();
223 254 $this->container['assets'] = new SpringDevs\Subscription\Assets();
224 255 }
225 256
226 257 /**
@@ -225,12 +256,13 @@
225 256
226 257 /**
227 258 * Initialize plugin for localization
228 259 *
229 - * @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.
230 262 */
231 263 public function localization_setup() {
232 - 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.
233 265 }
234 266
235 267 /**
236 268 * What type of request is this?
@@ -257,8 +289,38 @@
257 289 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
258 290 }
259 291 }
260 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 +}
261 323
262 324 /**
263 325 * Initialize the main plugin
264 326 *