Make WordPress Core

Ticket #37171: 37171.diff

File 37171.diff, 4.8 KB (added by leobaiano, 8 years ago)

Including preconnect through wp_resource_hints()

  • wp-content/themes/twentyfifteen/functions.php

     
    273273add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
    274274
    275275/**
     276 * Add preconnect for Google Fonts.
     277 *
     278 * @since Twenty Fifteen 1.6
     279 *
     280 * @param array   $urls           URLs to print for resource hints.
     281 * @param WP_Post $relation_type  The relation type the URLs are printed.
     282 * @return array  $urls           URLs to print for resource hints.
     283 */
     284function twentyfifteen_resource_hints( $urls, $relation_type ) {
     285    // Add preconnect for Google Fonts if queue twentyfifteen-fonts.
     286        if ( wp_style_is( 'twentyfifteen-fonts', 'queue' ) && 'preconnect' === $relation_type )
     287                $urls[] = 'https://fonts.gstatic.com';
     288 
     289    return $urls;
     290}
     291add_filter( 'wp_resource_hints', 'twentyfifteen_resource_hints', 10, 2 );
     292
     293/**
    276294 * Add featured image as background image to post navigation elements.
    277295 *
    278296 * @since Twenty Fifteen 1.0
  • wp-content/themes/twentyfourteen/functions.php

     
    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.8
     284 *
     285 * @param array   $urls           URLs to print for resource hints.
     286 * @param WP_Post $relation_type  The relation type the URLs are printed.
     287 * @return array  $urls           URLs to print for resource hints.
     288 */
     289function twentyfourteen_resource_hints( $urls, $relation_type ) {
     290    // Add preconnect for Google Fonts if queue twentyfourteen-lato.
     291        if ( wp_style_is( 'twentyfourteen-lato', 'queue' ) && 'preconnect' === $relation_type )
     292                $urls[] = 'https://fonts.gstatic.com';
     293 
     294    return $urls;
     295}
     296add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 );
     297
    280298if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
    281299/**
    282300 * Print the attached image with a link to the next attached image.
  • wp-content/themes/twentythirteen/functions.php

     
    191191add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
    192192
    193193/**
     194 * Add preconnect for Google Fonts.
     195 *
     196 * @since Twenty Thirteen 2.0
     197 *
     198 * @param array   $urls           URLs to print for resource hints.
     199 * @param WP_Post $relation_type  The relation type the URLs are printed.
     200 * @return array  $urls           URLs to print for resource hints.
     201 */
     202function twentythirteen_resource_hints( $urls, $relation_type ) {
     203    // Add preconnect for Google Fonts if queue twentythirteen-fonts.
     204        if ( wp_style_is( 'twentythirteen-fonts', 'queue' ) && 'preconnect' === $relation_type )
     205                $urls[] = 'https://fonts.gstatic.com';
     206 
     207    return $urls;
     208}
     209add_filter( 'wp_resource_hints', 'twentythirteen_resource_hints', 10, 2 );
     210
     211/**
    194212 * Filter the page title.
    195213 *
    196214 * Creates a nicely formatted and more specific title element text for output
  • wp-content/themes/twentytwelve/functions.php

     
    146146
    147147        $font_url = twentytwelve_get_font_url();
    148148        if ( ! empty( $font_url ) )
    149                 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null );
     149                // wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null );
    150150
    151151        // Loads our main stylesheet.
    152152        wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );
     
    158158add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
    159159
    160160/**
     161 * Add preconnect for Google Fonts.
     162 *
     163 * @since Twenty Twelve 2.1
     164 *
     165 * @param array   $urls           URLs to print for resource hints.
     166 * @param WP_Post $relation_type  The relation type the URLs are printed.
     167 * @return array  $urls           URLs to print for resource hints.
     168 */
     169function twentytwelve_resource_hints( $urls, $relation_type ) {
     170    // Add preconnect for Google Fonts if queue twentytwelve-fonts.
     171        if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type )
     172                $urls[] = 'https://fonts.gstatic.com';
     173 
     174    return $urls;
     175}
     176add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 );
     177
     178/**
    161179 * Filter TinyMCE CSS path to include Google Fonts.
    162180 *
    163181 * Adds additional stylesheets to the TinyMCE editor if needed.