WordPress.org

Make WordPress Core

Ticket #37171: 37171.6.diff

File 37171.6.diff, 5.0 KB (added by peterwilsoncc, 3 years ago)
  • src/wp-content/themes/twentyfifteen/functions.php

    diff --git src/wp-content/themes/twentyfifteen/functions.php src/wp-content/themes/twentyfifteen/functions.php
    index 1c382bf..8ae7e1d 100644
    function twentyfifteen_scripts() { 
    286286add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
    287287
    288288/**
     289 * Add preconnect for Google Fonts.
     290 *
     291 * @since Twenty Fifteen 1.7
     292 *
     293 * @param array   $urls          URLs to print for resource hints.
     294 * @param string  $relation_type The relation type the URLs are printed.
     295 * @return array URLs to print for resource hints.
     296 */
     297function twentyfifteen_resource_hints( $urls, $relation_type ) {
     298        if ( wp_style_is( 'twentyfifteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
     299                if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
     300                        $urls[] = array(
     301                                'href' => 'https://fonts.gstatic.com',
     302                                'crossorigin',
     303                        );
     304                } else {
     305                        $urls[] = 'https://fonts.gstatic.com';
     306                }
     307        }
     308
     309        return $urls;
     310}
     311add_filter( 'wp_resource_hints', 'twentyfifteen_resource_hints', 10, 2 );
     312
     313/**
    289314 * Add featured image as background image to post navigation elements.
    290315 *
    291316 * @since Twenty Fifteen 1.0
  • src/wp-content/themes/twentyfourteen/functions.php

    diff --git src/wp-content/themes/twentyfourteen/functions.php src/wp-content/themes/twentyfourteen/functions.php
    index f85ef1c..74141dc 100644
    function twentyfourteen_admin_fonts() { 
    277277}
    278278add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' );
    279279
     280/**
     281 * Add preconnect for Google Fonts.
     282 *
     283 * @since Twenty Fourteen 1.9
     284 *
     285 * @param array   $urls          URLs to print for resource hints.
     286 * @param string  $relation_type The relation type the URLs are printed.
     287 * @return array URLs to print for resource hints.
     288 */
     289function twentyfourteen_resource_hints( $urls, $relation_type ) {
     290        if ( wp_style_is( 'twentyfourteen-lato', 'queue' ) && 'preconnect' === $relation_type ) {
     291                if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
     292                        $urls[] = array(
     293                                'href' => 'https://fonts.gstatic.com',
     294                                'crossorigin',
     295                        );
     296                } else {
     297                        $urls[] = 'https://fonts.gstatic.com';
     298                }
     299        }
     300
     301        return $urls;
     302}
     303add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 );
     304
    280305if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
    281306/**
    282307 * Print the attached image with a link to the next attached image.
  • src/wp-content/themes/twentythirteen/functions.php

    diff --git src/wp-content/themes/twentythirteen/functions.php src/wp-content/themes/twentythirteen/functions.php
    index ae1bd9e..d1f7d5b 100644
    function twentythirteen_scripts_styles() { 
    191191add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
    192192
    193193/**
     194 * Add preconnect for Google Fonts.
     195 *
     196 * @since Twenty Thirteen 2.1
     197 *
     198 * @param array   $urls          URLs to print for resource hints.
     199 * @param string  $relation_type The relation type the URLs are printed.
     200 * @return array URLs to print for resource hints.
     201 */
     202function twentythirteen_resource_hints( $urls, $relation_type ) {
     203        if ( wp_style_is( 'twentythirteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
     204                if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
     205                        $urls[] = array(
     206                                'href' => 'https://fonts.gstatic.com',
     207                                'crossorigin',
     208                        );
     209                } else {
     210                        $urls[] = 'https://fonts.gstatic.com';
     211                }
     212        }
     213
     214        return $urls;
     215}
     216add_filter( 'wp_resource_hints', 'twentythirteen_resource_hints', 10, 2 );
     217
     218/**
    194219 * Filter the page title.
    195220 *
    196221 * Creates a nicely formatted and more specific title element text for output
  • src/wp-content/themes/twentytwelve/functions.php

    diff --git src/wp-content/themes/twentytwelve/functions.php src/wp-content/themes/twentytwelve/functions.php
    index 56cd8e5..2dc2cd8 100644
    function twentytwelve_scripts_styles() { 
    158158add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
    159159
    160160/**
     161 * Add preconnect for Google Fonts.
     162 *
     163 * @since Twenty Twelve 2.2
     164 *
     165 * @param array   $urls          URLs to print for resource hints.
     166 * @param string  $relation_type The relation type the URLs are printed.
     167 * @return array URLs to print for resource hints.
     168 */
     169function twentytwelve_resource_hints( $urls, $relation_type ) {
     170        if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
     171                if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
     172                        $urls[] = array(
     173                                'href' => 'https://fonts.gstatic.com',
     174                                'crossorigin',
     175                        );
     176                } else {
     177                        $urls[] = 'https://fonts.gstatic.com';
     178                }
     179        }
     180
     181        return $urls;
     182}
     183add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 );
     184
     185/**
    161186 * Filter TinyMCE CSS path to include Google Fonts.
    162187 *
    163188 * Adds additional stylesheets to the TinyMCE editor if needed.