| @@ -5,10 +5,17 @@ | ||
| 5 | 5 | |
| 6 | 6 | use Hostinger\Admin\PluginSettings; |
| 7 | 7 | use Hostinger\Admin\Jobs\JobInitializer; |
| 8 | 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; | |
| 9 | 13 | use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper; |
| 14 | +use Hostinger\LlmsTxtGenerator\LlmsTxtHeadLink; | |
| 10 | 15 | use Hostinger\LlmsTxtGenerator\LlmsTxtParser; |
| 16 | +use Hostinger\LlmsTxtGenerator\LlmsTxtSummaryProvider; | |
| 17 | +use Hostinger\Rest\CacheRoutes; | |
| 11 | 18 | use Hostinger\Rest\Routes; |
| 12 | 19 | use Hostinger\Rest\SettingsRoutes; |
| 13 | 20 | use Hostinger\Admin\Assets as AdminAssets; |
| 14 | 21 | use Hostinger\Admin\Hooks as AdminHooks; |
| @@ -73,9 +80,9 @@ | ||
| 73 | 80 | |
| 74 | 81 | private function load_public_dependencies(): void { |
| 75 | 82 | |
| 76 | 83 | $client = new Client( |
| 77 | - 'https://wh-wordpress-proxy-api.hostinger.io', | |
| 84 | + 'https://' . HOSTINGER_PROXY_API_HOST, | |
| 78 | 85 | array( |
| 79 | 86 | Config::TOKEN_HEADER => $this->utils->getApiToken(), |
| 80 | 87 | Config::DOMAIN_HEADER => $this->utils->getHostInfo(), |
| 81 | 88 | ) |
| @@ -80,16 +87,36 @@ | ||
| 80 | 87 | Config::DOMAIN_HEADER => $this->utils->getHostInfo(), |
| 81 | 88 | ) |
| 82 | 89 | ); |
| 83 | 90 | |
| 84 | - new JobInitializer( new Proxy( $client, $this->utils ) ); | |
| 91 | + $llms_txt_parser = new LlmsTxtParser( new LlmsTxtSummaryProvider() ); | |
| 92 | + | |
| 93 | + new JobInitializer( new Proxy( $client, $this->utils ), $llms_txt_parser ); | |
| 85 | 94 | new Hooks(); |
| 86 | 95 | |
| 87 | - $plugin_settings = new PluginSettings(); | |
| 96 | + $plugin_settings = new PluginSettings(); | |
| 97 | + $llms_txt_file_helper = new LlmsTxtFileHelper(); | |
| 88 | 98 | |
| 89 | - new LlmsTxtGenerator( $plugin_settings, new LlmsTxtFileHelper(), new LlmsTxtParser() ); | |
| 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' ); | |
| 90 | 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 | + | |
| 91 | 109 | $settings_routes = new SettingsRoutes( $plugin_settings ); |
| 92 | - $routes = new Routes( $settings_routes ); | |
| 110 | + $cache_routes = new CacheRoutes( $cache_purger ); | |
| 111 | + $routes = new Routes( $settings_routes, $cache_routes ); | |
| 93 | 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 | + ); | |
| 94 | 121 | } |
| 95 | 122 | } |