| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class to boot up module. |
| 4 |
* |
| 5 |
* @link https://wpmudev.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @author WPMUDEV (https://wpmudev.com) |
| 9 |
* @package WPMUDEV/Plugin_Cross_Sell |
| 10 |
* |
| 11 |
* @copyright (c) 2025, Incsub (http://incsub.com) |
| 12 |
*/ |
| 13 |
|
| 14 |
namespace WPMUDEV\Modules\Plugin_Cross_Sell; |
| 15 |
|
| 16 |
// If this file is called directly, abort. |
| 17 |
defined( 'WPINC' ) || die; |
| 18 |
|
| 19 |
/** |
| 20 |
* The Loader class is responsible for initializing the module. |
| 21 |
*/ |
| 22 |
final class Loader { |
| 23 |
/** |
| 24 |
* Settings helper class instance. |
| 25 |
* |
| 26 |
* @since 1.0.0 |
| 27 |
* @var object |
| 28 |
*/ |
| 29 |
public $settings; |
| 30 |
|
| 31 |
/** |
| 32 |
* Minimum supported php version. |
| 33 |
* |
| 34 |
* @since 1.0.0 |
| 35 |
* @var float |
| 36 |
*/ |
| 37 |
public $php_version = '7.4'; |
| 38 |
|
| 39 |
/** |
| 40 |
* Minimum WordPress version. |
| 41 |
* |
| 42 |
* @since 1.0.0 |
| 43 |
* @var float |
| 44 |
*/ |
| 45 |
public $wp_version = '6.3'; |
| 46 |
|
| 47 |
/** |
| 48 |
* The dependency container. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* @var Container |
| 52 |
*/ |
| 53 |
private $container; |
| 54 |
|
| 55 |
/** |
| 56 |
* Initialize the loader. |
| 57 |
* |
| 58 |
* @since 1.0.0 |
| 59 |
* @param Container $container The dependency container. |
| 60 |
* @return void |
| 61 |
*/ |
| 62 |
public function __construct( Container $container ) { |
| 63 |
$this->container = $container; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Initialize functionality if requirements are met. |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
public function init(): void { |
| 72 |
if ( ! $this->can_boot() ) { |
| 73 |
return; |
| 74 |
} |
| 75 |
|
| 76 |
$this->setup_components(); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Main condition that checks if plugin parts should continue loading. |
| 81 |
* |
| 82 |
* @return bool |
| 83 |
*/ |
| 84 |
private function can_boot() { |
| 85 |
/** |
| 86 |
* Checks |
| 87 |
* - PHP version |
| 88 |
* - WP Version |
| 89 |
* If not then return. |
| 90 |
*/ |
| 91 |
global $wp_version; |
| 92 |
|
| 93 |
return ( |
| 94 |
version_compare( PHP_VERSION, $this->php_version, '>=' ) && |
| 95 |
version_compare( $wp_version, $this->wp_version, '>=' ) |
| 96 |
); |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Register all the actions and filters. |
| 101 |
* |
| 102 |
* @since 1.0.0 |
| 103 |
* @access private |
| 104 |
* @return void |
| 105 |
*/ |
| 106 |
private function setup_components(): void { |
| 107 |
$submenus = new App\Submenus\CrossSell(); |
| 108 |
$submenus->init( $this->container ); |
| 109 |
|
| 110 |
$install_endpoint = new App\Rest_Endpoints\Install_Plugin(); |
| 111 |
$install_endpoint->init( $this->container ); |
| 112 |
|
| 113 |
$activation_endpoint = new App\Rest_Endpoints\Activate_Plugin(); |
| 114 |
$activation_endpoint->init( $this->container ); |
| 115 |
} |
| 116 |
} |
| 117 |
|