soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Notice: WP_Scripts::localize was called incorrectly #1990

Closed swinggraphics closed 3 years ago

swinggraphics commented 3 years ago

Oxygen 3.7.1 is the only active plugin WP 5.7 This notice renders the editor unusable.

Spellhammer commented 3 years ago

Please post the full notice or error log so we can see which line of code it's referencing.

For now, set WP_DEBUG_DISPLAY to false so that the notice doesn't get injected in the builder.

swinggraphics commented 3 years ago

Ok, but you need to turn debug on during development in order to catch these bugs before a release, and also while debugging, so can replicate the issue and know when it's fixed.

Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /wp-includes/functions.php on line 5313

lothisoft commented 3 years ago

Can you give us some guidance on when this bug will be fixed? I suspect I'm experiencing follow-up bugs that are difficult to pinpoint e.g. saving reusable part templates can no longer be saved. I receive "Please contact support" error messages.

jojojojojoj5564656465465 commented 3 years ago

Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /home/ybrv7474/nouveau-site/wordpress/wp-includes/functions.php on line 5313

JohnTendik commented 3 years ago

I hate to be that guy, but this bug renders the editor completely useless and turning off Debug mode is not an option since we are developing plugins of our own and need the debug information.

I did some digging and this is where the error happens:

if ( $hook == 'post.php' || $hook == 'edit.php' ) {
        if ( 'ct_template' === $post->post_type ) {
            wp_register_script('ct_template_edit_add', CT_FW_URI.'/admin/ct_template_edit_add.js');
            wp_localize_script( 'ct_template_edit_add', 'ct_template_add_reusable_link', add_query_arg(array('post_type'=>'ct_template', 'is_reusable'=>'true'),admin_url('post-new.php')) ) ;
            wp_enqueue_script(  'ct_template_edit_add' );
        }
    }

in /framework/admin/pages.php

I added an array around the add_query_arg and it got rid of the warning, however Im not sure what the side effects for this would be, I didn't dig too deep. Ill let someone more knowledgable take a look at a proper fix lol

wkoehn commented 3 years ago

Yep, I'm seeing this also - latest stable Oxygen/WP, and PHP 7.4.1 on LocalWP. PS to you all developing plugins, use Query Monitor to capture and display the errors so they don't spill out into the UI...

KittenCodes commented 3 years ago

Fixed in v3.8 Beta 1.