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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

66.67
/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() {
2✔
39
                // This ensures backwards compatibility with other plugins using this filter as well.
40
                \add_filter( 'pre_get_document_title', [ $this, 'get_title' ], 15 );
2✔
41
                $title = \wp_get_document_title();
2✔
42
                \remove_filter( 'pre_get_document_title', [ $this, 'get_title' ], 15 );
2✔
43
                return $title;
2✔
44
        }
45

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

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

58
                return '';
2✔
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