[wp-trac] [WordPress Trac] #53437: Widgets Screen: wp.editor.initialize is not a function notice

WordPress Trac noreply at wordpress.org
Thu Jul 8 01:42:49 UTC 2021


#53437: Widgets Screen: wp.editor.initialize is not a function notice
--------------------------+-------------------------
 Reporter:  noisysocks    |       Owner:  noisysocks
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  5.8
Component:  Widgets       |     Version:
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:
--------------------------+-------------------------

Comment (by noisysocks):

 Testing https://github.com/WordPress/wordpress-develop/pull/1481:

 - ✅ No error when loading new widgets screen with a Text legacy widget,
 5.8, patch not applied, no plugins. (Because it was fixed in [51202].)
 - ✅ No error when loading new widgets screen with a Text legacy widget,
 5.8, patch applied, no plugins.
 - ✅ `wp.editor.initialize` error when loading new widgets screen with a
 Text legacy widget, 5.8, patch not applied, CoBlocks plugin. (This is what
 we're aiming to fix.)
 - ✅ No error when loading new widgets screen with a Text legacy widget,
 5.8, patch applied, CoBlocks plugin.
 - ✅ When I visit the classic widgets screen, I can see that `wp.oldEditor
 === wp.editor` is true in DevTools.
 - ✅ When I visit the new widgets screen, I can see that `wp.oldEditor ===
 wp.editor` is false and that `wp.editor.initialize` is defined in
 DevTools.
 - ✅ When I visit the post block editor, I can see that `wp.oldEditor ===
 wp.editor` is false and that `wp.editor.initialize` is defined in
 DevTools.

 So, all seems good! I think it's a neat solution. It stops user-facing
 errors caused by a plugin incorrectly enqueuing `wp-editor` on the widgets
 screen.

 However, we also ought to encourage plugins to not enqueue `wp-editor` on
 the widgets screen. Doing so does not make sense as `wp-editor` provides
 functions for working with a ''post'' editor. The widgets screen has no
 post object. Usually this happens because `wp-editor` is a dependency of
 some other script and the plugin a author is unaware. This is where
 https://github.com/WordPress/wordpress-develop/pull/1484 comes in, which
 calls `_doing_it_wrong()` when `wp-editor` is enqueued alongside `wp-edit-
 post`.

 Testing https://github.com/WordPress/wordpress-develop/pull/1484:

 - ✅ No warning when loading new widgets screen, 5.8, patch applied, no
 plugins.
 - ✅ `_doing_it_wrong()` warning when loading new widgets screen, 5.8,
 patch applied, CoBlocks plugin, `WP_DEBUG` enabled.
 - ✅ No warning when loading new widgets screen, 5.8, patch applied,
 CoBlocks plugin, `WP_DEBUG` disabled.

 So, all seems good there too! Two bits of feedback on the code:

 - To clarify, does this check style deps as well? If so it should fix
 #53569.
 - Placing this very specific bit of logic in
 `WP_Dependencies::recurse_deps()` doesn't feel right to me. It's a low
 level "system" function. Can we move the check to a late-firing hook
 (`wp_loaded`?) and use the public`$wp_scripts->query()` method instead?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53437#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list