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

Yoast / wordpress-seo / 47c8459b21c4da54cd1b47acc2cd092c512000e8

02 Jul 2024 08:48AM UTC coverage: 55.363% (+1.3%) from 54.108%
47c8459b21c4da54cd1b47acc2cd092c512000e8

push

github

enricobattocchi
Merge branch 'refs/heads/feature/plugin-fixes' into trunk

7399 of 13400 branches covered (55.22%)

Branch coverage included in aggregate %.

294 of 357 new or added lines in 32 files covered. (82.35%)

175 existing lines in 3 files now uncovered.

29524 of 53293 relevant lines covered (55.4%)

63223.34 hits per line

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

78.57
/src/editors/framework/seo/posts/description-data-provider.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
3
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4
namespace Yoast\WP\SEO\Editors\Framework\Seo\Posts;
5

6
use Yoast\WP\SEO\Editors\Domain\Seo\Description;
7
use Yoast\WP\SEO\Editors\Domain\Seo\Seo_Plugin_Data_Interface;
8
use Yoast\WP\SEO\Editors\Framework\Seo\Description_Data_Provider_Interface;
9
use Yoast\WP\SEO\Helpers\Date_Helper;
10
use Yoast\WP\SEO\Helpers\Options_Helper;
11

12
/**
13
 * Describes if the description SEO data.
14
 */
15
class Description_Data_Provider extends Abstract_Post_Seo_Data_Provider implements Description_Data_Provider_Interface {
16

17
        /**
18
         * The date helper.
19
         *
20
         * @var Date_Helper $date_helper
21
         */
22
        private $date_helper;
23

24
        /**
25
         * The options helper.
26
         *
27
         * @var Options_Helper $options_helper
28
         */
29
        private $options_helper;
30

31
        /**
32
         * The constructor.
33
         *
34
         * @param Date_Helper    $date_helper    The date helper.
35
         * @param Options_Helper $options_helper The options helper.
36
         */
NEW
37
        public function __construct( Date_Helper $date_helper, Options_Helper $options_helper ) {
×
NEW
38
                $this->date_helper    = $date_helper;
×
NEW
39
                $this->options_helper = $options_helper;
×
40
        }
41

42
        /**
43
         * Retrieves the description template.
44
         *
45
         * @return string The description template.
46
         */
47
        public function get_description_template(): string {
4✔
48
                return $this->get_template( 'metadesc' );
4✔
49
        }
50

51
        /**
52
         * Determines the date to be displayed in the snippet preview.
53
         *
54
         * @return string
55
         */
56
        public function get_description_date(): string {
4✔
57
                return $this->date_helper->format_translated( $this->post->post_date, 'M j, Y' );
4✔
58
        }
59

60
        /**
61
         * Retrieves a template.
62
         *
63
         * @param string $template_option_name The name of the option in which the template you want to get is saved.
64
         *
65
         * @return string
66
         */
67
        private function get_template( string $template_option_name ): string {
4✔
68
                $needed_option = $template_option_name . '-' . $this->post->post_type;
4✔
69

70
                if ( $this->options_helper->get( $needed_option, '' ) !== '' ) {
4✔
71
                        return $this->options_helper->get( $needed_option );
2✔
72
                }
73

74
                return '';
2✔
75
        }
76

77
        /**
78
         * Method to return the Description domain object with SEO data.
79
         *
80
         * @return Seo_Plugin_Data_Interface The specific seo data.
81
         */
82
        public function get_data(): Seo_Plugin_Data_Interface {
4✔
83
                return new Description( $this->get_description_date(), $this->get_description_template() );
4✔
84
        }
85
}
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