wordpress-seo
/
src
/
task-list
/
application
/
tasks
/
child-tasks
/
improve-content-readability-child.php
improve-content-readability-child.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/task-list/application/tasks/child-tasks/improve-content-readability-child.php
| 1 | <?php |
| 2 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 3 | // phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded |
| 4 | namespace Yoast\WP\SEO\Task_List\Application\Tasks\Child_Tasks; |
| 5 | |
| 6 | use Yoast\WP\SEO\Task_List\Domain\Components\Call_To_Action_Entry; |
| 7 | use Yoast\WP\SEO\Task_List\Domain\Components\Score_Task_Analyzer; |
| 8 | use Yoast\WP\SEO\Task_List\Domain\Components\Task_Analyzer_Interface; |
| 9 | use Yoast\WP\SEO\Task_List\Domain\Tasks\Abstract_Child_Task; |
| 10 | |
| 11 | /** |
| 12 | * Represents the child task for improving content readability. |
| 13 | */ |
| 14 | class Improve_Content_Readability_Child extends Abstract_Child_Task { |
| 15 | |
| 16 | use Content_Score_Child_Task_Trait; |
| 17 | |
| 18 | /** |
| 19 | * Holds the duration. |
| 20 | * |
| 21 | * @var int |
| 22 | */ |
| 23 | protected $duration = 10; |
| 24 | |
| 25 | /** |
| 26 | * Returns the task's call to action entry. |
| 27 | * |
| 28 | * @return Call_To_Action_Entry|null |
| 29 | */ |
| 30 | public function get_call_to_action(): ?Call_To_Action_Entry { |
| 31 | $link = $this->get_link(); |
| 32 | if ( $link !== null ) { |
| 33 | $link = \add_query_arg( 'yoast-tab', 'readability', $link ); |
| 34 | } |
| 35 | |
| 36 | return new Call_To_Action_Entry( |
| 37 | \__( 'Improve readability', 'wordpress-seo' ), |
| 38 | 'link', |
| 39 | $link, |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Returns the task's analyzer component. |
| 45 | * |
| 46 | * @return Task_Analyzer_Interface|null |
| 47 | */ |
| 48 | public function get_analyzer(): ?Task_Analyzer_Interface { |
| 49 | $result_labels = [ |
| 50 | 'good' => \__( 'Good', 'wordpress-seo' ), |
| 51 | 'ok' => \__( 'OK', 'wordpress-seo' ), |
| 52 | 'bad' => \__( 'Needs improvement', 'wordpress-seo' ), |
| 53 | ]; |
| 54 | |
| 55 | $result_descriptions = [ |
| 56 | 'good' => \__( 'Your content is clear and easy to read. This helps your audience stay engaged with your message.', 'wordpress-seo' ), |
| 57 | 'ok' => \__( 'Your content is readable but could be clearer. Consider simplifying a few sentences to improve the overall flow.', 'wordpress-seo' ), |
| 58 | 'bad' => \__( 'Your content is currently difficult to read. Check the analysis for specific ways to simplify your writing for a better user experience.', 'wordpress-seo' ), |
| 59 | ]; |
| 60 | |
| 61 | $result = $this->content_item_score_data->get_score(); |
| 62 | |
| 63 | return new Score_Task_Analyzer( |
| 64 | \__( 'Readability', 'wordpress-seo' ), |
| 65 | $result, |
| 66 | $result_labels[ $result ], |
| 67 | $result_descriptions[ $result ], |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 |