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
← All changes | includes/Activator.php +27 -4 3.0.77 → 3.0.79 View file →
@@ -1,20 +1,43 @@
1 1 <?php
2 2
3 3 namespace Hostinger;
4 4
5 +use Hostinger\Admin\PluginSettings;
6 +use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper;
7 +use Hostinger\LlmsTxtGenerator\LlmsTxtGenerator;
8 +use Hostinger\LlmsTxtGenerator\LlmsTxtParser;
9 +use Hostinger\LlmsTxtGenerator\LlmsTxtSummaryProvider;
10 +
5 11 defined( 'ABSPATH' ) || exit;
6 12
7 13 class Activator {
8 14 public const INSTALLATION_OPTION_NAME = 'hts_new_installation';
9 - /**
10 - * @return void
11 - */
15 +
12 16 public static function activate(): void {
13 - $options = new DefaultOptions();
17 + $plugin_settings = new PluginSettings();
18 +
19 + $options = new DefaultOptions( $plugin_settings );
14 20 $options->add_options();
15 21
22 + self::generate_llms_txt( $plugin_settings );
16 23 self::update_installation_state_on_activation();
24 + }
25 +
26 + /**
27 + * The generator's own self-heal on `init` only runs for a logged-in administrator, so a site
28 + * provisioned headlessly would serve no llms.txt until someone opened wp-admin.
29 + */
30 + private static function generate_llms_txt( PluginSettings $plugin_settings ): void {
31 + $file_helper = new LlmsTxtFileHelper();
32 +
33 + if ( $file_helper->llmstxt_file_exists() ) {
34 + return;
35 + }
36 +
37 + $llms_txt_parser = new LlmsTxtParser( new LlmsTxtSummaryProvider() );
38 + $generator = new LlmsTxtGenerator( $plugin_settings, $file_helper, $llms_txt_parser );
39 + $generator->generate();
17 40 }
18 41
19 42 /**
20 43 * Saves installation state.