[wp-trac] [WordPress Trac] #39323: Twenty Seventeen: wp_resource_hints when enqueue custom fonts in child theme

WordPress Trac noreply at wordpress.org
Sat Dec 31 00:43:12 UTC 2016


#39323: Twenty Seventeen: wp_resource_hints when enqueue custom fonts in child
theme
---------------------------+----------------------
 Reporter:  sami.keijonen  |       Owner:
     Type:  enhancement    |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  Bundled Theme  |     Version:  4.7
 Severity:  normal         |  Resolution:  wontfix
 Keywords:                 |     Focuses:
---------------------------+----------------------
Changes (by dd32):

 * status:  reopened => closed
 * resolution:   => wontfix


Comment:

 Your proposed filter just makes it even more complicated.

 If you're not going to use the Twenty Seventeen CSS fonts enqueue, and
 instead replace it with your own, specify what resource hints that file
 needs using the WordPress API.

 I'm marking this as `wontfix` again, conversation can continue while
 closed, and a committer can re-open if they so desire.

 For reference, this is what it would look like in a child theme:
 {{{
 add_action( 'wp_enqueue_scripts', function() {
     wp_dequeue_style( 'twentyseventeen-fonts' );
     wp_enqueue_style( 'my-theme-fonts',
 'https://fonts.googleapis.com/css....' );
 }, 11 );

 function mytheme_resource_hints( $urls, $relation_type ) {
         if ( wp_style_is( 'my-theme-fonts', 'queue' ) && 'preconnect' ===
 $relation_type ) {
                 $urls[] = array(
                         'href' => 'https://fonts.gstatic.com',
                         'crossorigin',
                 );
         }

         return $urls;
 }
 add_filter( 'wp_resource_hints', 'mytheme_resource_hints', 10, 2 );
 }}}
 There is nothing duplicative about specifically having that in there.

 Ideally, WordPress would have a extra param on `wp_register_style()` which
 would take in that `$urls[]` section and automatically append it when the
 stylesheet was enqueued - but that should be proposed in a different
 ticket instead.

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


More information about the wp-trac mailing list