Scripts: Ensure sub-directory WordPress installs can load polyfill scripts.
`wp_get_script_polyfill()` bypasses `WP_Scripts::do_item()`, so didn't transform the script path into its fully qualified URL. Props swissspidy, ocean90. Merges [43960] to trunk. Fixes #45469. git-svn-id: https://develop.svn.wordpress.org/trunk@44286 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fc48870953
commit
c7cc0cebe0
@ -178,6 +178,24 @@ function wp_get_script_polyfill( &$scripts, $tests ) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$src = $scripts->registered[ $handle ]->src;
|
||||||
|
$ver = $scripts->registered[ $handle ]->ver;
|
||||||
|
|
||||||
|
if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
|
||||||
|
$src = $scripts->base_url . $src;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $ver ) ) {
|
||||||
|
$src = add_query_arg( 'ver', $ver, $src );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This filter is documented in wp-includes/class.wp-scripts.php */
|
||||||
|
$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
|
||||||
|
|
||||||
|
if ( ! $src ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$polyfill .= (
|
$polyfill .= (
|
||||||
// Test presence of feature...
|
// Test presence of feature...
|
||||||
'( ' . $test . ' ) || ' .
|
'( ' . $test . ' ) || ' .
|
||||||
@ -185,7 +203,7 @@ function wp_get_script_polyfill( &$scripts, $tests ) {
|
|||||||
// at the `document.write`. Its caveat of synchronous mid-stream
|
// at the `document.write`. Its caveat of synchronous mid-stream
|
||||||
// blocking write is exactly the behavior we need though.
|
// blocking write is exactly the behavior we need though.
|
||||||
'document.write( \'<script src="' .
|
'document.write( \'<script src="' .
|
||||||
esc_url( $scripts->registered[ $handle ]->src ) .
|
$src .
|
||||||
'"></scr\' + \'ipt>\' );'
|
'"></scr\' + \'ipt>\' );'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user