TwentyTwenty_Non_Latin_Languages::get_non_latin_css( string $type = 'front-end' ): string|null
- Since
- Twenty Twenty 1.0
- Source
wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php:30
Description
Returns CSS for non-latin language, if available, or null.
Compatibility
- WordPress
- since Twenty Twenty 1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$typestringoptional- Whether to return CSS for the "front-end", "block-editor", or "classic-editor".Default:
'front-end'
Return value
string|null- Custom CSS, or null if not applicable.
Performance profile
How much work a call to TwentyTwenty_Non_Latin_Languages::get_non_latin_css() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Moderate
- Scaling
- Constant
- Instructions
- 13–32
- Plugin surface
- 2 hooks
- Called by
- 3
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 34.
Third-party callbacks on 'twentytwenty_get_localized_font_family_types', 'twentytwenty_get_localized_font_family_elements' run inside this call, and their cost is not bounded by anything here.
3 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below TwentyTwenty_Non_Latin_Languages::get_non_latin_css()
Further down the call graph this can also reach cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost TwentyTwenty_Non_Latin_Languages::get_non_latin_css() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($font_family[$locale]) | 13 | get_bloginfo(), apply_filters() |
!empty($font_family[$locale]) && empty($elements[$type]) | 20 | get_bloginfo(), apply_filters(), apply_filters() |
!empty($font_family[$locale]) && !empty($elements[$type]) | 32 | get_bloginfo(), apply_filters(), apply_filters(), twentytwenty_generate_css() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 34 | 13–32 | 2 | |
| 8.5 | 34 | 13–32 | 2 | |
| 8.4 | 34 | 13–32 | 2 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 40 | 13–38 | 2 | |
| 8.2 | 40 | 13–38 | 2 | |
| 8.1 | 40 | 13–38 | 2 | |
| 7.4 | 40 | 13–38 | 2 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while TwentyTwenty_Non_Latin_Languages::get_non_latin_css() runs, in this order:
- apply_filters( twentytwenty_get_localized_font_family_types )filterline 42 (+12 into the body)
Filters the fallback fonts for non-latin languages.
- apply_filters( twentytwenty_get_localized_font_family_elements )filterline 118 (+88 into the body)
Filters the elements to apply fallback fonts to.
Uses · 3
- get_bloginfo()Retrieves information about the current site.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- twentytwenty_generate_css()Generates CSS.
Used by · 3
- twentytwenty_add_classic_editor_non_latin_styles()Output non-latin font styles in the classic editor.
- twentytwenty_block_editor_styles()Enqueues supplemental block editor styles.
- twentytwenty_non_latin_languages()Enqueues non-latin language styles.
Source code
public static function get_non_latin_css( $type = 'front-end' ) { // Fetch site locale. $locale = get_bloginfo( 'language' ); /** * Filters the fallback fonts for non-latin languages. * * @since Twenty Twenty 1.0 * * @param array $font_family An array of locales and font families. */ $font_family = apply_filters( 'twentytwenty_get_localized_font_family_types', array( // Arabic. 'ar' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'ary' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'azb' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'ckb' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'fa-IR' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'haz' => array( 'Tahoma', 'Arial', 'sans-serif' ), 'ps' => array( 'Tahoma', 'Arial', 'sans-serif' ), // Chinese Simplified (China) - Noto Sans SC. 'zh-CN' => array( '\'PingFang SC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), // Chinese Traditional (Taiwan) - Noto Sans TC. 'zh-TW' => array( '\'PingFang TC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), // Chinese (Hong Kong) - Noto Sans HK. 'zh-HK' => array( '\'PingFang HK\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), // Cyrillic. 'bel' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'bg-BG' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'kk' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'mk-MK' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'mn' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'ru-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'sah' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'sr-RS' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'tt-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 'uk' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), // Devanagari. 'bn-BD' => array( 'Arial', 'sans-serif' ), 'hi-IN' => array( 'Arial', 'sans-serif' ), 'mr' => array( 'Arial', 'sans-serif' ), 'ne-NP' => array( 'Arial', 'sans-serif' ), // Greek. 'el' => array( '\'Helvetica Neue\', Helvetica, Arial, sans-serif' ), // Gujarati. 'gu' => array( 'Arial', 'sans-serif' ), // Hebrew. 'he-IL' => array( '\'Arial Hebrew\'', 'Arial', 'sans-serif' ), // Japanese. 'ja' => array( 'sans-serif' ), // Korean. 'ko-KR' => array( '\'Apple SD Gothic Neo\'', '\'Malgun Gothic\'', '\'Nanum Gothic\'', 'Dotum', 'sans-serif' ), // Thai. 'th' => array( '\'Sukhumvit Set\'', '\'Helvetica Neue\'', 'Helvetica', 'Arial', 'sans-serif' ), // Vietnamese. 'vi' => array( '\'Libre Franklin\'', 'sans-serif' ), ) ); // Return if the selected language has no fallback fonts. if ( empty( $font_family[ $locale ] ) ) { return null; }Changelog
Introduced in Twenty Twenty 1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.