PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / llms-txt / application / health-check / file-check.php

file-check.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/llms-txt/application/health-check/file-check.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Llms_Txt\Application\Health_Check;
5
6 use Yoast\WP\SEO\Helpers\Options_Helper;
7 use Yoast\WP\SEO\Llms_Txt\User_Interface\Health_Check\File_Reports;
8 use Yoast\WP\SEO\Services\Health_Check\Health_Check;
9
10 /**
11 * Fails when the llms.txt file fails to be generated.
12 */
13 class File_Check extends Health_Check {
14
15 /**
16 * Runs the health check.
17 *
18 * @var File_Runner
19 */
20 private $runner;
21
22 /**
23 * Generates WordPress-friendly health check results.
24 *
25 * @var File_Reports
26 */
27 private $reports;
28
29 /**
30 * The Options_Helper instance.
31 *
32 * @var Options_Helper
33 */
34 private $options_helper;
35
36 /**
37 * Constructor.
38 *
39 * @param File_Runner $runner The object that implements the actual health check.
40 * @param File_Reports $reports The object that generates WordPress-friendly results.
41 * @param Options_Helper $options_helper The options helper.
42 */
43 public function __construct(
44 File_Runner $runner,
45 File_Reports $reports,
46 Options_Helper $options_helper
47 ) {
48 $this->runner = $runner;
49 $this->reports = $reports;
50 $this->options_helper = $options_helper;
51
52 $this->reports->set_test_identifier( $this->get_test_identifier() );
53 $this->set_runner( $this->runner );
54 }
55
56 /**
57 * Returns the WordPress-friendly health check result.
58 *
59 * @return string[] The WordPress-friendly health check result.
60 */
61 protected function get_result() {
62 if ( $this->runner->is_successful() ) {
63 return $this->reports->get_success_result();
64 }
65
66 return $this->reports->get_generation_failure_result( $this->runner->get_generation_failure_reason() );
67 }
68
69 /**
70 * Returns true when the llms.txt feature is disabled.
71 *
72 * @return bool Whether the health check should be excluded from the results.
73 */
74 public function is_excluded() {
75 return $this->options_helper->get( 'enable_llms_txt', false ) !== true;
76 }
77 }
78