| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main plugin class. |
| 4 |
* |
| 5 |
* @package WebberZone\Top_Ten |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WebberZone\Top_Ten; |
| 9 |
|
| 10 |
use WebberZone\Top_Ten\Admin\Cron; |
| 11 |
|
| 12 |
if ( ! defined( 'WPINC' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Main plugin class. |
| 18 |
* |
| 19 |
* @since 3.3.0 |
| 20 |
*/ |
| 21 |
final class Main { |
| 22 |
/** |
| 23 |
* The single instance of the class. |
| 24 |
* |
| 25 |
* @var Main |
| 26 |
*/ |
| 27 |
private static ?self $instance = null; |
| 28 |
|
| 29 |
/** |
| 30 |
* Admin. |
| 31 |
* |
| 32 |
* @since 3.3.0 |
| 33 |
* |
| 34 |
* @var Admin\Admin |
| 35 |
*/ |
| 36 |
public ?Admin\Admin $admin = null; |
| 37 |
|
| 38 |
/** |
| 39 |
* Network Admin. |
| 40 |
* |
| 41 |
* @since 4.2.0 |
| 42 |
* |
| 43 |
* @var Admin\Network\Admin |
| 44 |
*/ |
| 45 |
public ?Admin\Network\Admin $network_admin = null; |
| 46 |
|
| 47 |
/** |
| 48 |
* Shortcodes. |
| 49 |
* |
| 50 |
* @since 3.3.0 |
| 51 |
* |
| 52 |
* @var Frontend\Shortcodes |
| 53 |
*/ |
| 54 |
public Frontend\Shortcodes $shortcodes; |
| 55 |
|
| 56 |
/** |
| 57 |
* Blocks. |
| 58 |
* |
| 59 |
* @since 3.3.0 |
| 60 |
* |
| 61 |
* @var Frontend\Blocks\Blocks|null |
| 62 |
*/ |
| 63 |
public ?Frontend\Blocks\Blocks $blocks = null; |
| 64 |
|
| 65 |
/** |
| 66 |
* Counter. |
| 67 |
* |
| 68 |
* @since 3.3.0 |
| 69 |
* |
| 70 |
* @var Counter |
| 71 |
*/ |
| 72 |
public Counter $counter; |
| 73 |
|
| 74 |
/** |
| 75 |
* Tracker. |
| 76 |
* |
| 77 |
* @since 3.3.0 |
| 78 |
* |
| 79 |
* @var Tracker |
| 80 |
*/ |
| 81 |
public Tracker $tracker; |
| 82 |
|
| 83 |
/** |
| 84 |
* Feed. |
| 85 |
* |
| 86 |
* @since 3.3.0 |
| 87 |
* |
| 88 |
* @var Frontend\Feed|null |
| 89 |
*/ |
| 90 |
public ?Frontend\Feed $feed = null; |
| 91 |
|
| 92 |
/** |
| 93 |
* Styles. |
| 94 |
* |
| 95 |
* @since 3.3.0 |
| 96 |
* |
| 97 |
* @var Frontend\Styles_Handler |
| 98 |
*/ |
| 99 |
public Frontend\Styles_Handler $styles; |
| 100 |
|
| 101 |
/** |
| 102 |
* Language Handler. |
| 103 |
* |
| 104 |
* @since 3.3.0 |
| 105 |
* |
| 106 |
* @var Frontend\Language_Handler |
| 107 |
*/ |
| 108 |
public Frontend\Language_Handler $language; |
| 109 |
|
| 110 |
/** |
| 111 |
* Cron class. |
| 112 |
* |
| 113 |
* @since 3.3.0 |
| 114 |
* |
| 115 |
* @var Cron |
| 116 |
*/ |
| 117 |
public Cron $cron; |
| 118 |
|
| 119 |
/** |
| 120 |
* Pro class. |
| 121 |
* |
| 122 |
* @since 4.0.0 |
| 123 |
* |
| 124 |
* @var Pro\Pro |
| 125 |
*/ |
| 126 |
public ?Pro\Pro $pro = null; |
| 127 |
|
| 128 |
/** |
| 129 |
* Gets the instance of the class. |
| 130 |
* |
| 131 |
* @since 3.3.0 |
| 132 |
* |
| 133 |
* @return Main |
| 134 |
*/ |
| 135 |
public static function get_instance() { |
| 136 |
if ( null === self::$instance ) { |
| 137 |
self::$instance = new self(); |
| 138 |
self::$instance->init(); |
| 139 |
} |
| 140 |
|
| 141 |
return self::$instance; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* A dummy constructor. |
| 146 |
* |
| 147 |
* @since 3.3.0 |
| 148 |
*/ |
| 149 |
private function __construct() { |
| 150 |
// Do nothing. |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Initializes the plugin. |
| 155 |
* |
| 156 |
* @since 3.3.0 |
| 157 |
*/ |
| 158 |
private function init() { |
| 159 |
$this->language = new Frontend\Language_Handler(); |
| 160 |
$this->styles = new Frontend\Styles_Handler(); |
| 161 |
$this->counter = new Counter(); |
| 162 |
$this->tracker = new Tracker(); |
| 163 |
$this->shortcodes = new Frontend\Shortcodes(); |
| 164 |
$this->cron = new Cron(); |
| 165 |
|
| 166 |
if ( Feature_Manager::is_enabled( 'blocks' ) ) { |
| 167 |
$this->blocks = new Frontend\Blocks\Blocks(); |
| 168 |
} |
| 169 |
if ( Feature_Manager::is_enabled( 'feed' ) ) { |
| 170 |
$this->feed = new Frontend\Feed(); |
| 171 |
} |
| 172 |
|
| 173 |
new Hook_Loader(); |
| 174 |
|
| 175 |
// Initialize admin on init action to ensure translations are loaded. |
| 176 |
add_action( 'init', array( $this, 'init_admin' ) ); |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Initialize admin components. |
| 181 |
* |
| 182 |
* @since 4.2.0 |
| 183 |
*/ |
| 184 |
public function init_admin(): void { |
| 185 |
if ( is_admin() ) { |
| 186 |
$this->admin = new Admin\Admin(); |
| 187 |
if ( is_multisite() ) { |
| 188 |
$this->network_admin = new Admin\Network\Admin(); |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
} |
| 193 |
|