Problems are the prefetch link tags
in my case they are „pointing“ to to wrong location
e.g.:
<link href="/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.19" as="script" rel="prefetch">
should be –>
<link href="/wp/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.19" as="script" rel="prefetch">
WP_SITEURL should be used (for these links) instead of WP_HOME
hint:
WP_SITEURL or site_url() (see: “WordPress-Address (URL)” in General > Settings)
WP_HOME or home_url() (see: “Website-Address (URL)” in General > Settings)
on some installations WP_SITEURL !== WP_HOME
here is a quick fix (404 gone)
WooCommerce (Version 6.9.3)
file:
[…]/plugins/woocommerce/packages/woocommerce-blocks/src/AssetsController.php
line 118
change:
'href' => $src,
to:
'href' => ( null === parse_url( $src )['host'] ? site_url() : '' ) . $src,
full array_merge block
$urls = array_merge(
$urls,
array_map(
function( $src ) {
return array(
'href' => ( null === parse_url( $src )['host'] ? site_url() : '' ) . $src,
'as' => 'script',
);
},
array_unique( array_filter( $resources ) )
)
);
@l3l3 – this is only half the rent, for this shows 29times:
Notice: Undefined index: host in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/AssetsController.php on line 121
I wonder if woocommerce authors are aware of this?
-
This reply was modified 1 year, 7 months ago by timholz.
-
This reply was modified 1 year, 7 months ago by timholz.
@timholz
okay you are using php7
here:
$urls = array_merge(
$urls,
array_map(
function( $src ) {
$url = parse_url( $src );
$href = ( !array_key_exists( 'host', $url ) ? site_url() : '' ) . $src;
return array(
'href' => $href,
'as' => 'script',
);
},
array_unique( array_filter( $resources ) )
)
);
or shorter (one-line)
$urls = array_merge(
$urls,
array_map(
function( $src ) {
return array(
'href' => ( !array_key_exists( 'host', parse_url( $src ) ) ? site_url() : '' ) . $src,
'as' => 'script',
);
},
array_unique( array_filter( $resources ) )
)
);
@l3l3 thanks for the info. Have a nice evening.
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad