PluginProbe
Hostinger Tools / 3.0.78
Hostinger Tools v3.0.78
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 2.0.1 All 109 releases
← All changes | includes/LlmsTxtGenerator/LlmsTxtGenerator.php +5 -6 3.0.66 → 3.0.78 View file →
@@ -3,8 +3,9 @@
3 3 namespace Hostinger\LlmsTxtGenerator;
4 4
5 5 use Hostinger\Admin\Jobs\LlmsTxtInjectContentJob;
6 6 use Hostinger\Admin\PluginSettings;
7 +use Hostinger\Helper;
7 8
8 9 defined( 'ABSPATH' ) || exit;
9 10
10 11 class LlmsTxtGenerator {
@@ -9,9 +10,8 @@
9 10
10 11 class LlmsTxtGenerator {
11 12
12 13 public const HOSTINGER_LLMSTXT_SIGNATURE = '[comment]: # (Generated by Hostinger Tools Plugin)';
13 - protected const UTF8_BOM = "\xEF\xBB\xBF";
14 14 public const HOSTINGER_LLMSTXT_SUPPORTED_POST_TYPES = array(
15 15 'post' => 'Posts',
16 16 'page' => 'Pages',
17 17 'product' => 'Products',
@@ -47,8 +47,10 @@
47 47 $this->generate();
48 48 }
49 49
50 50 public function init(): void {
51 + $this->init_hooks();
52 +
51 53 if ( wp_doing_ajax() || wp_doing_cron() || ! current_user_can( 'manage_options' ) ) {
52 54 return;
53 55 }
54 56
@@ -56,10 +58,8 @@
56 58
57 59 if ( $settings->get_enable_llms_txt() && ! $this->file_helper->llmstxt_file_exists() ) {
58 60 $this->generate();
59 61 }
60 -
61 - $this->init_hooks();
62 62 }
63 63
64 64 public function on_settings_update( bool $is_enabled ): void {
65 65 if ( $is_enabled ) {
@@ -85,10 +85,9 @@
85 85 }
86 86 }
87 87
88 88 public function get_content(): string {
89 - $content = self::UTF8_BOM;
90 - $content .= $this->parser->inject_title();
89 + $content = $this->parser->inject_title();
91 90 $content .= $this->parser->inject_site_description();
92 91 $content .= $this->parser->inject_items( $this->parser->get_by_post_type( 'post' ), 'Posts' );
93 92 $content .= $this->parser->inject_items( $this->parser->get_by_post_type( 'page' ), 'Pages' );
94 93 $content .= $this->maybe_inject_woocommerce_products();
@@ -142,9 +141,9 @@
142 141 return array_key_exists( $post_type, self::HOSTINGER_LLMSTXT_SUPPORTED_POST_TYPES );
143 142 }
144 143
145 144 protected function is_woocommerce_active(): bool {
146 - return ( is_null( $this->woocommerce_status ) && is_plugin_active( 'woocommerce/woocommerce.php' ) ) || $this->woocommerce_status === 'active';
145 + return ( is_null( $this->woocommerce_status ) && Helper::is_plugin_active( 'woocommerce/woocommerce' ) ) || $this->woocommerce_status === 'active';
147 146 }
148 147
149 148 protected function maybe_inject_woocommerce_products(): string {
150 149 if ( ! $this->is_woocommerce_active() ) {