WordPress.org

Make WordPress Core

Ticket #37387: 37387.diff

File 37387.diff, 4.2 KB (added by peterwilsoncc, 4 years ago)
  • src/wp-includes/general-template.php

    diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
    index ca48499..d1a4982 100644
    function wp_site_icon() { 
    27952795 *
    27962796 * These performance improving indicators work by using `<link rel"…">`.
    27972797 *
     2798 * TODO - Move Emoji CDN hinting to the JavaScript loader.
     2799 *
    27982800 * @since 4.6.0
    27992801 */
    28002802function wp_resource_hints() {
    28012803        $hints = array(
    28022804                'dns-prefetch' => wp_dependencies_unique_hosts(),
    2803                 'preconnect'   => array( 's.w.org' ),
     2805                'preconnect'   => array(),
    28042806                'prefetch'     => array(),
    28052807                'prerender'    => array(),
    28062808        );
    28072809
     2810        // Add DNS prefetch for the Emoji CDN.
     2811        // The path is removed in the foreach loop below.
     2812        /** This filter is documented in wp-includes/formatting.php */
     2813        $hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );
     2814
    28082815        foreach ( $hints as $relation_type => $urls ) {
    28092816                /**
    28102817                 * Filters domains and URLs for resource hints.
  • tests/phpunit/tests/general/resourceHints.php

    diff --git tests/phpunit/tests/general/resourceHints.php tests/phpunit/tests/general/resourceHints.php
    index 95958e7..7546875 100644
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    3131        }
    3232
    3333        function test_should_have_defaults_on_frontend() {
    34                 $expected = "<link rel='preconnect' href='http://s.w.org'>\n";
     34                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
    3535
    3636                $this->expectOutputString( $expected );
    3737
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    3939        }
    4040
    4141        function test_dns_prefetching() {
    42                 $expected = "<link rel='dns-prefetch' href='//wordpress.org'>\n" .
     42                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
     43                                        "<link rel='dns-prefetch' href='//wordpress.org'>\n" .
    4344                                        "<link rel='dns-prefetch' href='//google.com'>\n" .
    44                                         "<link rel='dns-prefetch' href='//make.wordpress.org'>\n" .
    45                                         "<link rel='preconnect' href='http://s.w.org'>\n";
     45                                        "<link rel='dns-prefetch' href='//make.wordpress.org'>\n";
    4646
    4747                add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ), 10, 2 );
    4848
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    6767        }
    6868
    6969        function test_prerender() {
    70                 $expected = "<link rel='preconnect' href='http://s.w.org'>\n" .
     70                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
    7171                                        "<link rel='prerender' href='https://make.wordpress.org/great-again'>\n" .
    7272                                        "<link rel='prerender' href='http://jobs.wordpress.net'>\n" .
    7373                                        "<link rel='prerender' href='//core.trac.wordpress.org'>\n";
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    9393        }
    9494
    9595        function test_parse_url_dns_prefetch() {
    96                 $expected = "<link rel='dns-prefetch' href='//make.wordpress.org'>\n" .
    97                                         "<link rel='preconnect' href='http://s.w.org'>\n";
     96                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
     97                                        "<link rel='dns-prefetch' href='//make.wordpress.org'>\n";
    9898
    9999                add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ), 10, 2 );
    100100
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    115115
    116116        function test_dns_prefetch_styles() {
    117117                $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
    118                                         "<link rel='preconnect' href='http://s.w.org'>\n";
     118                                        "<link rel='dns-prefetch' href='//s.w.org'>\n";
    119119
    120120                $args = array(
    121121                        'family' => 'Open+Sans:400',
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    134134
    135135        function test_dns_prefetch_scripts() {
    136136                $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
    137                                         "<link rel='preconnect' href='http://s.w.org'>\n";
     137                                        "<link rel='dns-prefetch' href='//s.w.org'>\n";
    138138
    139139                $args = array(
    140140                        'family' => 'Open+Sans:400',
    class Tests_WP_Resource_Hints extends WP_UnitTestCase { 
    151151        }
    152152
    153153        function test_dns_prefetch_scripts_does_not_included_registered_only() {
    154                 $expected = "<link rel='preconnect' href='http://s.w.org'>\n";
     154                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
    155155                $unexpected = "<link rel='dns-prefetch' href='//wordpress.org'>\n";
    156156
    157157                wp_register_script( 'jquery-elsewhere', 'https://wordpress.org/wp-includes/js/jquery/jquery.js' );