diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
index 4f2be9f..df0cdd0 100644
|
|
|
function wp_site_icon() { |
| 2799 | 2799 | */ |
| 2800 | 2800 | function wp_resource_hints() { |
| 2801 | 2801 | $hints = array( |
| 2802 | | 'dns-prefetch' => wp_resource_hints_scripts_styles(), |
| | 2802 | 'dns-prefetch' => wp_dependencies_unique_hosts(), |
| 2803 | 2803 | 'preconnect' => array( 's.w.org' ), |
| 2804 | 2804 | 'prefetch' => array(), |
| 2805 | 2805 | 'prerender' => array(), |
| … |
… |
function wp_resource_hints() { |
| 2839 | 2839 | } |
| 2840 | 2840 | |
| 2841 | 2841 | /** |
| 2842 | | * Adds dns-prefetch for all scripts and styles enqueued from external hosts. |
| | 2842 | * Returns a list of unique hosts of all enqueued scripts and styles. |
| 2843 | 2843 | * |
| 2844 | 2844 | * @since 4.6.0 |
| | 2845 | * |
| | 2846 | * @return array A list of unique hosts of enqueued scripts and styles. |
| 2845 | 2847 | */ |
| 2846 | | function wp_resource_hints_scripts_styles() { |
| | 2848 | function wp_dependencies_unique_hosts() { |
| 2847 | 2849 | global $wp_scripts, $wp_styles; |
| 2848 | 2850 | |
| 2849 | 2851 | $unique_hosts = array(); |
| 2850 | 2852 | |
| 2851 | | if ( is_object( $wp_scripts ) && ! empty( $wp_scripts->registered ) ) { |
| 2852 | | foreach ( $wp_scripts->registered as $registered_script ) { |
| 2853 | | $parsed = wp_parse_url( $registered_script->src ); |
| | 2853 | foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { |
| | 2854 | if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { |
| | 2855 | foreach ( $dependencies->queue as $handle ) { |
| | 2856 | /* @var _WP_Dependency $dependency */ |
| | 2857 | $dependency = $dependencies->registered[ $handle ]; |
| | 2858 | $parsed = wp_parse_url( $dependency->src ); |
| 2854 | 2859 | |
| 2855 | | if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { |
| 2856 | | $unique_hosts[] = $parsed['host']; |
| 2857 | | } |
| 2858 | | } |
| 2859 | | } |
| 2860 | | |
| 2861 | | if ( is_object( $wp_styles ) && ! empty( $wp_styles->registered ) ) { |
| 2862 | | foreach ( $wp_styles->registered as $registered_style ) { |
| 2863 | | $parsed = wp_parse_url( $registered_style->src ); |
| 2864 | | |
| 2865 | | if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { |
| 2866 | | $unique_hosts[] = $parsed['host']; |
| | 2860 | if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { |
| | 2861 | $unique_hosts[] = $parsed['host']; |
| | 2862 | } |
| 2867 | 2863 | } |
| 2868 | 2864 | } |
| 2869 | 2865 | } |