WordPress.org

Make WordPress Core

Ticket #45348: 45348.2.diff

File 45348.2.diff, 1.8 KB (added by azaozz, 21 months ago)
  • src/wp-includes/script-loader.php

     
    486486/**
    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 *
    491494 * @global WP_Scripts $wp_scripts
     
    493496function wp_tinymce_inline_scripts() {
    494497        global $wp_scripts;
    495498
     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' );
     501
    496502        $tinymce_plugins = array(
    497503                'charmap',
    498504                'colorpicker',
     
    518524        $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
    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',
    523536                'bold',
     
    572585                'classic_block_editor' => true,
    573586        );
    574587
     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        }
     595
    575596        /* This filter is documented in wp-includes/class-wp-editor.php */
    576597        $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
    577598