darrenjacoby / intervention

WordPress plugin to configure wp-admin and application state using a single config file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments remove `WP_Scripts::localize ` error

jmerilainen opened this issue · comments

I was testing the new awesome application.discussion => false feature and noticed that it calls the Comments::remove() which calls BlockEditor::set('discussion', true) and finally it will call wp_localize_script('intervention-block-editor', 'config', 'discussion'). But the wp_localize_script function requires the last parameter to be array so it errors out.

Should the BlockEditor::set('discussion', true) be removed or have different value? (Or if it is still working progress, sorry to rush :D)

Hey @jmerilainen ,

I wasn't able to re-create the error, but did make a change, would you mind testing on your side for me?

b58bd8

@jmerilainen just checking in here, let me know.

Hey @darrenjacoby,

Sorry for ghosting suddenly, other things got over the way.

Yeah the format is now alright! But I still caught a minor error on front end which is missing dependencies of intervention-block-editor script. It requires wp-blocks, wp-edit-post scripts but I think those are enqueued only on admin.

I'm not yet super familiar with the codebase but for example this did the trick:

if (is_admin()) {
    BlockEditor::set(['discussion']);
}

@jmerilainen thanks, added into BlockEditor.php and will release soon!