| @@ -1,15 +1,25 @@ | ||
| 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; |
| 16 | +use SpringDevs\Subscription\Illuminate\StockPause; | |
| 9 | 17 | use SpringDevs\Subscription\Illuminate\Email; |
| 18 | +use SpringDevs\Subscription\Illuminate\Multilingual; | |
| 10 | 19 | use SpringDevs\Subscription\Illuminate\Order; |
| 11 | 20 | use SpringDevs\Subscription\Illuminate\Post; |
| 21 | +use SpringDevs\Subscription\Illuminate\Stats; | |
| 12 | 22 | use SpringDevs\Subscription\Illuminate\Gateways\Stripe\Stripe; |
| 13 | 23 | use SpringDevs\Subscription\Illuminate\GuestCheckout; |
| 14 | 24 | use SpringDevs\Subscription\Illuminate\RoleManagement; |
| 15 | 25 | use SpringDevs\Subscription\Illuminate\Subscription\Subscription; |
| @@ -29,17 +39,55 @@ | ||
| 29 | 39 | new Subscription(); |
| 30 | 40 | new RoleManagement(); |
| 31 | 41 | new Order(); |
| 32 | 42 | new Cron(); |
| 43 | + new StockPause(); | |
| 44 | + new Cancellation(); | |
| 45 | + new Stats(); | |
| 33 | 46 | new Post(); |
| 34 | 47 | new Block(); |
| 35 | 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 | + } | |
| 36 | 56 | new GuestCheckout(); |
| 37 | 57 | new AutoRenewal(); |
| 38 | 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' ) ); | |
| 39 | 66 | } |
| 40 | 67 | |
| 41 | 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 | + /** | |
| 42 | 90 | * Stripe Initialization. |
| 43 | 91 | * |
| 44 | 92 | * @return void |
| 45 | 93 | */ |
| @@ -72,9 +120,9 @@ | ||
| 72 | 120 | $is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ); |
| 73 | 121 | |
| 74 | 122 | // Register the PayPal gateway with WooCommerce. |
| 75 | 123 | if ( $is_paypal_integration_enabled ) { |
| 76 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'register_paypal_gateway' ) ); | |
| 124 | + add_filter( 'woocommerce_payment_gateways', [ $this, 'register_paypal_gateway' ] ); | |
| 77 | 125 | } |
| 78 | 126 | } |
| 79 | 127 | |
| 80 | 128 | /** |