diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
index 75dadfc..ae0f9cd 100644
|
|
|
add_action( 'wp_head', 'wp_print_styles', 8 ); |
| 233 | 233 | add_action( 'wp_head', 'wp_print_head_scripts', 9 ); |
| 234 | 234 | add_action( 'wp_head', 'wp_generator' ); |
| 235 | 235 | add_action( 'wp_head', 'rel_canonical' ); |
| | 236 | add_action( 'wp_head', 'wp_dns_prefetch' ); |
| 236 | 237 | add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); |
| 237 | 238 | add_action( 'wp_head', 'wp_site_icon', 99 ); |
| 238 | 239 | add_action( 'wp_footer', 'wp_print_footer_scripts', 20 ); |
diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
index 23525b5..8ec9629 100644
|
|
|
function wp_site_icon() { |
| 2523 | 2523 | } |
| 2524 | 2524 | |
| 2525 | 2525 | /** |
| | 2526 | * Prints out domains to prefetch for page speed optimization. |
| | 2527 | * |
| | 2528 | * @since 4.4.0 |
| | 2529 | */ |
| | 2530 | function wp_dns_prefetch() { |
| | 2531 | /** |
| | 2532 | * Filter the domains to prefetch for page speed optimization. |
| | 2533 | * |
| | 2534 | * @since 4.4.0 |
| | 2535 | * |
| | 2536 | * @param array $prefetch_urls Domains to prefetch. |
| | 2537 | */ |
| | 2538 | $prefetch_domains = apply_filters( 'dns_prefetch_domains', array() ); |
| | 2539 | $prefetch_domains = array_unique( array_map( 'strtolower', $prefetch_domains ) ); |
| | 2540 | |
| | 2541 | foreach ( $prefetch_domains as $domain ) { |
| | 2542 | $domain = esc_url( untrailingslashit( $domain ), array('http', 'https') ); |
| | 2543 | printf( "<link rel='dns-prefetch' href='%s'>\r\n", $domain ); |
| | 2544 | } |
| | 2545 | } |
| | 2546 | |
| | 2547 | /** |
| 2526 | 2548 | * Whether the user should have a WYSIWIG editor. |
| 2527 | 2549 | * |
| 2528 | 2550 | * Checks that the user requires a WYSIWIG editor and that the editor is |
diff --git tests/phpunit/tests/general/template.php tests/phpunit/tests/general/template.php
index f935a1b..39a935c 100644
|
|
|
class Tests_General_Template extends WP_UnitTestCase { |
| 177 | 177 | $this->site_icon_id = wp_insert_attachment( $attachment, $upload['file'] ); |
| 178 | 178 | wp_update_attachment_metadata( $this->site_icon_id, wp_generate_attachment_metadata( $this->site_icon_id, $upload['file'] ) ); |
| 179 | 179 | } |
| | 180 | |
| | 181 | /** |
| | 182 | * @ticket 34292 |
| | 183 | */ |
| | 184 | function test_wp_dns_prefetch() { |
| | 185 | $this->assertEmpty( get_echo( 'wp_dns_prefetch' ) ); |
| | 186 | |
| | 187 | add_filter( 'dns_prefetch_domains', array( $this, '_add_dns_prefetch_domains' ) ); |
| | 188 | |
| | 189 | $expected = "<link rel='dns-prefetch' href='http://wordpress.org'>\r\n" . |
| | 190 | "<link rel='dns-prefetch' href='https://google.com'>\r\n" . |
| | 191 | "<link rel='dns-prefetch' href='//make.wordpress.org'>\r\n"; |
| | 192 | |
| | 193 | $this->assertEquals( $expected, get_echo( 'wp_dns_prefetch' ) ); |
| | 194 | } |
| | 195 | |
| | 196 | function _add_dns_prefetch_domains( $domains ) { |
| | 197 | $domains[] = 'http://wordpress.org'; |
| | 198 | $domains[] = 'https://google.com'; |
| | 199 | $domains[] = '//make.wordpress.org'; |
| | 200 | |
| | 201 | return $domains; |
| | 202 | } |
| 180 | 203 | } |