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

See [37920].
See #34292.
Built from https://develop.svn.wordpress.org/trunk@37922


git-svn-id: http://core.svn.wordpress.org/trunk@37863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-06-29 21:05:28 +00:00
parent f7465bfcf3
commit 6c10cda818
2 changed files with 11 additions and 18 deletions

View File

@ -2821,7 +2821,10 @@ function wp_resource_hints() {
$url = esc_url( $url, array( 'http', 'https' ) );
if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
$parsed = parse_url( $url );
$parsed = wp_parse_url( $url );
if ( empty( $parsed['host'] ) ) {
continue;
}
if ( ! empty( $parsed['scheme'] ) ) {
$url = $parsed['scheme'] . '://' . $parsed['host'];
@ -2847,30 +2850,20 @@ function wp_resource_hints_scripts_styles() {
if ( is_object( $wp_scripts ) && ! empty( $wp_scripts->registered ) ) {
foreach ( $wp_scripts->registered as $registered_script ) {
$src = $registered_script->src;
// Make sure the URL has a scheme, otherwise parse_url() could fail to pass the host.
if ( '//' == substr( $src, 0, 2 ) ) {
$src = set_url_scheme( $src );
}
$parsed = wp_parse_url( $registered_script->src );
$this_host = parse_url( $src, PHP_URL_HOST );
if ( ! empty( $this_host ) && ! in_array( $this_host, $unique_hosts ) && $this_host !== $_SERVER['SERVER_NAME'] ) {
$unique_hosts[] = $this_host;
if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
$unique_hosts[] = $parsed['host'];
}
}
}
if ( is_object( $wp_styles ) && ! empty( $wp_styles->registered ) ) {
foreach ( $wp_styles->registered as $registered_style ) {
$src = $registered_style->src;
// Make sure the URL has a scheme, otherwise parse_url() could fail to pass the host.
if ( '//' == substr( $src, 0, 2 ) ) {
$src = set_url_scheme( $src );
}
$parsed = wp_parse_url( $registered_style->src );
$this_host = parse_url( $src, PHP_URL_HOST );
if ( ! empty( $this_host ) && ! in_array( $this_host, $unique_hosts ) && $this_host !== $_SERVER['SERVER_NAME'] ) {
$unique_hosts[] = $this_host;
if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
$unique_hosts[] = $parsed['host'];
}
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-alpha-37921';
$wp_version = '4.6-alpha-37922';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.