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

Yoast / wordpress-seo / dd6e866a9e6d253114633104d9e3858d807178ba

19 Jun 2024 10:03AM UTC coverage: 48.628% (-4.3%) from 52.936%
dd6e866a9e6d253114633104d9e3858d807178ba

push

github

web-flow
Merge pull request #21431 from Yoast/21429-update-copy-in-the-introduction-and-consent-modals

Updates the copy for the introduction and consent modals

7441 of 13454 branches covered (55.31%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 2 files covered. (0.0%)

3718 existing lines in 107 files now uncovered.

25100 of 53464 relevant lines covered (46.95%)

62392.47 hits per line

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

0.0
/admin/formatter/class-metabox-formatter.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin\Formatter
6
 */
7

8
use Yoast\WP\SEO\Config\Schema_Types;
9
use Yoast\WP\SEO\Editors\Application\Analysis_Features\Enabled_Analysis_Features_Repository;
10
use Yoast\WP\SEO\Editors\Application\Integrations\Integration_Information_Repository;
11

12
/**
13
 * This class forces needed methods for the metabox localization.
14
 */
15
class WPSEO_Metabox_Formatter {
16

17
        /**
18
         * Object that provides formatted values.
19
         *
20
         * @var WPSEO_Metabox_Formatter_Interface
21
         */
22
        private $formatter;
23

24
        /**
25
         * Setting the formatter property.
26
         *
27
         * @param WPSEO_Metabox_Formatter_Interface $formatter Object that provides the formatted values.
28
         */
UNCOV
29
        public function __construct( WPSEO_Metabox_Formatter_Interface $formatter ) {
×
UNCOV
30
                $this->formatter = $formatter;
×
31
        }
32

33
        /**
34
         * Returns the values.
35
         *
36
         * @return array<string,string|array<string|int|bool>|bool|int>
37
         */
UNCOV
38
        public function get_values() {
×
UNCOV
39
                $defaults = $this->get_defaults();
×
UNCOV
40
                $values   = $this->formatter->get_values();
×
41

UNCOV
42
                return ( $values + $defaults );
×
43
        }
44

45
        /**
46
         * Returns array with all the values always needed by a scraper object.
47
         *
48
         * @return array<string,string|array<string|int|bool>|bool|int> Default settings for the metabox.
49
         */
UNCOV
50
        private function get_defaults() {
×
UNCOV
51
                $schema_types = new Schema_Types();
×
UNCOV
52
                $host         = YoastSEO()->helpers->url->get_url_host( get_site_url() );
×
53

UNCOV
54
                $defaults = [
×
UNCOV
55
                        'author_name'                        => get_the_author_meta( 'display_name' ),
×
UNCOV
56
                        'site_name'                          => YoastSEO()->meta->for_current_page()->site_name,
×
UNCOV
57
                        'sitewide_social_image'              => WPSEO_Options::get( 'og_default_image' ),
×
UNCOV
58
                        'search_url'                         => '',
×
UNCOV
59
                        'post_edit_url'                      => '',
×
UNCOV
60
                        'base_url'                           => '',
×
UNCOV
61
                        'contentLocale'                      => get_locale(),
×
UNCOV
62
                        'userLocale'                         => get_user_locale(),
×
UNCOV
63
                        'translations'                       => $this->get_translations(),
×
UNCOV
64
                        'keyword_usage'                      => [],
×
UNCOV
65
                        'title_template'                     => '',
×
UNCOV
66
                        'metadesc_template'                  => '',
×
UNCOV
67
                        'isRtl'                              => is_rtl(),
×
UNCOV
68
                        'isPremium'                          => YoastSEO()->helpers->product->is_premium(),
×
UNCOV
69
                        'siteIconUrl'                        => get_site_icon_url(),
×
UNCOV
70
                        'showSocial'                         => [
×
UNCOV
71
                                'facebook' => WPSEO_Options::get( 'opengraph', false ),
×
UNCOV
72
                                'twitter'  => WPSEO_Options::get( 'twitter', false ),
×
UNCOV
73
                        ],
×
UNCOV
74
                        'schema'                             => [
×
UNCOV
75
                                'displayFooter'      => WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ),
×
UNCOV
76
                                'pageTypeOptions'    => $schema_types->get_page_type_options(),
×
UNCOV
77
                                'articleTypeOptions' => $schema_types->get_article_type_options(),
×
UNCOV
78
                        ],
×
UNCOV
79
                        'twitterCardType'                    => 'summary_large_image',
×
UNCOV
80
                        'publish_box'                        => [
×
UNCOV
81
                                'labels' => [
×
UNCOV
82
                                        'keyword'            => [
×
UNCOV
83
                                                'na'   => sprintf(
×
84
                                                        /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
UNCOV
85
                                                        __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
86
                                                        '<a href="#yoast-seo-analysis-collapsible-metabox">',
×
UNCOV
87
                                                        '</a>',
×
UNCOV
88
                                                        '<strong>' . __( 'Not available', 'wordpress-seo' ) . '</strong>'
×
UNCOV
89
                                                ),
×
UNCOV
90
                                                'bad'  => sprintf(
×
91
                                                        /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
UNCOV
92
                                                        __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
93
                                                        '<a href="#yoast-seo-analysis-collapsible-metabox">',
×
UNCOV
94
                                                        '</a>',
×
UNCOV
95
                                                        '<strong>' . __( 'Needs improvement', 'wordpress-seo' ) . '</strong>'
×
UNCOV
96
                                                ),
×
UNCOV
97
                                                'ok'   => sprintf(
×
98
                                                        /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
UNCOV
99
                                                        __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
100
                                                        '<a href="#yoast-seo-analysis-collapsible-metabox">',
×
UNCOV
101
                                                        '</a>',
×
UNCOV
102
                                                        '<strong>' . __( 'OK', 'wordpress-seo' ) . '</strong>'
×
UNCOV
103
                                                ),
×
UNCOV
104
                                                'good' => sprintf(
×
105
                                                        /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
UNCOV
106
                                                        __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
107
                                                        '<a href="#yoast-seo-analysis-collapsible-metabox">',
×
UNCOV
108
                                                        '</a>',
×
UNCOV
109
                                                        '<strong>' . __( 'Good', 'wordpress-seo' ) . '</strong>'
×
UNCOV
110
                                                ),
×
UNCOV
111
                                        ],
×
UNCOV
112
                                        'content'            => [
×
UNCOV
113
                                                'na'   => sprintf(
×
114
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
UNCOV
115
                                                        __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
116
                                                        '<a href="#yoast-readability-analysis-collapsible-metabox">',
×
UNCOV
117
                                                        '</a>',
×
UNCOV
118
                                                        '<strong>' . __( 'Not available', 'wordpress-seo' ) . '</strong>'
×
UNCOV
119
                                                ),
×
UNCOV
120
                                                'bad'  => sprintf(
×
121
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
UNCOV
122
                                                        __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
123
                                                        '<a href="#yoast-readability-analysis-collapsible-metabox">',
×
UNCOV
124
                                                        '</a>',
×
UNCOV
125
                                                        '<strong>' . __( 'Needs improvement', 'wordpress-seo' ) . '</strong>'
×
UNCOV
126
                                                ),
×
UNCOV
127
                                                'ok'   => sprintf(
×
128
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
UNCOV
129
                                                        __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
130
                                                        '<a href="#yoast-readability-analysis-collapsible-metabox">',
×
UNCOV
131
                                                        '</a>',
×
UNCOV
132
                                                        '<strong>' . __( 'OK', 'wordpress-seo' ) . '</strong>'
×
UNCOV
133
                                                ),
×
UNCOV
134
                                                'good' => sprintf(
×
135
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
UNCOV
136
                                                        __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
137
                                                        '<a href="#yoast-readability-analysis-collapsible-metabox">',
×
UNCOV
138
                                                        '</a>',
×
UNCOV
139
                                                        '<strong>' . __( 'Good', 'wordpress-seo' ) . '</strong>'
×
UNCOV
140
                                                ),
×
UNCOV
141
                                        ],
×
UNCOV
142
                                        'inclusive-language' => [
×
UNCOV
143
                                                'na'   => sprintf(
×
144
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
UNCOV
145
                                                        __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
146
                                                        '<a href="#yoast-inclusive-language-analysis-collapsible-metabox">',
×
UNCOV
147
                                                        '</a>',
×
UNCOV
148
                                                        '<strong>' . __( 'Not available', 'wordpress-seo' ) . '</strong>'
×
UNCOV
149
                                                ),
×
UNCOV
150
                                                'bad'  => sprintf(
×
151
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
UNCOV
152
                                                        __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
153
                                                        '<a href="#yoast-inclusive-language-analysis-collapsible-metabox">',
×
UNCOV
154
                                                        '</a>',
×
UNCOV
155
                                                        '<strong>' . __( 'Needs improvement', 'wordpress-seo' ) . '</strong>'
×
UNCOV
156
                                                ),
×
UNCOV
157
                                                'ok'   => sprintf(
×
158
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
UNCOV
159
                                                        __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
160
                                                        '<a href="#yoast-inclusive-language-analysis-collapsible-metabox">',
×
UNCOV
161
                                                        '</a>',
×
UNCOV
162
                                                        '<strong>' . __( 'Potentially non-inclusive', 'wordpress-seo' ) . '</strong>'
×
UNCOV
163
                                                ),
×
UNCOV
164
                                                'good' => sprintf(
×
165
                                                /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
UNCOV
166
                                                        __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
×
UNCOV
167
                                                        '<a href="#yoast-inclusive-language-analysis-collapsible-metabox">',
×
UNCOV
168
                                                        '</a>',
×
UNCOV
169
                                                        '<strong>' . __( 'Good', 'wordpress-seo' ) . '</strong>'
×
UNCOV
170
                                                ),
×
UNCOV
171
                                        ],
×
UNCOV
172
                                ],
×
UNCOV
173
                        ],
×
174
                        /**
175
                         * Filter to determine if the markers should be enabled or not.
176
                         *
177
                         * @param bool $showMarkers Should the markers being enabled. Default = true.
178
                         */
UNCOV
179
                        'show_markers'                       => apply_filters( 'wpseo_enable_assessment_markers', true ),
×
UNCOV
180
                        'zapierIntegrationActive'            => WPSEO_Options::get( 'zapier_integration_active', false ) ? 1 : 0,
×
UNCOV
181
                        'zapierConnectedStatus'              => ! empty( WPSEO_Options::get( 'zapier_subscription', [] ) ) ? 1 : 0,
×
UNCOV
182
                        'getJetpackBoostPrePublishLink'      => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-get-prepublish?domain=' . $host ),
×
UNCOV
183
                        'upgradeJetpackBoostPrePublishLink'  => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-upgrade-prepublish?domain=' . $host ),
×
UNCOV
184
                        'woocommerceUpsellSchemaLink'        => WPSEO_Shortlinker::get( 'https://yoa.st/product-schema-metabox' ),
×
UNCOV
185
                        'woocommerceUpsellGooglePreviewLink' => WPSEO_Shortlinker::get( 'https://yoa.st/product-google-preview-metabox' ),
×
UNCOV
186
                ];
×
187

UNCOV
188
                $integration_information_repo = YoastSEO()->classes->get( Integration_Information_Repository::class );
×
189

UNCOV
190
                $enabled_integrations  = $integration_information_repo->get_integration_information();
×
UNCOV
191
                $defaults              = array_merge( $defaults, $enabled_integrations );
×
UNCOV
192
                $enabled_features_repo = YoastSEO()->classes->get( Enabled_Analysis_Features_Repository::class );
×
193

UNCOV
194
                $enabled_features = $enabled_features_repo->get_enabled_features()->parse_to_legacy_array();
×
UNCOV
195
                return array_merge( $defaults, $enabled_features );
×
196
        }
197

198
        /**
199
         * Returns Jed compatible YoastSEO.js translations.
200
         *
201
         * @return string[]
202
         */
UNCOV
203
        private function get_translations() {
×
UNCOV
204
                $locale = get_user_locale();
×
205

UNCOV
206
                $file = WPSEO_PATH . 'languages/wordpress-seo-' . $locale . '.json';
×
UNCOV
207
                if ( file_exists( $file ) ) {
×
208
                        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Retrieving a local file.
UNCOV
209
                        $file = file_get_contents( $file );
×
UNCOV
210
                        if ( is_string( $file ) && $file !== '' ) {
×
UNCOV
211
                                return json_decode( $file, true );
×
212
                        }
213
                }
214

UNCOV
215
                return [];
×
216
        }
217
}
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

© 2025 Coveralls, Inc