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
subscription / includes / Illuminate.php

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

135 lines 4.0 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\Email;
17 use SpringDevs\Subscription\Illuminate\Order;
18 use SpringDevs\Subscription\Illuminate\Post;
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;
24
25 /**
26 * Globally Load Scripts.
27 */
28 class Illuminate {
29
30 /**
31 * Initialize the Class.
32 */
33 public function __construct() {
34 $this->stripe_initialization();
35 $this->paypal_initialization();
36
37 new Subscription();
38 new RoleManagement();
39 new Order();
40 new Cron();
41 new Cancellation();
42 new Stats();
43 new Post();
44 new Block();
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();
54 new AutoRenewal();
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' ) );
62 }
63
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 /**
86 * Stripe Initialization.
87 *
88 * @return void
89 */
90 public function stripe_initialization() {
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
96 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions-utilities.php';
97 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-pre-orders.php';
98 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions.php';
99 include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php';
100
101 if ( class_exists( '\WC_Stripe_Payment_Gateway' ) ) {
102 new Stripe();
103 }
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;
133 }
134 }
135