PluginProbe
Hostinger Tools / 3.0.79
Hostinger Tools v3.0.79
3.0.79 3.0.78 3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 All 110 releases
hostinger / includes / Bootstrap.php

Bootstrap.php in Hostinger Tools 3.0.79, at includes/Bootstrap.php

123 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger;
4
5
6 use Hostinger\Admin\PluginSettings;
7 use Hostinger\Admin\Jobs\JobInitializer;
8 use Hostinger\Admin\Proxy;
9 use Hostinger\Cdn\CacheClient;
10 use Hostinger\Cdn\CachePurger;
11 use Hostinger\Cdn\LiteSpeedHooks;
12 use Hostinger\Cdn\SoftwareIdResolver;
13 use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper;
14 use Hostinger\LlmsTxtGenerator\LlmsTxtHeadLink;
15 use Hostinger\LlmsTxtGenerator\LlmsTxtParser;
16 use Hostinger\LlmsTxtGenerator\LlmsTxtSummaryProvider;
17 use Hostinger\Rest\CacheRoutes;
18 use Hostinger\Rest\Routes;
19 use Hostinger\Rest\SettingsRoutes;
20 use Hostinger\Admin\Assets as AdminAssets;
21 use Hostinger\Admin\Hooks as AdminHooks;
22 use Hostinger\Admin\Menu as AdminMenu;
23 use Hostinger\Admin\Redirects as AdminRedirects;
24 use Hostinger\WpHelper\Config;
25 use Hostinger\WpHelper\Requests\Client;
26 use Hostinger\WpHelper\Utils;
27 use Hostinger\LlmsTxtGenerator\LlmsTxtGenerator;
28
29 defined( 'ABSPATH' ) || exit;
30
31 class Bootstrap {
32
33 protected Loader $loader;
34 protected Utils $utils;
35 protected Config $config;
36
37 public function __construct() {
38 $this->loader = new Loader();
39 $this->utils = new Utils();
40 $this->config = new Config();
41 }
42
43 public function run(): void {
44 $this->load_dependencies();
45 $this->set_locale();
46 $this->loader->run();
47 }
48
49 private function load_dependencies(): void {
50 $this->load_public_dependencies();
51
52 if ( is_admin() ) {
53 $this->load_admin_dependencies();
54 }
55
56 if ( defined( 'WP_CLI' ) && WP_CLI ) {
57 new Cli();
58 }
59
60 $plugin_settings = new PluginSettings();
61 $plugin_options = $plugin_settings->get_plugin_settings();
62
63 if ( $plugin_options->get_maintenance_mode() ) {
64 require_once HOSTINGER_ABSPATH . 'includes/ComingSoon.php';
65 }
66 }
67
68 private function set_locale() {
69 $plugin_i18n = new I18n();
70 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
71 }
72
73 private function load_admin_dependencies(): void {
74 new AdminAssets();
75 new AdminHooks( $this->utils );
76 new AdminMenu();
77 new AdminRedirects();
78 new AdminRedirects();
79 }
80
81 private function load_public_dependencies(): void {
82
83 $client = new Client(
84 'https://' . HOSTINGER_PROXY_API_HOST,
85 array(
86 Config::TOKEN_HEADER => $this->utils->getApiToken(),
87 Config::DOMAIN_HEADER => $this->utils->getHostInfo(),
88 )
89 );
90
91 $llms_txt_parser = new LlmsTxtParser( new LlmsTxtSummaryProvider() );
92
93 new JobInitializer( new Proxy( $client, $this->utils ), $llms_txt_parser );
94 new Hooks();
95
96 $plugin_settings = new PluginSettings();
97 $llms_txt_file_helper = new LlmsTxtFileHelper();
98
99 $llms_txt_generator = new LlmsTxtGenerator( $plugin_settings, $llms_txt_file_helper, $llms_txt_parser );
100 $this->loader->add_action( 'wp_loaded', $llms_txt_generator, 'maybe_regenerate_after_update' );
101
102 $llms_txt_head_link = new LlmsTxtHeadLink( $plugin_settings, $llms_txt_file_helper );
103 $this->loader->add_action( 'wp_head', $llms_txt_head_link, 'render' );
104
105 $cache_purger = $this->build_cache_purger( $client );
106
107 new LiteSpeedHooks( $cache_purger, $this->utils );
108
109 $settings_routes = new SettingsRoutes( $plugin_settings );
110 $cache_routes = new CacheRoutes( $cache_purger );
111 $routes = new Routes( $settings_routes, $cache_routes );
112 $routes->init();
113 }
114
115 private function build_cache_purger( Client $client ): CachePurger {
116 return new CachePurger(
117 new CacheClient( $client ),
118 new SoftwareIdResolver( $client ),
119 $this->utils
120 );
121 }
122 }
123