• 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

57.14
/inc/language-utils.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Internals
6
 * @since   5.9.0
7
 */
8

9
/**
10
 * Group of language utility methods for use by WPSEO.
11
 * All methods are static, this is just a sort of namespacing class wrapper.
12
 */
13
class WPSEO_Language_Utils {
14

15
        /**
16
         * Returns the language part of a given locale, defaults to english when the $locale is empty.
17
         *
18
         * @param string|null $locale The locale to get the language of.
19
         *
20
         * @return string The language part of the locale.
21
         */
22
        public static function get_language( $locale = null ) {
6✔
23
                $language = 'en';
6✔
24

25
                if ( empty( $locale ) || ! is_string( $locale ) ) {
6✔
26
                        return $language;
4✔
27
                }
28

29
                $locale_parts = explode( '_', $locale );
4✔
30

31
                if ( ! empty( $locale_parts[0] ) && ( strlen( $locale_parts[0] ) === 2 || strlen( $locale_parts[0] ) === 3 ) ) {
4✔
32
                        $language = $locale_parts[0];
4✔
33
                }
34

35
                return $language;
4✔
36
        }
37

38
        /**
39
         * Returns the full name for the sites' language.
40
         *
41
         * @return string The language name.
42
         */
43
        public static function get_site_language_name() {
×
44
                require_once ABSPATH . 'wp-admin/includes/translation-install.php';
×
45

46
                $translations = wp_get_available_translations();
×
47
                $locale       = get_locale();
×
48
                $language     = isset( $translations[ $locale ] ) ? $translations[ $locale ]['native_name'] : 'English (US)';
×
49

50
                return $language;
×
51
        }
52

53
        /**
54
         * Returns the l10n array for the knowledge graph company info missing.
55
         *
56
         * @deprecated 20.3
57
         * @codeCoverageIgnore
58
         *
59
         * @return array The l10n array.
60
         */
61
        public static function get_knowledge_graph_company_info_missing_l10n() {
62
                _deprecated_function( __METHOD__, 'Yoast SEO 20.3' );
63

64
                return [
65
                        'URL'     => esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/3r3' ) ),
66
                        /* translators: 1: expands to a link opening tag; 2: expands to a link closing tag */
67
                        'message' => esc_html__(
68
                                'A company name and logo need to be set for structured data to work properly. Since you haven’t set these yet, we are using the site name and logo as default values. %1$sLearn more about the importance of structured data.%2$s',
69
                                'wordpress-seo'
70
                        ),
71
                ];
72
        }
73
}
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