From 5548ab1e975211434a2e9d01e71b4f80a3b5775a Mon Sep 17 00:00:00 2001 From: Luigi Date: Mon, 11 Jul 2022 14:16:55 +0200 Subject: [PATCH] Fix loading deps when WordPress is installed in a subdir #6500 Fix loading deps when WordPress is installed in a subdir --- src/BlockTypes/MiniCart.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 80e9330ce40..8028cfd985a 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -276,8 +276,12 @@ protected function append_script_and_deps_src( $script ) { if ( ! $script->src ) { return; } + + $site_url = get_site_url(); + $path = wp_parse_url( $site_url )['path'] ?? ''; + $this->scripts_to_lazy_load[ $script->handle ] = array( - 'src' => $script->src, + 'src' => wp_http_validate_url( $script->src ) ? $script->src : $path . $script->src, 'version' => $script->ver, 'before' => $wp_scripts->print_inline_script( $script->handle, 'before', false ), 'after' => $wp_scripts->print_inline_script( $script->handle, 'after', false ),