$src =
$wp_scripts->registered
[ $handle ]->src;
if ( !
preg_match( '|^(https?:)?//|',
$src ) && !
( $wp_scripts->content_url &&
str_starts_with( $src,
$wp_scripts->content_url
) ) ) { $src =
$wp_scripts->base_url .
$src;
} $relative = false;
$languages_path = WP_LANG_DIR;
$src_url =
wp_parse_url( $src );
$content_url =
wp_parse_url( content_url() );
$plugins_url =
wp_parse_url( plugins_url() );
$site_url =
wp_parse_url( site_url() );
// If the host is the same or it's a relative URL.
if ( ( !
isset( $content_url['path'
] ) ||
str_starts_with( $src_url['path'
],
$content_url['path'
] ) ) && ( !
isset( $src_url['host'
] ) || !
isset( $content_url['host'
] ) ||
$src_url['host'
] ===
$content_url['host'
] ) ) { // Make the src relative the specific plugin or theme.
if ( isset( $content_url['path'
] ) ) { $relative =
substr( $src_url['path'
],
strlen( $content_url['path'
] ) );
}