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

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

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

0.0
/src/presenters/title-presenter.php
1
<?php
2

3
namespace Yoast\WP\SEO\Presenters;
4

5
use Yoast\WP\SEO\Presentations\Indexable_Presentation;
6

7
/**
8
 * Presenter class for the document title.
9
 */
10
class Title_Presenter extends Abstract_Indexable_Tag_Presenter {
11

12
        /**
13
         * The tag key name.
14
         *
15
         * @var string
16
         */
17
        protected $key = 'title';
18

19
        /**
20
         * The tag format including placeholders.
21
         *
22
         * @var string
23
         */
24
        protected $tag_format = '<title>%s</title>';
25

26
        /**
27
         * The method of escaping to use.
28
         *
29
         * @var string
30
         */
31
        protected $escaping = 'html';
32

33
        /**
34
         * Gets the raw value of a presentation.
35
         *
36
         * @return string The raw value.
37
         */
38
        public function get() {
39
                // This ensures backwards compatibility with other plugins using this filter as well.
40
                \add_filter( 'pre_get_document_title', [ $this, 'get_title' ], 15 );
×
41
                $title = \wp_get_document_title();
×
42
                \remove_filter( 'pre_get_document_title', [ $this, 'get_title' ], 15 );
×
43
                return $title;
×
44
        }
45

46
        /**
47
         * Returns a tag in the head.
48
         *
49
         * @return string The tag.
50
         */
51
        public function present() {
52
                $value = $this->get();
×
53

54
                if ( \is_string( $value ) && $value !== '' ) {
×
55
                        return \sprintf( $this->tag_format, $this->escape_value( $value ) );
×
56
                }
57

58
                return '';
×
59
        }
60

61
        /**
62
         * Returns the presentation title.
63
         *
64
         * @return string The title.
65
         */
66
        public function get_title() {
67
                $title = $this->replace_vars( $this->presentation->title );
×
68

69
                /**
70
                 * Filter: 'wpseo_title' - Allow changing the Yoast SEO generated title.
71
                 *
72
                 * @api string $title The title.
73
                 *
74
                 * @param Indexable_Presentation $presentation The presentation of an indexable.
75
                 */
76
                $title = \apply_filters( 'wpseo_title', $title, $this->presentation );
×
77
                $title = $this->helpers->string->strip_all_tags( $title );
×
78
                return \trim( $title );
×
79
        }
80
}
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