wordpress-seo
/
src
/
task-list
/
application
/
tasks
/
child-tasks
/
improve-default-meta-descriptions-child.php
improve-default-meta-descriptions-child.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.7, at src/task-list/application/tasks/child-tasks/improve-default-meta-descriptions-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\Data\Meta_Description_Content_Item_Data; |
| 8 | use Yoast\WP\SEO\Task_List\Domain\Tasks\Abstract_Child_Task; |
| 9 | use Yoast\WP\SEO\Task_List\Domain\Tasks\Parent_Task_Interface; |
| 10 | |
| 11 | /** |
| 12 | * Represents a child task for improving default meta descriptions. |
| 13 | */ |
| 14 | class Improve_Default_Meta_Descriptions_Child extends Abstract_Child_Task { |
| 15 | |
| 16 | use Child_Task_Trait { |
| 17 | Child_Task_Trait::__construct as private base_construct; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Holds the duration. |
| 22 | * |
| 23 | * @var int |
| 24 | */ |
| 25 | protected $duration = 5; |
| 26 | |
| 27 | /** |
| 28 | * The meta description content item data. |
| 29 | * |
| 30 | * @var Meta_Description_Content_Item_Data |
| 31 | */ |
| 32 | private $meta_description_data; |
| 33 | |
| 34 | /** |
| 35 | * Constructs the task. |
| 36 | * |
| 37 | * @param Parent_Task_Interface $parent_task The parent task. |
| 38 | * @param Meta_Description_Content_Item_Data $content_item_data The content item data. |
| 39 | */ |
| 40 | public function __construct( |
| 41 | Parent_Task_Interface $parent_task, |
| 42 | Meta_Description_Content_Item_Data $content_item_data |
| 43 | ) { |
| 44 | $this->base_construct( $parent_task, $content_item_data ); |
| 45 | $this->meta_description_data = $content_item_data; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns whether this task is completed. |
| 50 | * |
| 51 | * A child task is completed when the post has a custom meta description. |
| 52 | * |
| 53 | * @return bool Whether this task is completed. |
| 54 | */ |
| 55 | public function get_is_completed(): bool { |
| 56 | return $this->meta_description_data->has_description(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the task's priority. |
| 61 | * |
| 62 | * @return string |
| 63 | */ |
| 64 | public function get_priority(): string { |
| 65 | return 'medium'; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns the task's call to action entry. |
| 70 | * |
| 71 | * @return Call_To_Action_Entry|null |
| 72 | */ |
| 73 | public function get_call_to_action(): ?Call_To_Action_Entry { |
| 74 | return new Call_To_Action_Entry( |
| 75 | \__( 'Open editor', 'wordpress-seo' ), |
| 76 | 'link', |
| 77 | $this->get_link(), |
| 78 | ); |
| 79 | } |
| 80 | } |
| 81 |