WordPress.org

Make WordPress Core

Ticket #45348: 45348.diff

File 45348.diff, 2.4 KB (added by azaozz, 21 months ago)
  • src/wp-admin/edit-form-blocks.php

     
    325325                'post' => $post->ID,
    326326        )
    327327);
     328wp_tinymce_inline_scripts();
    328329wp_enqueue_editor();
    329330
    330331/**
  • src/wp-includes/script-loader.php

     
    484484                'window.wp.oldEditor = window.wp.editor;',
    485485                'after'
    486486        );
     487}
    487488
    488         // TinyMCE init.
     489/**
     490 * Adds inline scripts required for the TinyMCE in the block editor.
     491 *
     492 * These TinyMCE init settings are used to extend and override the default settings
     493 * from `_WP_Editors::default_settings()` for the Classic block.
     494 *
     495 * @since 5.0.0
     496 *
     497 * @global WP_Scripts $wp_scripts
     498 */
     499function wp_tinymce_inline_scripts() {
     500        global $wp_scripts;
     501
     502        /** This filter is documented in wp-includes/class-wp-editor.php */
     503        $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
     504
    489505        $tinymce_plugins = array(
    490506                'charmap',
    491507                'colorpicker',
     
    511527        $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
    512528        $tinymce_plugins = array_unique( $tinymce_plugins );
    513529
     530        $disable_captions = false;
     531        // Runs after `tiny_mce_plugins` but before `mce_buttons`.
     532        /** This filter is documented in wp-admin/includes/media.php */
     533        if ( apply_filters( 'disable_captions', '' ) ) {
     534                $disable_captions = true;
     535        }
     536
    514537        $toolbar1 = array(
    515538                'formatselect',
    516539                'bold',
     
    565588                'classic_block_editor' => true,
    566589        );
    567590
     591        if ( $disable_captions ) {
     592                $tinymce_settings['wpeditimage_disable_captions'] = true;
     593        }
     594
     595        if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
     596                array_merge( $tinymce_settings, $editor_settings['tinymce'] );
     597        }
     598
    568599        /* This filter is documented in wp-includes/class-wp-editor.php */
    569600        $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
    570601
     
    596627                }
    597628        }';
    598629
    599         $scripts->add_inline_script( 'wp-block-library', $script, 'before' );
     630        $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' );
    600631}
    601632
    602633/**