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

Yoast / wordpress-seo / 8218b111533b92ec47f94130a94bcd0102263a45

01 Dec 2025 09:48AM UTC coverage: 53.092%. First build
8218b111533b92ec47f94130a94bcd0102263a45

push

github

web-flow
Merge pull request #22759 from Yoast/feature/task-list

Feature/task list

8697 of 16050 branches covered (54.19%)

Branch coverage included in aggregate %.

98 of 605 new or added lines in 51 files covered. (16.2%)

32413 of 61381 relevant lines covered (52.81%)

46976.02 hits per line

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

0.0
/src/task-list/application/tasks/set-search-appearance-templates.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\Helpers\Options_Helper;
6
use Yoast\WP\SEO\Helpers\Route_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\Tasks\Abstract_Post_Type_Task;
10

11
/**
12
 * Represents the task for setting search appearance templates.
13
 */
14
class Set_Search_Appearance_Templates extends Abstract_Post_Type_Task {
15

16
        /**
17
         * Holds the id.
18
         *
19
         * @var string
20
         */
21
        protected $id = 'set-search-appearance-templates';
22

23
        /**
24
         * Holds the priority.
25
         *
26
         * @var string
27
         */
28
        protected $priority = 'high';
29

30
        /**
31
         * Holds the duration.
32
         *
33
         * @var int
34
         */
35
        protected $duration = 10;
36

37
        /**
38
         * Holds the post type.
39
         *
40
         * @var string
41
         */
42
        protected $post_type;
43

44
        /**
45
         * Holds the options helper.
46
         *
47
         * @var Options_Helper
48
         */
49
        private $options_helper;
50

51
        /**
52
         * Holds the route helper.
53
         *
54
         * @var Route_Helper
55
         */
56
        private $route_helper;
57

58
        /**
59
         * Constructs the task.
60
         *
61
         * @param Options_Helper $options_helper The options helper.
62
         * @param Route_Helper   $route_helper   The route helper.
63
         */
NEW
64
        public function __construct(
×
65
                Options_Helper $options_helper,
66
                Route_Helper $route_helper
67
        ) {
NEW
68
                $this->options_helper = $options_helper;
×
NEW
69
                $this->route_helper   = $route_helper;
×
70
        }
71

72
        /**
73
         * Returns whether this task is completed.
74
         *
75
         * @return bool Whether this task is completed.
76
         */
NEW
77
        public function get_is_completed(): bool {
×
NEW
78
                $post_type = \get_post_type_object( $this->get_post_type() );
×
79

80
                // First check if the SEO title has been customized.
NEW
81
                if ( $this->options_helper->get_title_default( 'title-' . $post_type->name ) !== $this->options_helper->get( 'title-' . $post_type->name ) ) {
×
NEW
82
                        return true;
×
83
                }
84

85
                // Then check if the meta description has been customized.
NEW
86
                if ( $this->options_helper->get_title_default( 'metadesc-' . $post_type->name ) !== $this->options_helper->get( 'metadesc-' . $post_type->name ) ) {
×
NEW
87
                        return true;
×
88
                }
89

NEW
90
                return false;
×
91
        }
92

93
        /**
94
         * Returns the task's link.
95
         *
96
         * @return string|null
97
         */
NEW
98
        public function get_link(): ?string {
×
NEW
99
                $post_type = \get_post_type_object( $this->get_post_type() );
×
NEW
100
                $link      = \sprintf(
×
NEW
101
                        'admin.php?page=wpseo_page_settings#/post-type/%s',
×
NEW
102
                        $this->route_helper->get_route( $post_type->name, $post_type->rewrite, $post_type->rest_base )
×
NEW
103
                );
×
104

NEW
105
                return \self_admin_url( $link );
×
106
        }
107

108
        /**
109
         * Returns the task's call to action entry.
110
         *
111
         * @return string|null
112
         */
NEW
113
        public function get_call_to_action(): Call_To_Action_Entry {
×
NEW
114
                return new Call_To_Action_Entry(
×
NEW
115
                        \__( 'Set search templates', 'wordpress-seo' ),
×
NEW
116
                        'link',
×
NEW
117
                        $this->get_link()
×
NEW
118
                );
×
119
        }
120

121
        /**
122
         * Returns the task's copy set.
123
         *
124
         * @return string|null
125
         */
NEW
126
        public function get_copy_set(): Copy_Set {
×
NEW
127
                $post_type = \get_post_type_object( $this->get_post_type() );
×
128

NEW
129
                return new Copy_Set(
×
130
                        /* translators: %1$s expands to the post type label this task is about */
NEW
131
                        \sprintf( \__( 'Set search appearance templates for your %1$s', 'wordpress-seo' ), \strtolower( $post_type->label ) ),
×
132
                        /* translators: %1$s expands to the post type name this task is about */
NEW
133
                        \sprintf( \__( 'Generic titles and descriptions make your results unclear in search. Templates ensure every %1$s has a clear, click-worthy snippet automatically.', 'wordpress-seo' ), $post_type->name ),
×
NEW
134
                        \__( 'Go to Search appearance, choose your post type, and set default title and meta description patterns.', 'wordpress-seo' )
×
NEW
135
                );
×
136
        }
137
}
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