From 1eb5f61c9e5c36a5e587010bf8e4d1e811da56e0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 20 Sep 2024 14:07:11 +0000 Subject: [PATCH] Editor: Restore the merging of TinyMCE settings in `wp_tinymce_inline_scripts()`. This ensures that the function applies the `wp_editor_settings` filter and merges the resulting array with the rest of TinyMCE init settings. Includes a unit test to verify that the settings are merged correctly after adding the assignment of `array_merge()` result that was missed in the initial commit. Follow-up to [44265], [59033]. Props kkmuffme, akshat2802, davidbaumwald, SergeyBiryukov. Fixes #61754. git-svn-id: https://develop.svn.wordpress.org/trunk@59074 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 4 ++ .../tests/editor/wpTinyMceInlineScripts.php | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/phpunit/tests/editor/wpTinyMceInlineScripts.php diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index a8540157b9f56..2da46f1332e7f 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -609,6 +609,10 @@ function wp_tinymce_inline_scripts() { $tinymce_settings['wpeditimage_disable_captions'] = true; } + if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) { + $tinymce_settings = array_merge( $tinymce_settings, $editor_settings['tinymce'] ); + } + /** This filter is documented in wp-includes/class-wp-editor.php */ $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' ); diff --git a/tests/phpunit/tests/editor/wpTinyMceInlineScripts.php b/tests/phpunit/tests/editor/wpTinyMceInlineScripts.php new file mode 100644 index 0000000000000..b2341291f42f1 --- /dev/null +++ b/tests/phpunit/tests/editor/wpTinyMceInlineScripts.php @@ -0,0 +1,39 @@ + true ); + return $settings; + } + ); + + add_filter( + 'tiny_mce_before_init', + static function ( $tinymce_settings ) use ( &$merged_settings ) { + $merged_settings = $tinymce_settings; + return $tinymce_settings; + } + ); + + wp_scripts(); + wp_tinymce_inline_scripts(); + + $this->assertArrayHasKey( 'wp_autoresize_on', $merged_settings ); + } +}