Changeset 38826 for trunk/src/wp-includes/general-template.php
- Timestamp:
- 10/19/2016 09:28:22 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r38786 r38826 2831 2831 2832 2832 foreach ( $hints as $relation_type => $urls ) { 2833 $unique_urls = array(); 2834 2833 2835 /** 2834 2836 * Filters domains and URLs for resource hints of relation type. … … 2842 2844 2843 2845 foreach ( $urls as $key => $url ) { 2846 $atts = array(); 2847 2848 if ( is_array( $url ) ) { 2849 if ( isset( $url['href'] ) ) { 2850 $atts = $url; 2851 $url = $url['href']; 2852 } else { 2853 continue; 2854 } 2855 } 2856 2844 2857 $url = esc_url( $url, array( 'http', 'https' ) ); 2858 2845 2859 if ( ! $url ) { 2846 unset( $urls[ $key ] );2847 2860 continue; 2848 2861 } 2849 2862 2863 if ( isset( $unique_urls[ $url ] ) ) { 2864 continue; 2865 } 2866 2850 2867 if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) { 2851 2868 $parsed = wp_parse_url( $url ); 2869 2852 2870 if ( empty( $parsed['host'] ) ) { 2853 unset( $urls[ $key ] );2854 2871 continue; 2855 2872 } … … 2863 2880 } 2864 2881 2865 $urls[ $key ] = $url; 2882 $atts['rel'] = $relation_type; 2883 $atts['href'] = $url; 2884 2885 $unique_urls[ $url ] = $atts; 2866 2886 } 2867 2887 2868 $urls = array_unique( $urls ); 2869 2870 foreach ( $urls as $url ) { 2871 printf( "<link rel='%s' href='%s' />\n", $relation_type, $url ); 2888 foreach ( $unique_urls as $atts ) { 2889 $html = ''; 2890 2891 foreach ( $atts as $attr => $value ) { 2892 if ( ! is_scalar( $value ) || 2893 ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr )) 2894 ) { 2895 continue; 2896 } 2897 2898 $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); 2899 2900 if ( ! is_string( $attr ) ) { 2901 $html .= " $value"; 2902 } else { 2903 $html .= " $attr='$value'"; 2904 } 2905 } 2906 2907 $html = trim( $html ); 2908 2909 echo "<link $html />\n"; 2872 2910 } 2873 2911 }
Note: See TracChangeset
for help on using the changeset viewer.