[ Index ]

PHP Cross Reference of WordPress

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


Generated: Sat Apr 20 01:00:03 2024 Cross-referenced by PHPXref 0.7.1