Changeset 38100 for trunk/src/wp-includes/general-template.php
- Timestamp:
- 07/19/2016 02:34:42 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r38036 r38100 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(), … … 2852 2852 2853 2853 /** 2854 * Adds dns-prefetch for all scripts and styles enqueued from external hosts.2854 * Returns a list of unique hosts of all enqueued scripts and styles. 2855 2855 * 2856 2856 * @since 4.6.0 2857 */ 2858 function wp_resource_hints_scripts_styles() { 2857 * 2858 * @return array A list of unique hosts of enqueued scripts and styles. 2859 */ 2860 function wp_dependencies_unique_hosts() { 2859 2861 global $wp_scripts, $wp_styles; 2860 2862 2861 2863 $unique_hosts = array(); 2862 2864 2863 if ( is_object( $wp_scripts ) && ! empty( $wp_scripts->registered ) ) { 2864 foreach ( $wp_scripts->registered as $registered_script ) { 2865 $parsed = wp_parse_url( $registered_script->src ); 2866 2867 if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { 2868 $unique_hosts[] = $parsed['host']; 2869 } 2870 } 2871 } 2872 2873 if ( is_object( $wp_styles ) && ! empty( $wp_styles->registered ) ) { 2874 foreach ( $wp_styles->registered as $registered_style ) { 2875 $parsed = wp_parse_url( $registered_style->src ); 2876 2877 if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { 2878 $unique_hosts[] = $parsed['host']; 2865 foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) { 2866 if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) { 2867 foreach ( $dependencies->queue as $handle ) { 2868 /* @var _WP_Dependency $dependency */ 2869 $dependency = $dependencies->registered[ $handle ]; 2870 $parsed = wp_parse_url( $dependency->src ); 2871 2872 if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) { 2873 $unique_hosts[] = $parsed['host']; 2874 } 2879 2875 } 2880 2876 }
Note: See TracChangeset
for help on using the changeset viewer.