From dbc692fb84430b4aec897dce023c6754f7dca36e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 17 Dec 2018 03:27:12 +0000 Subject: [PATCH] Block Editor: Load TinyMCE inline scripts later. Previously, the TinyMCE inline scripts were added on the `init` action in the block editor. In the classic editor, however, these scripts are loaded when the TinyMCE window is printed, and some plugins rely on them being loaded later, so they can attach to the appropriate filters. Props pento. Merges [43901] to trunk. Fixes #45338. Built from https://develop.svn.wordpress.org/trunk@44251 git-svn-id: http://core.svn.wordpress.org/trunk@44081 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-blocks.php | 1 + wp-includes/script-loader.php | 14 ++++++++++++-- wp-includes/version.php | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/wp-admin/edit-form-blocks.php b/wp-admin/edit-form-blocks.php index 2ee0ba988a..0f4ccee94b 100644 --- a/wp-admin/edit-form-blocks.php +++ b/wp-admin/edit-form-blocks.php @@ -305,6 +305,7 @@ wp_enqueue_media( 'post' => $post->ID, ) ); +wp_tinymce_inline_scripts(); wp_enqueue_editor(); /** diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 6a3cf7d5e5..245d12d687 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -475,8 +475,18 @@ function wp_default_packages_inline_scripts( &$scripts ) { 'window.wp.oldEditor = window.wp.editor;', 'after' ); +} + +/** + * Adds inline scripts required for the TinyMCE in the block editor. + * + * @since 5.0.0 + * + * @global WP_Scripts $wp_scripts + */ +function wp_tinymce_inline_scripts() { + global $wp_scripts; - // TinyMCE init. $tinymce_plugins = array( 'charmap', 'colorpicker', @@ -587,7 +597,7 @@ function wp_default_packages_inline_scripts( &$scripts ) { } }'; - $scripts->add_inline_script( 'wp-block-library', $script, 'before' ); + $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index eaa01a9448..32ffc3ad5b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44250'; +$wp_version = '5.1-alpha-44251'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.