| 1 |
<?php |
| 2 |
|
| 3 |
namespace SpringDevs\Subscription; |
| 4 |
|
| 5 |
use SpringDevs\Subscription\Frontend\Checkout; |
| 6 |
use SpringDevs\Subscription\Illuminate\AutoRenewal; |
| 7 |
use SpringDevs\Subscription\Illuminate\Block; |
| 8 |
use SpringDevs\Subscription\Illuminate\Cron; |
| 9 |
use SpringDevs\Subscription\Illuminate\Email; |
| 10 |
use SpringDevs\Subscription\Illuminate\Order; |
| 11 |
use SpringDevs\Subscription\Illuminate\Post; |
| 12 |
use SpringDevs\Subscription\Illuminate\Gateways\Stripe\Stripe; |
| 13 |
use SpringDevs\Subscription\Illuminate\GuestCheckout; |
| 14 |
use SpringDevs\Subscription\Illuminate\RoleManagement; |
| 15 |
use SpringDevs\Subscription\Illuminate\Subscription\Subscription; |
| 16 |
|
| 17 |
/** |
| 18 |
* Globally Load Scripts. |
| 19 |
*/ |
| 20 |
class Illuminate { |
| 21 |
|
| 22 |
/** |
| 23 |
* Initialize the Class. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->stripe_initialization(); |
| 27 |
$this->paypal_initialization(); |
| 28 |
|
| 29 |
new Subscription(); |
| 30 |
new RoleManagement(); |
| 31 |
new Order(); |
| 32 |
new Cron(); |
| 33 |
new Post(); |
| 34 |
new Block(); |
| 35 |
new Checkout(); |
| 36 |
new GuestCheckout(); |
| 37 |
new AutoRenewal(); |
| 38 |
new Email(); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Stripe Initialization. |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public function stripe_initialization() { |
| 47 |
if ( function_exists( 'woocommerce_gateway_stripe' ) ) { |
| 48 |
if ( ! class_exists( 'WC_Payment_Gateway_CC' ) ) { |
| 49 |
include_once dirname( WC_PLUGIN_FILE ) . '/includes/gateways/class-wc-payment-gateway-cc.php'; |
| 50 |
} |
| 51 |
|
| 52 |
include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions-utilities.php'; |
| 53 |
include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-pre-orders.php'; |
| 54 |
include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/compat/trait-wc-stripe-subscriptions.php'; |
| 55 |
include_once dirname( WC_STRIPE_MAIN_FILE ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
| 56 |
|
| 57 |
if ( class_exists( '\WC_Stripe_Payment_Gateway' ) ) { |
| 58 |
new Stripe(); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* PayPal Gateway Initialization. |
| 65 |
* |
| 66 |
* @return void |
| 67 |
*/ |
| 68 |
public function paypal_initialization() { |
| 69 |
// Forcefully enable PayPal integration if the option is not set. |
| 70 |
update_option( 'wp_subs_paypal_integration_enabled', 'on' ); |
| 71 |
|
| 72 |
$is_paypal_integration_enabled = 'on' === get_option( 'wp_subs_paypal_integration_enabled', 'off' ); |
| 73 |
|
| 74 |
// Register the PayPal gateway with WooCommerce. |
| 75 |
if ( $is_paypal_integration_enabled ) { |
| 76 |
add_filter( 'woocommerce_payment_gateways', array( $this, 'register_paypal_gateway' ) ); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Register our custom PayPal gateway with WooCommerce |
| 82 |
* |
| 83 |
* @param array $gateways Payment gateways. |
| 84 |
* @return array |
| 85 |
*/ |
| 86 |
public function register_paypal_gateway( $gateways ) { |
| 87 |
$gateways[] = 'SpringDevs\\Subscription\\Illuminate\\Gateways\\Paypal\\Paypal'; |
| 88 |
return $gateways; |
| 89 |
} |
| 90 |
} |
| 91 |
|