[wp-trac] [WordPress Trac] #37694: Can't disable dns-prefetch to s.w.org

WordPress Trac noreply at wordpress.org
Wed Aug 17 14:48:14 UTC 2016


#37694: Can't disable dns-prefetch to s.w.org
---------------------------+----------------------
 Reporter:  superpoincare  |       Owner:
     Type:  defect (bug)   |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  Script Loader  |     Version:  4.6
 Severity:  normal         |  Resolution:  invalid
 Keywords:                 |     Focuses:
---------------------------+----------------------
Changes (by swissspidy):

 * status:  new => closed
 * resolution:   => invalid
 * component:  General => Script Loader
 * milestone:  Awaiting Review =>


Old description:

> According to the ticket 34292, dns-prefetch to s.w.org can be disabled
> with the following code (modified with the actual function):
>

> {{{
> function trac34292_example_resource_hints( $hints, $relation_type ) {
>     if ( 'dns-prefetch' === $relation_type ) {
>         return array_diff( $hints, wp_dependencies_unique_hosts() );
>     }
>
>     return $hints;
> }
>
> add_filter( 'wp_resource_hints', 'trac34292_example_resource_hints', 10,
> 2 );
> }}}
>
> However this doesn't work. I still see the dns-prefetch in HTML.

New description:

 According to the ticket #34292, dns-prefetch to s.w.org can be disabled
 with the following code (modified with the actual function):


 {{{
 function trac34292_example_resource_hints( $hints, $relation_type ) {
     if ( 'dns-prefetch' === $relation_type ) {
         return array_diff( $hints, wp_dependencies_unique_hosts() );
     }

     return $hints;
 }

 add_filter( 'wp_resource_hints', 'trac34292_example_resource_hints', 10, 2
 );
 }}}

 However this doesn't work. I still see the dns-prefetch in HTML.

--

Comment:

 Hey there,

 This code snippet I shared on #34292 was for removing resource hints for
 scripts and styles, not the s.w.org domain. That's why it doesn't work.

 `return array_diff( $hints, wp_dependencies_unique_hosts() );` means "keep
 all but scripts & styles".

 Instead, you'd want `array_diff( wp_dependencies_unique_hosts(), $hints
 )`, i.e. "keep scripts & styles but nothing else.

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


More information about the wp-trac mailing list