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