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/LlmsTxtGenerator/LlmsTxtGenerator.php +25 -0 3.0.77 → 3.0.79 View file →
@@ -10,8 +10,9 @@
10 10
11 11 class LlmsTxtGenerator {
12 12
13 13 public const HOSTINGER_LLMSTXT_SIGNATURE = '[comment]: # (Generated by Hostinger Tools Plugin)';
14 + public const HOSTINGER_LLMSTXT_GENERATED_VERSION = 'hostinger_llmstxt_generated_version';
14 15 public const HOSTINGER_LLMSTXT_SUPPORTED_POST_TYPES = array(
15 16 'post' => 'Posts',
16 17 'page' => 'Pages',
17 18 'product' => 'Products',
@@ -60,8 +61,21 @@
60 61 $this->generate();
61 62 }
62 63 }
63 64
65 + public function maybe_regenerate_after_update(): void {
66 + if ( wp_doing_ajax() || wp_doing_cron() || ! current_user_can( 'manage_options' ) ) {
67 + return;
68 + }
69 +
70 + if ( $this->has_generated_current_version() ) {
71 + return;
72 + }
73 +
74 + $this->record_generated_version();
75 + $this->generate();
76 + }
77 +
64 78 public function on_settings_update( bool $is_enabled ): void {
65 79 if ( $is_enabled ) {
66 80 $this->generate();
67 81 } else {
@@ -124,8 +138,11 @@
124 138 return;
125 139 }
126 140
127 141 $this->file_helper->create( $this->get_content() );
142 +
143 + $this->record_generated_version();
144 +
128 145 do_action( LlmsTxtInjectContentJob::JOB_NAME, array( 'post_type' => 'post' ) );
129 146 do_action( LlmsTxtInjectContentJob::JOB_NAME, array( 'post_type' => 'page' ) );
130 147
131 148 if ( $this->is_woocommerce_active() ) {
@@ -134,8 +151,16 @@
134 151 }
135 152
136 153 protected function delete(): void {
137 154 $this->file_helper->delete();
155 + }
156 +
157 + protected function has_generated_current_version(): bool {
158 + return get_option( self::HOSTINGER_LLMSTXT_GENERATED_VERSION ) === HOSTINGER_WORDPRESS_PLUGIN_VERSION;
159 + }
160 +
161 + protected function record_generated_version(): void {
162 + update_option( self::HOSTINGER_LLMSTXT_GENERATED_VERSION, HOSTINGER_WORDPRESS_PLUGIN_VERSION );
138 163 }
139 164
140 165 protected function is_post_type_supported( string $post_type ): bool {
141 166 return array_key_exists( $post_type, self::HOSTINGER_LLMSTXT_SUPPORTED_POST_TYPES );