[wp-trac] [WordPress Trac] #47282: Use font-display for Google Fonts in core themes

WordPress Trac noreply at wordpress.org
Wed May 15 21:07:27 UTC 2019


#47282: Use font-display for Google Fonts in core themes
---------------------------+------------------------
 Reporter:  westonruter    |       Owner:  flixos90
     Type:  enhancement    |      Status:  reviewing
 Priority:  normal         |   Milestone:  5.3
Component:  Bundled Theme  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:
---------------------------+------------------------

Comment (by westonruter):

 @superpoincare as long as the stylesheets are enqueued properly, then you
 can just amend the URL of the registered stylesheet. For example:

 {{{#!php
 <?php
 add_action( 'wp_enqueue_scripts', function()  {
         $handle = 'my-google-font-stylesheet';
         if ( ! wp_style_is( $handle, 'registered' ) ) {
                 return;
         }
         wp_styles()->registered[ $handle ]->src = add_query_arg(
                 'display',
                 'fallback',
                 wp_styles()->registered[ $handle ]->src
         );
 }, 100 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47282#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list