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 / task-list / application / tasks / enable-llms-txt.php

enable-llms-txt.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/task-list/application/tasks/enable-llms-txt.php

122 lines 2.6 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 -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Task_List\Application\Tasks;
5
6 use Yoast\WP\SEO\Helpers\Options_Helper;
7 use Yoast\WP\SEO\Task_List\Domain\Components\Call_To_Action_Entry;
8 use Yoast\WP\SEO\Task_List\Domain\Components\Copy_Set;
9 use Yoast\WP\SEO\Task_List\Domain\Exceptions\Complete_LLMS_Task_Exception;
10 use Yoast\WP\SEO\Task_List\Domain\Tasks\Abstract_Task;
11 use Yoast\WP\SEO\Task_List\Domain\Tasks\Completeable_Task_Interface;
12
13 /**
14 * Represents the task for the enabling the llms.txt file.
15 */
16 class Enable_Llms_Txt extends Abstract_Task implements Completeable_Task_Interface {
17
18 /**
19 * Holds the id.
20 *
21 * @var string
22 */
23 protected $id = 'enable-llms-txt';
24
25 /**
26 * Holds the priority.
27 *
28 * @var string
29 */
30 protected $priority = 'medium';
31
32 /**
33 * Holds the duration.
34 *
35 * @var int
36 */
37 protected $duration = 1;
38
39 /**
40 * Holds the options helper.
41 *
42 * @var Options_Helper
43 */
44 private $options_helper;
45
46 /**
47 * Constructs the task.
48 *
49 * @param Options_Helper $options_helper The options helper.
50 */
51 public function __construct( Options_Helper $options_helper ) {
52 $this->options_helper = $options_helper;
53 }
54
55 /**
56 * Returns whether this task is completed.
57 *
58 * @return bool Whether this task is completed.
59 */
60 public function get_is_completed(): bool {
61 return $this->options_helper->get( 'enable_llms_txt', false );
62 }
63
64 /**
65 * Returns the task's link.
66 *
67 * @return string|null
68 */
69 public function get_link(): ?string {
70 return null;
71 }
72
73 /**
74 * Completes a task.
75 *
76 * @return void
77 *
78 * @throws Complete_LLMS_Task_Exception If the option could not be set.
79 */
80 public function complete_task(): void {
81 $result = $this->options_helper->set( 'enable_llms_txt', true );
82
83 if ( ! $result ) {
84 throw new Complete_LLMS_Task_Exception();
85 }
86 }
87
88 /**
89 * Returns the task's call to action entry.
90 *
91 * @return Call_To_Action_Entry|null
92 */
93 public function get_call_to_action(): ?Call_To_Action_Entry {
94 return new Call_To_Action_Entry(
95 \__( 'Enable llms.txt', 'wordpress-seo' ),
96 'default',
97 $this->get_link(),
98 );
99 }
100
101 /**
102 * Returns the task's copy set.
103 *
104 * @return string|null
105 */
106 public function get_copy_set(): Copy_Set {
107 return new Copy_Set(
108 \__( 'Create an llms.txt file', 'wordpress-seo' ),
109 '<p>' . \__( 'Without llms.txt, AI platforms may not know how to treat your content. Enabling it helps communicate your preferences in a clearer way to AI tools.', 'wordpress-seo' ) . '</p>',
110 );
111 }
112
113 /**
114 * Returns whether the task is valid.
115 *
116 * @return bool
117 */
118 public function is_valid(): bool {
119 return ! \is_multisite();
120 }
121 }
122