[ Index ]

WordPress 5.4.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/wp-content/themes/twentytwenty/classes/ -> class-twentytwenty-non-latin-languages.php (source)

   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           *
  25           * @return void
  26           */
  27  		public static function get_non_latin_css( $type = 'front-end' ) {
  28  
  29              // Fetch site locale.
  30              $locale = get_bloginfo( 'language' );
  31  
  32              // Define fallback fonts for non-latin languages.
  33              $font_family = apply_filters(
  34                  'twentytwenty_get_localized_font_family_types',
  35                  array(
  36  
  37                      // Arabic.
  38                      'ar'    => array( 'Tahoma', 'Arial', 'sans-serif' ),
  39                      'ary'   => array( 'Tahoma', 'Arial', 'sans-serif' ),
  40                      'azb'   => array( 'Tahoma', 'Arial', 'sans-serif' ),
  41                      'ckb'   => array( 'Tahoma', 'Arial', 'sans-serif' ),
  42                      'fa-IR' => array( 'Tahoma', 'Arial', 'sans-serif' ),
  43                      'haz'   => array( 'Tahoma', 'Arial', 'sans-serif' ),
  44                      'ps'    => array( 'Tahoma', 'Arial', 'sans-serif' ),
  45  
  46                      // Chinese Simplified (China) - Noto Sans SC.
  47                      'zh-CN' => array( '\'PingFang SC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ),
  48  
  49                      // Chinese Traditional (Taiwan) - Noto Sans TC.
  50                      'zh-TW' => array( '\'PingFang TC\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ),
  51  
  52                      // Chinese (Hong Kong) - Noto Sans HK.
  53                      'zh-HK' => array( '\'PingFang HK\'', '\'Helvetica Neue\'', '\'Microsoft YaHei New\'', '\'STHeiti Light\'', 'sans-serif' ),
  54  
  55                      // Cyrillic.
  56                      'bel'   => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  57                      'bg-BG' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  58                      'kk'    => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  59                      'mk-MK' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  60                      'mn'    => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  61                      'ru-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  62                      'sah'   => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  63                      'sr-RS' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  64                      'tt-RU' => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  65                      'uk'    => array( '\'Helvetica Neue\'', 'Helvetica', '\'Segoe UI\'', 'Arial', 'sans-serif' ),
  66  
  67                      // Devanagari.
  68                      'bn-BD' => array( 'Arial', 'sans-serif' ),
  69                      'hi-IN' => array( 'Arial', 'sans-serif' ),
  70                      'mr'    => array( 'Arial', 'sans-serif' ),
  71                      'ne-NP' => array( 'Arial', 'sans-serif' ),
  72  
  73                      // Greek.
  74                      'el'    => array( '\'Helvetica Neue\', Helvetica, Arial, sans-serif' ),
  75  
  76                      // Gujarati.
  77                      'gu'    => array( 'Arial', 'sans-serif' ),
  78  
  79                      // Hebrew.
  80                      'he-IL' => array( '\'Arial Hebrew\'', 'Arial', 'sans-serif' ),
  81  
  82                      // Japanese.
  83                      'ja'    => array( 'sans-serif' ),
  84  
  85                      // Korean.
  86                      'ko-KR' => array( '\'Apple SD Gothic Neo\'', '\'Malgun Gothic\'', '\'Nanum Gothic\'', 'Dotum', 'sans-serif' ),
  87  
  88                      // Thai.
  89                      'th'    => array( '\'Sukhumvit Set\'', '\'Helvetica Neue\'', 'Helvetica', 'Arial', 'sans-serif' ),
  90  
  91                      // Vietnamese.
  92                      'vi'    => array( '\'Libre Franklin\'', 'sans-serif' ),
  93  
  94                  )
  95              );
  96  
  97              // Return if the selected language has no fallback fonts.
  98              if ( empty( $font_family[ $locale ] ) ) {
  99                  return;
 100              }
 101  
 102              // Define elements to apply fallback fonts to.
 103              $elements = apply_filters(
 104                  'twentytwenty_get_localized_font_family_elements',
 105                  array(
 106                      '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' ),
 107                      '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' ),
 108                      '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' ),
 109                  )
 110              );
 111  
 112              // Return if the specified type doesn't exist.
 113              if ( empty( $elements[ $type ] ) ) {
 114                  return;
 115              }
 116  
 117              // Return the specified styles.
 118              return twentytwenty_generate_css( implode( ',', $elements[ $type ] ), 'font-family', implode( ',', $font_family[ $locale ] ), null, null, false );
 119  
 120          }
 121      }
 122  }


Generated: Tue May 19 15:51:04 2020 Cross-referenced by PHPXref 0.7.1