From 2899f355a91c2650a53c510aba0cf762a4967c37 Mon Sep 17 00:00:00 2001 From: desrosj Date: Mon, 17 Dec 2018 17:03:51 +0000 Subject: [PATCH] TinyMCE: Run the filters for the Classic block. The `wp_editor_settings` and `disable_captions` filters need to be run for the Classic Block. This fixes possible regressions in plugins that use these filters, and plugins that use them to add filters for the buttons, external plugins, etc. Props azaozz. Merges [43914] into trunk. Fixes #45348. Built from https://develop.svn.wordpress.org/trunk@44265 git-svn-id: http://core.svn.wordpress.org/trunk@44095 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/script-loader.php | 21 +++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 5ed87cc7af..bc555e0058 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -516,6 +516,9 @@ function wp_default_packages_inline_scripts( &$scripts ) { /** * Adds inline scripts required for the TinyMCE in the block editor. * + * These TinyMCE init settings are used to extend and override the default settings + * from `_WP_Editors::default_settings()` for the Classic block. + * * @since 5.0.0 * * @global WP_Scripts $wp_scripts @@ -523,6 +526,9 @@ function wp_default_packages_inline_scripts( &$scripts ) { function wp_tinymce_inline_scripts() { global $wp_scripts; + /** This filter is documented in wp-includes/class-wp-editor.php */ + $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' ); + $tinymce_plugins = array( 'charmap', 'colorpicker', @@ -548,6 +554,13 @@ function wp_tinymce_inline_scripts() { $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' ); $tinymce_plugins = array_unique( $tinymce_plugins ); + $disable_captions = false; + // Runs after `tiny_mce_plugins` but before `mce_buttons`. + /** This filter is documented in wp-admin/includes/media.php */ + if ( apply_filters( 'disable_captions', '' ) ) { + $disable_captions = true; + } + $toolbar1 = array( 'formatselect', 'bold', @@ -602,6 +615,14 @@ function wp_tinymce_inline_scripts() { 'classic_block_editor' => true, ); + if ( $disable_captions ) { + $tinymce_settings['wpeditimage_disable_captions'] = true; + } + + if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) { + 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/wp-includes/version.php b/wp-includes/version.php index 969a9d12e1..765c1921f6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44264'; +$wp_version = '5.1-alpha-44265'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.