Make WordPress Core

Changeset 43914 for branches/5.0


Ignore:
Timestamp:
11/21/2018 12:17:02 PM (8 years ago)
Author:
azaozz
Message:

TinyMCE: Run the "wp_editor_settings" and "disable_captions" filters for the Classic block. Fixes possible regressions in plugins that use these filters, also plugins that use them to add filters for the buttons, external plugins, etc.

Fixes #45348.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/script-loader.php

    r43905 r43914  
    487487 * Adds inline scripts required for the TinyMCE in the block editor.
    488488 *
     489 * These TinyMCE init settings are used to extend and override the default settings
     490 * from `_WP_Editors::default_settings()` for the Classic block.
     491 *
    489492 * @since 5.0.0
    490493 *
    … …  
    493496function wp_tinymce_inline_scripts() {
    494497        global $wp_scripts;
     498
     499        /** This filter is documented in wp-includes/class-wp-editor.php */
     500        $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
    495501
    496502        $tinymce_plugins = array(
    … …  
    519525        $tinymce_plugins = array_unique( $tinymce_plugins );
    520526
     527        $disable_captions = false;
     528        // Runs after `tiny_mce_plugins` but before `mce_buttons`.
     529        /** This filter is documented in wp-admin/includes/media.php */
     530        if ( apply_filters( 'disable_captions', '' ) ) {
     531                $disable_captions = true;
     532        }
     533
    521534        $toolbar1 = array(
    522535                'formatselect',
    … …  
    572585                'classic_block_editor' => true,
    573586        );
     587
     588        if ( $disable_captions ) {
     589                $tinymce_settings['wpeditimage_disable_captions'] = true;
     590        }
     591
     592        if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
     593                array_merge( $tinymce_settings, $editor_settings['tinymce'] );
     594        }
    574595
    575596        /* This filter is documented in wp-includes/class-wp-editor.php */
Note: See TracChangeset for help on using the changeset viewer.