| 1 |
<?php |
| 2 |
/** |
| 3 |
* CartFlows Webhook Module Loader. |
| 4 |
* |
| 5 |
* @package CartFlows |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! class_exists( 'Cartflows_Webhook_Loader' ) ) { |
| 14 |
|
| 15 |
/** |
| 16 |
* Class Cartflows_Webhook_Loader. |
| 17 |
*/ |
| 18 |
class Cartflows_Webhook_Loader { |
| 19 |
|
| 20 |
/** |
| 21 |
* Member Variable |
| 22 |
* |
| 23 |
* @var instance |
| 24 |
*/ |
| 25 |
private static $instance = null; |
| 26 |
|
| 27 |
/** |
| 28 |
* Initiator |
| 29 |
* |
| 30 |
* @return object initialized object of class. |
| 31 |
*/ |
| 32 |
public static function get_instance() { |
| 33 |
if ( is_null( self::$instance ) ) { |
| 34 |
self::$instance = new self(); |
| 35 |
} |
| 36 |
return self::$instance; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Constructor |
| 41 |
*/ |
| 42 |
public function __construct() { |
| 43 |
$this->define_constants(); |
| 44 |
$this->load_files(); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Define webhook module constants. |
| 49 |
*/ |
| 50 |
private function define_constants() { |
| 51 |
define( 'CARTFLOWS_WEBHOOK_DIR', plugin_dir_path( __FILE__ ) ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Load module files. |
| 56 |
*/ |
| 57 |
private function load_files() { |
| 58 |
include_once CARTFLOWS_WEBHOOK_DIR . 'classes/class-cartflows-webhook-manager.php'; |
| 59 |
include_once CARTFLOWS_WEBHOOK_DIR . 'classes/class-cartflows-webhook-payload.php'; |
| 60 |
include_once CARTFLOWS_WEBHOOK_DIR . 'classes/class-cartflows-webhook-dispatcher.php'; |
| 61 |
include_once CARTFLOWS_WEBHOOK_DIR . 'classes/class-cartflows-webhook-events.php'; |
| 62 |
|
| 63 |
// Instantiate dispatcher so AS hook is always registered. |
| 64 |
Cartflows_Webhook_Dispatcher::get_instance(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
Cartflows_Webhook_Loader::get_instance(); |
| 69 |
} |
| 70 |
|