twenty_twenty_one_get_non_latin_css( string $type = 'front-end' ): string
- Since
- Twenty Twenty-One 1.0
- Source
wp-content/themes/twentytwentyone/inc/template-functions.php:239
Description
Return CSS for non-latin language, if available, or null
Compatibility
- WordPress
- since Twenty Twenty-One 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- CSS styles for non-Latin languages based on the site locale.
Performance profile
How much work a call to twenty_twenty_one_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–40
- Plugin surface
- 2 hooks
- Called by
- 1
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 42.
Third-party callbacks on 'twenty_twenty_one_get_localized_font_family_types', 'twenty_twenty_one_get_localized_font_family_elements' run inside this call, and their cost is not bounded by anything here.
1 place 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 twenty_twenty_one_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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost twenty_twenty_one_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]) && function_exists() | 36 | get_bloginfo(), apply_filters(), apply_filters(), function_exists(), twenty_twenty_one_generate_css() |
!empty($font_family[$locale]) && !empty($elements[$type]) && !function_exists() | 40 | get_bloginfo(), apply_filters(), apply_filters(), function_exists(), get_theme_file_path(), twenty_twenty_one_generate_css() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 42 | 13–40 | 3 | |
| 8.5 | 42 | 13–40 | 3 | |
| 8.4 | 42 | 13–40 | 3 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 48 | 13–46 | 3 | |
| 8.2 | 48 | 13–46 | 3 | |
| 8.1 | 48 | 13–46 | 3 | |
| 7.4 | 48 | 13–46 | 3 |
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 twenty_twenty_one_get_non_latin_css() runs, in this order:
- apply_filters( twenty_twenty_one_get_localized_font_family_types )filterline 251 (+12 into the body)
Filters the fallback fonts for non-latin languages.
- apply_filters( twenty_twenty_one_get_localized_font_family_elements )filterline 327 (+88 into the body)
Filters the elements to apply fallback fonts to.
Uses · 4
- get_bloginfo()Retrieves information about the current site.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_theme_file_path()Retrieves the path of a file in the theme.
- twenty_twenty_one_generate_css()Generates CSS.
Used by · 1
- twenty_twenty_one_non_latin_languages()Enqueues non-latin language styles.
Source code
function twenty_twenty_one_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-One 1.0 * * @param array $font_family An array of locales and font families. */ $font_family = apply_filters( 'twenty_twenty_one_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 ''; }Changelog
Introduced in Twenty Twenty-One 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/twentytwentyone/inc/template-functions.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.