| @@ -1,30 +1,40 @@ | ||
| 1 | 1 | <?php |
| 2 | -/* | |
| 3 | -Plugin Name: WPSubscription - WooCommerce Subscription & Recurring Payment Plugin | |
| 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.5.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. |
| 30 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 31 | + exit; | |
| 32 | +} | |
| 19 | 33 | |
| 20 | 34 | use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; |
| 21 | 35 | use SpringDevs\Subscription\Illuminate\Gateways\Paypal\Paypal_Blocks_Integration; |
| 22 | 36 | |
| 23 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 24 | - exit; | |
| 25 | -} | |
| 26 | - | |
| 27 | 37 | require_once __DIR__ . '/vendor/autoload.php'; |
| 28 | 38 | |
| 29 | 39 | /** |
| 30 | 40 | * Sdevs_Subscription class |
| @@ -38,9 +48,9 @@ | ||
| 38 | 48 | * Plugin version |
| 39 | 49 | * |
| 40 | 50 | * @var string |
| 41 | 51 | */ |
| 42 | - const version = '1.5.0'; | |
| 52 | + const VERSION = '2.0.0'; | |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Holds various class instances |
| 46 | 56 | * |
| @@ -112,15 +122,19 @@ | ||
| 112 | 122 | * |
| 113 | 123 | * @return void |
| 114 | 124 | */ |
| 115 | 125 | public function define_constants() { |
| 116 | - define( 'WP_SUBSCRIPTION_VERSION', self::version ); | |
| 117 | - define( 'WP_SUBSCRIPTION_FILE', __FILE__ ); | |
| 118 | - define( 'WP_SUBSCRIPTION_PATH', dirname( WP_SUBSCRIPTION_FILE ) ); | |
| 119 | - define( 'WP_SUBSCRIPTION_INCLUDES', WP_SUBSCRIPTION_PATH . '/includes' ); | |
| 120 | - define( 'WP_SUBSCRIPTION_TEMPLATES', WP_SUBSCRIPTION_PATH . '/templates/' ); | |
| 121 | - define( 'WP_SUBSCRIPTION_URL', plugins_url( '', WP_SUBSCRIPTION_FILE ) ); | |
| 122 | - 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'; | |
| 123 | 137 | } |
| 124 | 138 | |
| 125 | 139 | /** |
| 126 | 140 | * Load the plugin after all plugins are loaded |
| @@ -145,9 +159,10 @@ | ||
| 145 | 159 | * |
| 146 | 160 | * Nothing being called here yet. |
| 147 | 161 | */ |
| 148 | 162 | public function deactivate() { |
| 149 | - 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 | |
| 150 | 165 | } |
| 151 | 166 | |
| 152 | 167 | /** |
| 153 | 168 | * Include the required files |
| @@ -154,8 +169,12 @@ | ||
| 154 | 169 | * |
| 155 | 170 | * @return void |
| 156 | 171 | */ |
| 157 | 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 | + | |
| 158 | 177 | if ( $this->is_request( 'admin' ) ) { |
| 159 | 178 | $this->container['admin'] = new SpringDevs\Subscription\Admin(); |
| 160 | 179 | } |
| 161 | 180 | |
| @@ -226,9 +245,10 @@ | ||
| 226 | 245 | * @return void |
| 227 | 246 | */ |
| 228 | 247 | public function init_classes() { |
| 229 | 248 | if ( $this->is_request( 'ajax' ) ) { |
| 230 | - $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(); | |
| 231 | 251 | } |
| 232 | 252 | |
| 233 | 253 | $this->container['api'] = new SpringDevs\Subscription\API(); |
| 234 | 254 | $this->container['assets'] = new SpringDevs\Subscription\Assets(); |
| @@ -236,12 +256,13 @@ | ||
| 236 | 256 | |
| 237 | 257 | /** |
| 238 | 258 | * Initialize plugin for localization |
| 239 | 259 | * |
| 240 | - * @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. | |
| 241 | 262 | */ |
| 242 | 263 | public function localization_setup() { |
| 243 | - 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. | |
| 244 | 265 | } |
| 245 | 266 | |
| 246 | 267 | /** |
| 247 | 268 | * What type of request is this? |
| @@ -270,13 +291,13 @@ | ||
| 270 | 291 | } |
| 271 | 292 | } // Sdevs_Wc_Subscription |
| 272 | 293 | |
| 273 | 294 | // Add Paypal Gateway Blocks. |
| 274 | -if ( ! function_exists( 'wp_subscription_register_paypal_block' ) ) { | |
| 295 | +if ( ! function_exists( 'subscrpt_register_paypal_block' ) ) { | |
| 275 | 296 | /** |
| 276 | 297 | * Register the PayPal block for WooCommerce Blocks. |
| 277 | 298 | */ |
| 278 | - function wp_subscription_register_paypal_block() { | |
| 299 | + function subscrpt_register_paypal_block() { | |
| 279 | 300 | // Check if the required class exists. |
| 280 | 301 | if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { |
| 281 | 302 | return; |
| 282 | 303 | } |
| @@ -289,12 +310,15 @@ | ||
| 289 | 310 | } |
| 290 | 311 | ); |
| 291 | 312 | } |
| 292 | 313 | |
| 293 | - // Is PayPal integration enabled? | |
| 294 | - $is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ); | |
| 295 | - if ( $is_paypal_integration_enabled ) { | |
| 296 | - add_action( 'woocommerce_blocks_loaded', 'wp_subscription_register_paypal_block' ); | |
| 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 | + } | |
| 297 | 321 | } |
| 298 | 322 | } |
| 299 | 323 | |
| 300 | 324 | /** |