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 | includes/Illuminate.php +88 -2 1.3.22.0.0 View file →
@@ -1,16 +1,27 @@
1 1 <?php
2 +/**
3 + * Service container bootstrap.
4 + *
5 + * @package SpringDevs\Subscription
6 + */
2 7
3 8 namespace SpringDevs\Subscription;
4 9
5 10 use SpringDevs\Subscription\Frontend\Checkout;
11 +use SpringDevs\Subscription\Frontend\PlanCheckout;
6 12 use SpringDevs\Subscription\Illuminate\AutoRenewal;
7 13 use SpringDevs\Subscription\Illuminate\Block;
14 +use SpringDevs\Subscription\Illuminate\Cancellation;
8 15 use SpringDevs\Subscription\Illuminate\Cron;
9 16 use SpringDevs\Subscription\Illuminate\Email;
10 17 use SpringDevs\Subscription\Illuminate\Order;
11 18 use SpringDevs\Subscription\Illuminate\Post;
12 -use SpringDevs\Subscription\Illuminate\Stripe;
19 +use SpringDevs\Subscription\Illuminate\Stats;
20 +use SpringDevs\Subscription\Illuminate\Gateways\Stripe\Stripe;
21 +use SpringDevs\Subscription\Illuminate\GuestCheckout;
22 +use SpringDevs\Subscription\Illuminate\RoleManagement;
23 +use SpringDevs\Subscription\Illuminate\Subscription\Subscription;
13 24
14 25 /**
15 26 * Globally Load Scripts.
16 27 */
@@ -20,18 +31,59 @@
20 31 * Initialize the Class.
21 32 */
22 33 public function __construct() {
23 34 $this->stripe_initialization();
35 + $this->paypal_initialization();
36 +
37 + new Subscription();
38 + new RoleManagement();
24 39 new Order();
25 40 new Cron();
41 + new Cancellation();
42 + new Stats();
26 43 new Post();
27 44 new Block();
28 45 new Checkout();
46 + // Pro ships a superset plan checkout (Subscribe & Save, Installments,
47 + // variable / per-variation) on the same hooks and priorities, so free's
48 + // Recurring-simple checkout runs only when Pro is absent — otherwise the two
49 + // would create the subscription twice.
50 + if ( ! subscrpt_pro_activated() ) {
51 + new PlanCheckout();
52 + }
53 + new GuestCheckout();
29 54 new AutoRenewal();
30 55 new Email();
56 +
57 + // Hide the internal plan snapshot meta from the admin order-item screen.
58 + // WooCommerce's admin item view lists every meta key not in this filter
59 + // (it does not hide the leading-underscore prefix there). Registered here —
60 + // always loaded, both plugins share these keys — so it covers free and pro.
61 + add_filter( 'woocommerce_hidden_order_itemmeta', array( $this, 'hidden_plan_order_itemmeta' ) );
31 62 }
32 63
33 64 /**
65 + * Hide the plan snapshot meta keys on the admin order-item screen.
66 + *
67 + * @param array $keys Hidden order-item meta keys.
68 + *
69 + * @return array
70 + */
71 + public function hidden_plan_order_itemmeta( $keys ) {
72 + return array_merge(
73 + (array) $keys,
74 + array(
75 + '_subscrpt_plan_id',
76 + '_subscrpt_plan_group_id',
77 + '_subscrpt_plan_price',
78 + '_subscrpt_plan_payment_type',
79 + '_subscrpt_plan_max_no_payment',
80 + '_subscrpt_plan_terms',
81 + )
82 + );
83 + }
84 +
85 + /**
34 86 * Stripe Initialization.
35 87 *
36 88 * @return void
37 89 */
@@ -36,13 +88,47 @@
36 88 * @return void
37 89 */
38 90 public function stripe_initialization() {
39 91 if ( function_exists( 'woocommerce_gateway_stripe' ) ) {
92 + if ( ! class_exists( 'WC_Payment_Gateway_CC' ) ) {
93 + include_once dirname( WC_PLUGIN_FILE ) . '/includes/gateways/class-wc-payment-gateway-cc.php';
94 + }
95 +
40 96 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions-utilities.php';
41 97 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-pre-orders.php';
42 98 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions.php';
43 99 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
44 100
45 - new Stripe();
101 + if ( class_exists( '\WC_Stripe_Payment_Gateway' ) ) {
102 + new Stripe();
103 + }
46 104 }
105 + }
106 +
107 + /**
108 + * PayPal Gateway Initialization.
109 + *
110 + * @return void
111 + */
112 + public function paypal_initialization() {
113 + // Forcefully enable PayPal integration if the option is not set.
114 + update_option( 'wp_subs_paypal_integration_enabled', 'on' );
115 +
116 + $is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' );
117 +
118 + // Register the PayPal gateway with WooCommerce.
119 + if ( $is_paypal_integration_enabled ) {
120 + add_filter( 'woocommerce_payment_gateways', [ $this, 'register_paypal_gateway' ] );
121 + }
122 + }
123 +
124 + /**
125 + * Register our custom PayPal gateway with WooCommerce
126 + *
127 + * @param array $gateways Payment gateways.
128 + * @return array
129 + */
130 + public function register_paypal_gateway( $gateways ) {
131 + $gateways[] = 'SpringDevs\\Subscription\\Illuminate\\Gateways\\Paypal\\Paypal';
132 + return $gateways;
47 133 }
48 134 }