From c7be2d875e0dfd355522efbaf3e4fca54947768a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 9 Jul 2021 10:49:15 +0000 Subject: [PATCH] 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 --- src/wp-includes/script-loader.php | 12 ++++++------ src/wp-includes/widgets.php | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index b870e87a8f..a1392d469d 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -382,10 +382,12 @@ function wp_default_packages_inline_scripts( $scripts ) { 'after' ); - // wp-editor module is exposed as window.wp.editor - // Problem: there is quite some code expecting window.wp.oldEditor object available under window.wp.editor - // Solution: fuse the two objects together to maintain backward compatibility - // For more context, see https://github.com/WordPress/gutenberg/issues/33203 + /* + * wp-editor module is exposed as window.wp.editor. + * Problem: there is quite some code expecting window.wp.oldEditor object available under window.wp.editor. + * Solution: fuse the two objects together to maintain backward compatibility. + * For more context, see https://github.com/WordPress/gutenberg/issues/33203. + */ $scripts->add_inline_script( 'wp-editor', 'Object.assign( window.wp.editor, window.wp.oldEditor );', @@ -2269,8 +2271,6 @@ function wp_common_block_scripts_and_styles() { * Enqueues the global styles defined via theme.json. * * @since 5.8.0 - * - * @return void */ function wp_enqueue_global_styles() { if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) { diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php index a092c00c7d..2d1eb5d8ef 100644 --- a/src/wp-includes/widgets.php +++ b/src/wp-includes/widgets.php @@ -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' );