Make WordPress Core


Ignore:
Timestamp:
07/09/2021 01:17:41 AM (3 years ago)
Author:
noisysocks
Message:

Widgets: Warn when wp-editor script or wp-edit-post style is enqueued in widgets editor

It is common that plugins erroneously have wp-editor or wp-edit-post as a
dependency in a script that is loaded in the new widgets editor. This is a smell
since both @wordpress/editor and @wordpress/edit-post assume the existence
of a global "post" object which the widgets editor does not have.

[51387] fixes the user-facing errors typically caused by this mistake, but we
can go a step further and warn developers about this by calling
_doing_it_wrong() when we detect that the wp-editor script or wp-edit-post
style is enqueued alongside wp-edit-widgets or wp-customize-widgets.

See #53437.
Fixes #53569.
Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu, dlh.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r51309 r51388  
    567567add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
    568568add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
     569add_action( 'admin_head', 'wp_check_widget_editor_deps' );
    569570
    570571// Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494.
Note: See TracChangeset for help on using the changeset viewer.