[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Non-latin language handling. 4 * 5 * Handle non-latin language styles. 6 * 7 * @package WordPress 8 * @subpackage Twenty_Twenty 9 * @since Twenty Twenty 1.0 10 */ 11 12 if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) { 13 /** 14 * Language handling. 15 */ 16 class TwentyTwenty_Non_Latin_Languages { 17 18 /** 19 * Get custom CSS. 20 * 21 * Return CSS for non-latin language, if available, or null 22 * 23 * @param string $type Whether to return CSS for the "front-end", "block-editor" or "classic-editor". 24 * @return void 25 */ 26 public static function get_non_latin_css( $type = 'front-end' ) { 27 28 // Fetch site locale. 29 $locale = get_bloginfo( 'language' ); 30 31 // Define fallback fonts for non-latin languages. 32 $font_family = apply_filters( 33 'twentytwenty_get_localized_font_family_types', 34 array( 35 36 // Arabic. 37 'ar' => array( 'Tahoma', 'Arial', 'sans-serif' ), 38 'ary' => array( 'Tahoma', 'Arial', 'sans-serif' ), 39 'azb' => array( 'Tahoma', 'Arial', 'sans-serif' ), 40 'ckb' => array( 'Tahoma', 'Arial', 'sans-serif' ), 41 'fa-IR' => array( 'Tahoma', 'Arial', 'sans-serif' ), 42 'haz' => array( 'Tahoma', 'Arial', 'sans-serif' ), 43 'ps' => array( 'Tahoma', 'Arial', 'sans-serif' ), 44 45 // Chinese Simplified (China) - Noto Sans SC. 46 'zh-CN' => array( '\'PingFang SC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), 47 48 // Chinese Traditional (Taiwan) - Noto Sans TC. 49 'zh-TW' => array( '\'PingFang TC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), 50 51 // Chinese (Hong Kong) - Noto Sans HK. 52 'zh-HK' => array( '\'PingFang HK\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ), 53 54 // Cyrillic. 55 'bel' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 56 'bg-BG' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 57 'kk' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 58 'mk-MK' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 59 'mn' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 60 'ru-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 61 'sah' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 62 'sr-RS' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 63 'tt-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 64 'uk' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ), 65 66 // Devanagari. 67 'bn-BD' => array( 'Arial', 'sans-serif' ), 68 'hi-IN' => array( 'Arial', 'sans-serif' ), 69 'mr' => array( 'Arial', 'sans-serif' ), 70 'ne-NP' => array( 'Arial', 'sans-serif' ), 71 72 // Greek. 73 'el' => array( '\'Helvetica Neue\', Helvetica, Arial, sans-serif' ), 74 75 // Gujarati. 76 'gu' => array( 'Arial', 'sans-serif' ), 77 78 // Hebrew. 79 'he-IL' => array( '\'Arial Hebrew\'', 'Arial', 'sans-serif' ), 80 81 // Japanese. 82 'ja' => array( 'sans-serif' ), 83 84 // Korean. 85 'ko-KR' => array( '\'Apple SD Gothic Neo\'', '\'Malgun Gothic\'', '\'Nanum Gothic\'', 'Dotum', 'sans-serif' ), 86 87 // Thai. 88 'th' => array( '\'Sukhumvit Set\'', '\'Helvetica Neue\'', 'Helvetica', 'Arial', 'sans-serif' ), 89 90 // Vietnamese. 91 'vi' => array( '\'Libre Franklin\'', 'sans-serif' ), 92 93 ) 94 ); 95 96 // Return if the selected language has no fallback fonts. 97 if ( empty( $font_family[ $locale ] ) ) { 98 return; 99 } 100 101 // Define elements to apply fallback fonts to. 102 $elements = apply_filters( 103 'twentytwenty_get_localized_font_family_elements', 104 array( 105 'front-end' => array( 'body', 'input', 'textarea', 'button', '.button', '.faux-button', '.wp-block-button__link', '.wp-block-file__button', '.has-drop-cap:not(:focus)::first-letter', '.has-drop-cap:not(:focus)::first-letter', '.entry-content .wp-block-archives', '.entry-content .wp-block-categories', '.entry-content .wp-block-cover-image', '.entry-content .wp-block-latest-comments', '.entry-content .wp-block-latest-posts', '.entry-content .wp-block-pullquote', '.entry-content .wp-block-quote.is-large', '.entry-content .wp-block-quote.is-style-large', '.entry-content .wp-block-archives *', '.entry-content .wp-block-categories *', '.entry-content .wp-block-latest-posts *', '.entry-content .wp-block-latest-comments *', '.entry-content p', '.entry-content ol', '.entry-content ul', '.entry-content dl', '.entry-content dt', '.entry-content cite', '.entry-content figcaption', '.entry-content .wp-caption-text', '.comment-content p', '.comment-content ol', '.comment-content ul', '.comment-content dl', '.comment-content dt', '.comment-content cite', '.comment-content figcaption', '.comment-content .wp-caption-text', '.widget_text p', '.widget_text ol', '.widget_text ul', '.widget_text dl', '.widget_text dt', '.widget-content .rssSummary', '.widget-content cite', '.widget-content figcaption', '.widget-content .wp-caption-text' ), 106 'block-editor' => array( '.editor-styles-wrapper > *', '.editor-styles-wrapper p', '.editor-styles-wrapper ol', '.editor-styles-wrapper ul', '.editor-styles-wrapper dl', '.editor-styles-wrapper dt', '.editor-post-title__block .editor-post-title__input', '.editor-styles-wrapper .wp-block h1', '.editor-styles-wrapper .wp-block h2', '.editor-styles-wrapper .wp-block h3', '.editor-styles-wrapper .wp-block h4', '.editor-styles-wrapper .wp-block h5', '.editor-styles-wrapper .wp-block h6', '.editor-styles-wrapper .has-drop-cap:not(:focus)::first-letter', '.editor-styles-wrapper cite', '.editor-styles-wrapper figcaption', '.editor-styles-wrapper .wp-caption-text' ), 107 'classic-editor' => array( 'body#tinymce.wp-editor', 'body#tinymce.wp-editor p', 'body#tinymce.wp-editor ol', 'body#tinymce.wp-editor ul', 'body#tinymce.wp-editor dl', 'body#tinymce.wp-editor dt', 'body#tinymce.wp-editor figcaption', 'body#tinymce.wp-editor .wp-caption-text', 'body#tinymce.wp-editor .wp-caption-dd', 'body#tinymce.wp-editor cite', 'body#tinymce.wp-editor table' ), 108 ) 109 ); 110 111 // Return if the specified type doesn't exist. 112 if ( empty( $elements[ $type ] ) ) { 113 return; 114 } 115 116 // Return the specified styles. 117 return twentytwenty_generate_css( implode( ',', $elements[ $type ] ), 'font-family', implode( ',', $font_family[ $locale ] ), null, null, false ); 118 119 } 120 } 121 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Feb 28 01:00:03 2021 | Cross-referenced by PHPXref 0.7.1 |