• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 4d884e66ab613a9f074e39d9ffc009550b009bc9

10 Feb 2026 07:17AM UTC coverage: 50.237%. First build
4d884e66ab613a9f074e39d9ffc009550b009bc9

push

github

web-flow
Merge pull request #22947 from Yoast/1053-add-improve-your-contents-readability-task

1053 add improve your contents readability task

96 of 144 new or added lines in 11 files covered. (66.67%)

18242 of 36312 relevant lines covered (50.24%)

3.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/src/task-list/application/tasks/improve-content-readability.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Task_List\Application\Tasks;
4

5
use Yoast\WP\SEO\Editors\Application\Analysis_Features\Enabled_Analysis_Features_Repository;
6
use Yoast\WP\SEO\Editors\Framework\Readability_Analysis;
7
use Yoast\WP\SEO\Helpers\Indexable_Helper;
8
use Yoast\WP\SEO\Task_List\Application\Tasks\Child_Tasks\Improve_Content_Readability_Child;
9
use Yoast\WP\SEO\Task_List\Domain\Components\Call_To_Action_Entry;
10
use Yoast\WP\SEO\Task_List\Domain\Components\Copy_Set;
11
use Yoast\WP\SEO\Task_List\Domain\Tasks\Abstract_Post_Type_Parent_Task;
12
use Yoast\WP\SEO\Task_List\Domain\Tasks\Child_Task_Interface;
13
use Yoast\WP\SEO\Task_List\Infrastructure\Indexables\Recent_Content_Indexable_Collector;
14

15
/**
16
 * Represents the task for improving content readability.
17
 */
18
class Improve_Content_Readability extends Abstract_Post_Type_Parent_Task {
19

20
        /**
21
         * The default maximum number of content items to retrieve.
22
         *
23
         * @var int
24
         */
25
        public const DEFAULT_LIMIT = 100;
26

27
        /**
28
         * Holds the id.
29
         *
30
         * @var string
31
         */
32
        protected $id = 'improve-content-readability';
33

34
        /**
35
         * Holds the priority.
36
         *
37
         * @var string
38
         */
39
        protected $priority = 'medium';
40

41
        /**
42
         * Holds the recent content indexable collector.
43
         *
44
         * @var Recent_Content_Indexable_Collector
45
         */
46
        private $recent_content_indexable_collector;
47

48
        /**
49
         * Holds the indexable helper.
50
         *
51
         * @var Indexable_Helper
52
         */
53
        private $indexable_helper;
54

55
        /**
56
         * Holds the enabled analysis features repository.
57
         *
58
         * @var Enabled_Analysis_Features_Repository
59
         */
60
        private $enabled_analysis_features_repository;
61

62
        /**
63
         * Constructs the task.
64
         *
65
         * @param Recent_Content_Indexable_Collector   $recent_content_indexable_collector   The recent content indexable collector.
66
         * @param Indexable_Helper                     $indexable_helper                     The indexable helper.
67
         * @param Enabled_Analysis_Features_Repository $enabled_analysis_features_repository The enabled analysis features repository.
68
         */
69
        public function __construct(
2✔
70
                Recent_Content_Indexable_Collector $recent_content_indexable_collector,
71
                Indexable_Helper $indexable_helper,
72
                Enabled_Analysis_Features_Repository $enabled_analysis_features_repository
73
        ) {
74
                $this->recent_content_indexable_collector   = $recent_content_indexable_collector;
2✔
75
                $this->indexable_helper                     = $indexable_helper;
2✔
76
                $this->enabled_analysis_features_repository = $enabled_analysis_features_repository;
2✔
77
        }
78

79
        /**
80
         * Returns the task's link.
81
         *
82
         * @return string|null
83
         */
NEW
84
        public function get_link(): ?string {
×
NEW
85
                return null;
×
86
        }
87

88
        /**
89
         * Returns the task's call to action entry.
90
         *
91
         * @return Call_To_Action_Entry|null
92
         */
NEW
93
        public function get_call_to_action(): ?Call_To_Action_Entry {
×
NEW
94
                return null;
×
95
        }
96

97
        /**
98
         * Returns the task's copy set.
99
         *
100
         * @return Copy_Set
101
         */
102
        public function get_copy_set(): Copy_Set {
6✔
103
                return new Copy_Set(
6✔
104
                        // @TODO: we are going to reference the post type in the title in a later task.
105
                        \__( 'Improve your content\'s readability', 'wordpress-seo' ),
6✔
106
                        \sprintf(
6✔
107
                                /* translators: %1$s expands to an opening p tag, %2$s and %4$s expand to a closing p tag, %3$s expands to an opening p tag and opening strong tag, %5$s expands to a closing strong tag, %6$s expands to an opening strong tag, %7$s expands to a closing strong tag and closing p tag */
108
                                \__( '%1$sImproving your content\'s readability makes it easier for your audience to understand and engage with your content. Follow the instructions displayed in the readability analysis to improve your content\'s readability.%2$s%3$sPro tip%5$s: Use %6$sAI Optimize%7$s to speed up the process with high-quality, actionable suggestions.%4$s', 'wordpress-seo' ),
6✔
109
                                '<p>',
6✔
110
                                '</p>',
6✔
111
                                '<p><strong>',
6✔
112
                                '</p>',
6✔
113
                                '</strong>',
6✔
114
                                '<strong>',
6✔
115
                                '</strong>'
6✔
116
                        )
6✔
117
                );
6✔
118
        }
119

120
        /**
121
         * Populates the child tasks by querying content modified in the last two months.
122
         *
123
         * @return Child_Task_Interface[]
124
         */
125
        public function populate_child_tasks(): array {
6✔
126
                $post_type = $this->get_post_type();
6✔
127

128
                if ( empty( $post_type ) ) {
6✔
129
                        return [];
2✔
130
                }
131

132
                $two_months_ago = \gmdate( 'Y-m-d H:i:s', \strtotime( '-2 months' ) );
4✔
133

134
                $recent_content_items = $this->recent_content_indexable_collector->get_recent_content_with_readability_scores(
4✔
135
                        $post_type,
4✔
136
                        $two_months_ago,
4✔
137
                        self::DEFAULT_LIMIT
4✔
138
                );
4✔
139

140
                $child_tasks = [];
4✔
141
                foreach ( $recent_content_items as $content_item_score_data ) {
4✔
142
                        $child_tasks[] = new Improve_Content_Readability_Child(
2✔
143
                                $this,
2✔
144
                                $content_item_score_data
2✔
145
                        );
2✔
146
                }
147

148
                return $child_tasks;
4✔
149
        }
150

151
        /**
152
         * Returns whether the task is valid.
153
         *
154
         * @return bool
155
         */
156
        public function is_valid(): bool {
8✔
157
                if ( ! $this->indexable_helper->should_index_indexables() ) {
8✔
158
                        return false;
2✔
159
                }
160

161
                $enabled_features = $this->enabled_analysis_features_repository->get_enabled_features()->to_array();
6✔
162
                if ( ! isset( $enabled_features[ Readability_Analysis::NAME ] ) || $enabled_features[ Readability_Analysis::NAME ] === false ) {
6✔
163
                        return false;
4✔
164
                }
165

166
                return true;
2✔
167
        }
168
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc