Skip to content

Commit 179daa9

Browse files
SergeyBiryukovaslamdoctor
authored andcommitted
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
1 parent 9e96b0e commit 179daa9

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/wp-includes/script-loader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ function wp_tinymce_inline_scripts() {
609609
$tinymce_settings['wpeditimage_disable_captions'] = true;
610610
}
611611

612+
if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
613+
$tinymce_settings = array_merge( $tinymce_settings, $editor_settings['tinymce'] );
614+
}
615+
612616
/** This filter is documented in wp-includes/class-wp-editor.php */
613617
$tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
614618

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* @group editor
4+
*
5+
* @covers ::wp_tinymce_inline_scripts
6+
*/
7+
class Tests_Editor_wpTinyMceInlineScripts extends WP_UnitTestCase {
8+
9+
/**
10+
* Tests that the function applies the `wp_editor_settings` filter
11+
* and merges the resulting array with the rest of TinyMCE init settings.
12+
*
13+
* @ticket 61754
14+
*/
15+
public function test_wp_tinymce_inline_scripts_array_merge() {
16+
$merged_settings = array();
17+
18+
add_filter(
19+
'wp_editor_settings',
20+
static function ( $settings ) {
21+
$settings['tinymce'] = array( 'wp_autoresize_on' => true );
22+
return $settings;
23+
}
24+
);
25+
26+
add_filter(
27+
'tiny_mce_before_init',
28+
static function ( $tinymce_settings ) use ( &$merged_settings ) {
29+
$merged_settings = $tinymce_settings;
30+
return $tinymce_settings;
31+
}
32+
);
33+
34+
wp_scripts();
35+
wp_tinymce_inline_scripts();
36+
37+
$this->assertArrayHasKey( 'wp_autoresize_on', $merged_settings );
38+
}
39+
}

0 commit comments

Comments
 (0)