• Hello all,

    I updated a local dev version of one of my websites to check if it will work with 5.8.

    I am using a self developed AMP-only theme, hence I had to remove some filters and stuff from wordpress head loading. I have already found which line results in the error:

    remove_action('wp_head', 'wp_enqueue_scripts', 1);

    This leads to the following error:

    Warning: Invalid argument supplied for foreach() in /wp-includes/script-loader.php on line 2652

    Any idea how I can get both to work? If I don’t remove the scripts from the head which WordPress normally loads the AMP-checker won’t be satisfied and shows errors, then my website will no longer be AMP-compliant.

    Any help is appreciated.

    Thanks a lot.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @sajonara. My complete guess is that the $wp_styles global is not being set because you are removing the code which initialises it. Does this fix the problem?

    add_action( 'wp_head', 'wp_styles', 1 );
    
    Thread Starter sajonara

    (@sajonara)

    Dear @noisysocks, I tried this, but it did not help.

    But I am trying to allow the enqueue_scripts and instead filter different parts of the head out. Let’s see where this takes me. Still if anybody has an idea. I looked at the code, there is an object populated and obviously it then has no elements. I wonder if I could to a dummy.

    This is line 2652:

    foreach ( $wp_styles->queue as $handle ) {

    Kind regards

    • This reply was modified 3 years, 4 months ago by sajonara.

    I wonder if I could to a dummy.

    Yeah that might work. Something like this.

    add_action( 'wp_head', function() {
    	global $wp_styles;
    	$wp_styles->queue = array();
    }, 1 );
    

    Any resolution on this? Literally all my websites have been generating huge error_log files ever since 5.8, and I’m stumped as to what happened!

    – Deleted

    • This reply was modified 3 years, 2 months ago by frogsplash. Reason: Posted in wrong thread, my apologies
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invalid argument in script-loader after update to 5.8’ is closed to new replies.