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

Yoast / wordpress-seo / 55dec9a111eaff1b7fe75cefc941ff84009561d0

16 Feb 2026 08:03AM UTC coverage: 53.608% (+0.6%) from 52.986%
55dec9a111eaff1b7fe75cefc941ff84009561d0

Pull #22972

github

leonidasmi
Merge trunk
Pull Request #22972: Add tasks about the SEO and readability of recent posts

8934 of 16506 branches covered (54.13%)

Branch coverage included in aggregate %.

391 of 600 new or added lines in 40 files covered. (65.17%)

1 existing line in 1 file now uncovered.

33402 of 62467 relevant lines covered (53.47%)

47894.4 hits per line

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

91.49
/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
                $post_type = \get_post_type_object( $this->get_post_type() );
6✔
104

105
                return new Copy_Set(
6✔
106
                        /* translators: %1$s expands to the post type label this task is about */
107
                        \sprintf( \__( 'Improve the readability of your content type: %1$s', 'wordpress-seo' ), $post_type->label ),
6✔
108
                        \sprintf(
6✔
109
                                /* 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 */
110
                                \__( '%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✔
111
                                '<p>',
6✔
112
                                '</p>',
6✔
113
                                '<p><strong>',
6✔
114
                                '</p>',
6✔
115
                                '</strong>',
6✔
116
                                '<strong>',
6✔
117
                                '</strong>'
6✔
118
                        )
6✔
119
                );
6✔
120
        }
121

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

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

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

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

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

150
                return $child_tasks;
4✔
151
        }
152

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

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

168
                return true;
2✔
169
        }
170
}
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