WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/09/2021 05:56:43 PM (4 months ago)
Author:
desrosj
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.

Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu, dlh, noisysocks.
Merges [51388] to the 5.8 branch.
Fixes #53569. See #53437.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/wp-includes/default-filters.php

    r51347 r51393  
    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.