WordPress.org

Making WordPress.org

Changeset 7117


Ignore:
Timestamp:
04/16/2018 11:06:36 PM (23 months ago)
Author:
iandunn
Message:

WP15: Only enqueue fonts for locales that they support.

Props dimadin.
Fixes #3569.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php

    r7107 r7117  
    3333
    3434/**
     35 * Register custom fonts.
     36 */
     37function get_fonts_url() {
     38    $fonts_url = '';
     39    $fonts     = array();
     40    $subsets   = 'cyrillic,cyrillic-ext,greek,greek-ext,latin,latin-ext,vietnamese';
     41
     42    /*
     43     * Translators: If there are characters in your language that are not supported
     44     * by Source Sans Pro, translate this to 'off'. Do not translate into your own language.
     45     */
     46    if ( 'off' !== _x( 'on', 'Source Sans Pro font: on or off', 'wp15' ) ) {
     47        $fonts[] = 'Source Sans Pro:400,400i,600,700';
     48    }
     49
     50    /*
     51     * Translators: If there are characters in your language that are not supported
     52     * by Crete Round, translate this to 'off'. Do not translate into your own language.
     53     */
     54    if ( 'off' !== _x( 'on', 'Crete Round font: on or off', 'wp15' ) ) {
     55        $fonts[] = 'Crete Round';
     56    }
     57
     58    if ( $fonts ) {
     59        $fonts_url = add_query_arg( array(
     60            'family' => rawurlencode( implode( '|', $fonts ) ),
     61            'subset' => rawurlencode( $subsets ),
     62        ), 'https://fonts.googleapis.com/css' );
     63    }
     64
     65    return $fonts_url;
     66}
     67
     68/**
    3569 * Enqueue scripts and styles
    3670 */
    3771function enqueue_scripts() {
    3872    wp_register_style(
    39         'source-sans-pro',
    40         'https://fonts.googleapis.com/css?family=Crete+Round|Source+Sans+Pro:400,400i,600,700&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese'
     73        'twentyseventeen-wp15-fonts',
     74        get_fonts_url()
    4175    );
    4276
     
    4983        'twentyseventeen-style',
    5084        get_stylesheet_directory_uri() . '/style.css',
    51         array( 'twentyseventeen-parent-style', 'source-sans-pro', 'dashicons' ),
     85        array( 'twentyseventeen-parent-style', 'twentyseventeen-wp15-fonts', 'dashicons' ),
    5286        filemtime( __DIR__ . '/style.css' )
    5387    );
Note: See TracChangeset for help on using the changeset viewer.