Docs: Some documentation improvements for wp_check_widget_editor_deps():

* Add missing short description for the function.
* Correct function names in `_doing_it_wrong()` calls.
* Document the usage of `$wp_scripts` and `$wp_styles` globals.
* Update syntax for multi-line comment per the documentation standards.

Follow-up to [51387], [51388].

See #53437, #53569.

git-svn-id: https://develop.svn.wordpress.org/trunk@51390 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-07-09 10:49:15 +00:00
parent 7de1b7c0ae
commit c7be2d875e
2 changed files with 18 additions and 12 deletions

View File

@@ -2008,34 +2008,40 @@ function wp_render_widget_control( $id ) {
}
/**
* Displays a _doing_it_wrong() message for conflicting widget editor scripts.
*
* The 'wp-editor' script module is exposed as window.wp.editor. This overrides
* the legacy TinyMCE editor module which is required by the widgets editor.
* Because of that conflict, these two shouldn't be enqueued together. See
* https://core.trac.wordpress.org/ticket/53569.
* Because of that conflict, these two shouldn't be enqueued together.
* See https://core.trac.wordpress.org/ticket/53569.
*
* There is also another conflict related to styles where the block widgets
* editor is hidden if a block enqueues 'wp-edit-post' stylesheet. See
* https://core.trac.wordpress.org/ticket/53569.
* editor is hidden if a block enqueues 'wp-edit-post' stylesheet.
* See https://core.trac.wordpress.org/ticket/53569.
*
* @since 5.8.0
* @access private
*
* @global WP_Scripts $wp_scripts
* @global WP_Styles $wp_styles
*/
function wp_check_widget_editor_deps() {
global $wp_scripts, $wp_styles;
if (
$wp_scripts->query( 'wp-edit-widgets', 'enqueued' ) ||
$wp_scripts->query( 'wp-customize-widgets', 'enqueued' )
) {
if ( $wp_scripts->query( 'wp-editor', 'enqueued' ) ) {
_doing_it_wrong(
'enqueue_script',
'wp_enqueue_script()',
'"wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets).',
'5.8.0'
);
}
if ( $wp_styles->query( 'wp-edit-post', 'enqueued' ) ) {
_doing_it_wrong(
'enqueue_style',
'wp_enqueue_style()',
'"wp-edit-post" style should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets).',
'5.8.0'
);