From 2f7425994b471edad4a0d9198ce15296f49c52be Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 13 Jul 2022 12:42:28 +0200 Subject: [PATCH] Mini Cart: Fix loading deps when WordPress is installed in a subdir (#6673) * Fix loading deps when WordPress is installed in a subdir #6500 Fix loading deps when WordPress is installed in a subdir * update logic --- src/BlockTypes/MiniCart.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 80e9330ce40..53a0f91d891 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -276,8 +276,11 @@ protected function append_script_and_deps_src( $script ) { if ( ! $script->src ) { return; } + + $site_url = site_url() ?? wp_guess_url(); + $this->scripts_to_lazy_load[ $script->handle ] = array( - 'src' => $script->src, + 'src' => preg_match( '|^(https?:)?//|', $script->src ) ? $script->src : $site_url . $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 ),