| @@ -1,14 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Hostinger; |
| 4 | 4 | |
| 5 | - | |
| 5 | +use Hostinger\Admin\Ajax as AdminAjax; | |
| 6 | 6 | use Hostinger\Admin\PluginSettings; |
| 7 | -use Hostinger\Admin\Jobs\JobInitializer; | |
| 8 | -use Hostinger\Admin\Proxy; | |
| 9 | -use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper; | |
| 10 | -use Hostinger\LlmsTxtGenerator\LlmsTxtParser; | |
| 11 | 7 | use Hostinger\Rest\Routes; |
| 12 | 8 | use Hostinger\Rest\SettingsRoutes; |
| 13 | 9 | use Hostinger\Admin\Assets as AdminAssets; |
| 14 | 10 | use Hostinger\Admin\Hooks as AdminHooks; |
| @@ -13,83 +9,65 @@ | ||
| 13 | 9 | use Hostinger\Admin\Assets as AdminAssets; |
| 14 | 10 | use Hostinger\Admin\Hooks as AdminHooks; |
| 15 | 11 | use Hostinger\Admin\Menu as AdminMenu; |
| 16 | 12 | use Hostinger\Admin\Redirects as AdminRedirects; |
| 17 | -use Hostinger\WpHelper\Config; | |
| 18 | -use Hostinger\WpHelper\Requests\Client; | |
| 19 | -use Hostinger\WpHelper\Utils; | |
| 20 | -use Hostinger\LlmsTxtGenerator\LlmsTxtGenerator; | |
| 13 | +use Hostinger\Preview\Assets as PreviewAssets; | |
| 21 | 14 | |
| 22 | 15 | defined( 'ABSPATH' ) || exit; |
| 23 | 16 | |
| 24 | 17 | class Bootstrap { |
| 18 | + protected Loader $loader; | |
| 25 | 19 | |
| 26 | - protected Loader $loader; | |
| 27 | - protected Utils $utils; | |
| 28 | - protected Config $config; | |
| 20 | + public function __construct() { | |
| 21 | + $this->loader = new Loader(); | |
| 22 | + } | |
| 29 | 23 | |
| 30 | - public function __construct() { | |
| 31 | - $this->loader = new Loader(); | |
| 32 | - $this->utils = new Utils(); | |
| 33 | - $this->config = new Config(); | |
| 34 | - } | |
| 24 | + public function run(): void { | |
| 25 | + $this->load_dependencies(); | |
| 26 | + $this->set_locale(); | |
| 27 | + $this->loader->run(); | |
| 28 | + } | |
| 35 | 29 | |
| 36 | - public function run(): void { | |
| 37 | - $this->load_dependencies(); | |
| 38 | - $this->set_locale(); | |
| 39 | - $this->loader->run(); | |
| 40 | - } | |
| 30 | + private function load_dependencies(): void { | |
| 31 | + $this->load_public_dependencies(); | |
| 41 | 32 | |
| 42 | - private function load_dependencies(): void { | |
| 43 | - $this->load_public_dependencies(); | |
| 33 | + if ( is_admin() ) { | |
| 34 | + $this->load_admin_dependencies(); | |
| 35 | + } | |
| 44 | 36 | |
| 45 | - if ( is_admin() ) { | |
| 46 | - $this->load_admin_dependencies(); | |
| 47 | - } | |
| 37 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
| 38 | + new Cli(); | |
| 39 | + } | |
| 48 | 40 | |
| 49 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
| 50 | - new Cli(); | |
| 51 | - } | |
| 52 | - | |
| 53 | 41 | $plugin_settings = new PluginSettings(); |
| 54 | - $plugin_options = $plugin_settings->get_plugin_settings(); | |
| 42 | + $plugin_options = $plugin_settings->get_plugin_settings(); | |
| 55 | 43 | |
| 56 | - if ( $plugin_options->get_maintenance_mode() ) { | |
| 57 | - require_once HOSTINGER_ABSPATH . 'includes/ComingSoon.php'; | |
| 58 | - } | |
| 59 | - } | |
| 44 | + if ( $plugin_options->get_maintenance_mode() ) { | |
| 45 | + require_once HOSTINGER_ABSPATH . 'includes/ComingSoon.php'; | |
| 46 | + } | |
| 47 | + } | |
| 60 | 48 | |
| 61 | - private function set_locale() { | |
| 62 | - $plugin_i18n = new I18n(); | |
| 63 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); | |
| 64 | - } | |
| 49 | + private function set_locale() { | |
| 50 | + $plugin_i18n = new I18n(); | |
| 51 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); | |
| 52 | + } | |
| 65 | 53 | |
| 66 | - private function load_admin_dependencies(): void { | |
| 67 | - new AdminAssets(); | |
| 68 | - new AdminHooks( $this->utils ); | |
| 69 | - new AdminMenu(); | |
| 70 | - new AdminRedirects(); | |
| 71 | - new AdminRedirects(); | |
| 72 | - } | |
| 54 | + private function load_admin_dependencies(): void { | |
| 55 | + new AdminAssets(); | |
| 56 | + new AdminHooks(); | |
| 57 | + new AdminMenu(); | |
| 58 | + new AdminRedirects(); | |
| 59 | + new AdminRedirects(); | |
| 60 | + new AdminAjax(); | |
| 61 | + } | |
| 73 | 62 | |
| 74 | - private function load_public_dependencies(): void { | |
| 63 | + private function load_public_dependencies(): void { | |
| 64 | + new PreviewAssets(); | |
| 65 | + new Hooks(); | |
| 75 | 66 | |
| 76 | - $client = new Client( | |
| 77 | - 'https://wh-wordpress-proxy-api.hostinger.io', | |
| 78 | - array( | |
| 79 | - Config::TOKEN_HEADER => $this->utils->getApiToken(), | |
| 80 | - Config::DOMAIN_HEADER => $this->utils->getHostInfo(), | |
| 81 | - ) | |
| 82 | - ); | |
| 83 | - | |
| 84 | - new JobInitializer( new Proxy( $client, $this->utils ) ); | |
| 85 | - new Hooks(); | |
| 86 | - | |
| 87 | 67 | $plugin_settings = new PluginSettings(); |
| 88 | 68 | |
| 89 | - new LlmsTxtGenerator( $plugin_settings, new LlmsTxtFileHelper(), new LlmsTxtParser() ); | |
| 90 | - | |
| 91 | 69 | $settings_routes = new SettingsRoutes( $plugin_settings ); |
| 92 | - $routes = new Routes( $settings_routes ); | |
| 70 | + $routes = new Routes( $settings_routes ); | |
| 93 | 71 | $routes->init(); |
| 94 | - } | |
| 72 | + } | |
| 95 | 73 | } |