PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.3.3
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.3.3
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 66 releases
better-payment / includes / WooCommerce / Loader.php

Loader.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.3.3, at includes/WooCommerce/Loader.php

101 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\WooCommerce;
4
5 /**
6 * Exit if accessed directly
7 */
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Wires the WooCommerce integration module.
14 *
15 * Called from the bootstrap only when `class_exists( 'WooCommerce' )` — on
16 * sites without WooCommerce none of this module loads. Dependency direction
17 * is strictly WooCommerce module → Better Payment core; core never
18 * references this namespace.
19 *
20 * @since 2.4.0
21 */
22 class Loader {
23
24 /**
25 * Register the module's hooks.
26 *
27 * @return void
28 */
29 public static function register() {
30 // HPOS (custom order tables) compatibility — all order access in this
31 // module goes through the WC CRUD API.
32 add_action( 'before_woocommerce_init', array( __CLASS__, 'declare_hpos_compatibility' ) );
33
34 // Gateway registration (classic checkout + settings screen).
35 add_filter( 'woocommerce_payment_gateways', array( __CLASS__, 'register_gateway' ) );
36
37 // Blocks checkout support.
38 add_action( 'woocommerce_blocks_loaded', array( __CLASS__, 'register_blocks_support' ) );
39
40 // Return-URL verification + payment_confirmed consumer.
41 OrderHandler::register();
42
43 // Recurring payments (Better Payment subscriptions).
44 Subscriptions::register();
45
46 // "Subscription Total" summary on the cart + checkout totals table.
47 CartTotals::register();
48
49 // My Account > Subscriptions tab (customer list + single view).
50 MyAccount::register();
51
52 // Subscription lifecycle customer emails (cancelled + completed).
53 Emails::register();
54 }
55
56 /**
57 * Add the gateway to WooCommerce's list.
58 *
59 * @param array $gateways Registered gateway class names/instances.
60 * @return array
61 */
62 public static function register_gateway( $gateways ) {
63 $gateways[] = Gateway::class;
64
65 return $gateways;
66 }
67
68 /**
69 * Register the blocks checkout payment method integration.
70 *
71 * @return void
72 */
73 public static function register_blocks_support() {
74 if ( ! class_exists( '\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
75 return;
76 }
77
78 add_action(
79 'woocommerce_blocks_payment_method_type_registration',
80 static function ( $registry ) {
81 $registry->register( new Blocks() );
82 }
83 );
84 }
85
86 /**
87 * Declare HPOS compatibility.
88 *
89 * @return void
90 */
91 public static function declare_hpos_compatibility() {
92 if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
93 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
94 'custom_order_tables',
95 BETTER_PAYMENT_FILE,
96 true
97 );
98 }
99 }
100 }
101