PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.0
2.4.0 2.3.0 2.2.0 2.1.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 All 65 releases
subscription / includes / Illuminate.php

Illuminate.php in Subscriptions for WooCommerce with Stripe Recurring Payments 2.4.0, at includes/Illuminate.php

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