Make WordPress Core

Changeset 37922


Ignore:
Timestamp:
06/29/2016 09:04:25 PM (9 years ago)
Author:
ocean90
Message:

Script Loader: Use wp_parse_url() to fix URL parsing failures for PHP < 5.4.7.

See [37920].
See #34292.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r37920 r37922  
    28222822
    28232823            if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
    2824                 $parsed = parse_url( $url );
     2824                $parsed = wp_parse_url( $url );
     2825                if ( empty( $parsed['host'] ) ) {
     2826                    continue;
     2827                }
    28252828
    28262829                if ( ! empty( $parsed['scheme'] ) ) {
     
    28482851    if ( is_object( $wp_scripts ) && ! empty( $wp_scripts->registered ) ) {
    28492852        foreach ( $wp_scripts->registered as $registered_script ) {
    2850             $src = $registered_script->src;
    2851             // Make sure the URL has a scheme, otherwise parse_url() could fail to pass the host.
    2852             if ( '//' == substr( $src, 0, 2 ) ) {
    2853                 $src = set_url_scheme( $src );
    2854             }
    2855 
    2856             $this_host = parse_url( $src, PHP_URL_HOST );
    2857             if ( ! empty( $this_host ) && ! in_array( $this_host, $unique_hosts ) && $this_host !== $_SERVER['SERVER_NAME'] ) {
    2858                 $unique_hosts[] = $this_host;
     2853            $parsed = wp_parse_url( $registered_script->src );
     2854
     2855            if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
     2856                $unique_hosts[] = $parsed['host'];
    28592857            }
    28602858        }
     
    28632861    if ( is_object( $wp_styles ) && ! empty( $wp_styles->registered ) ) {
    28642862        foreach ( $wp_styles->registered as $registered_style ) {
    2865             $src = $registered_style->src;
    2866             // Make sure the URL has a scheme, otherwise parse_url() could fail to pass the host.
    2867             if ( '//' == substr( $src, 0, 2 ) ) {
    2868                 $src = set_url_scheme( $src );
    2869             }
    2870 
    2871             $this_host = parse_url( $src, PHP_URL_HOST );
    2872             if ( ! empty( $this_host ) && ! in_array( $this_host, $unique_hosts ) && $this_host !== $_SERVER['SERVER_NAME'] ) {
    2873                 $unique_hosts[] = $this_host;
     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'];
    28742867            }
    28752868        }
Note: See TracChangeset for help on using the changeset viewer.