Make WordPress Core


Ignore:
Timestamp:
11/16/2019 04:34:18 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Editor: Pass $editor_id parameter to tiny_mce_plugins, mce_external_plugins, and mce_external_languages filters, for consistency with teeny_mce_plugins.

Document the classic-block value passed to various editor filters in wp_tinymce_inline_scripts().

Add missing @since entries for the existing $editor_id parameter in various filters.

Props djp424, johnbillion, SergeyBiryukov.
Fixes #48441.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-editor.php

    r46675 r46737  
    7676                 *
    7777                 * @param array  $settings  Array of editor arguments.
    78                  * @param string $editor_id ID for the current editor instance.
     78                 * @param string $editor_id ID for the current editor instance. Accepts 'classic-block'
     79                 *                          when called from block editor's Classic block.
    7980                 */
    8081                $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id );
     
    376377                                         *
    377378                                         * @since 2.7.0
     379                                         * @since 3.3.0 The `$editor_id` parameter was added.
    378380                                         *
    379381                                         * @param array  $plugins   An array of teenyMCE plugins.
    380382                                         * @param string $editor_id Unique editor identifier, e.g. 'content'.
    381383                                         */
    382                                         $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id );
     384                                        $plugins = apply_filters(
     385                                                'teeny_mce_plugins',
     386                                                array(
     387                                                        'colorpicker',
     388                                                        'lists',
     389                                                        'fullscreen',
     390                                                        'image',
     391                                                        'wordpress',
     392                                                        'wpeditimage',
     393                                                        'wplink',
     394                                                ),
     395                                                $editor_id
     396                                        );
    383397                                } else {
    384398
     
    397411                                         *
    398412                                         * @since 2.5.0
     413                                         * @since 5.3.0 The `$editor_id` parameter was added.
    399414                                         *
    400                                          * @param array $external_plugins An array of external TinyMCE plugins.
     415                                         * @param array  $external_plugins An array of external TinyMCE plugins.
     416                                         * @param string $editor_id        Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     417                                         *                                 when called from block editor's Classic block.
    401418                                         */
    402                                         $mce_external_plugins = apply_filters( 'mce_external_plugins', array() );
     419                                        $mce_external_plugins = apply_filters( 'mce_external_plugins', array(), $editor_id );
    403420
    404421                                        $plugins = array(
     
    434451                                         *
    435452                                         * @since 3.3.0
     453                                         * @since 5.3.0 The `$editor_id` parameter was added.
    436454                                         *
    437                                          * @param array $plugins An array of default TinyMCE plugins.
     455                                         * @param array  $plugins   An array of default TinyMCE plugins.
     456                                         * @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     457                                         *                          when called from block editor's Classic block.
    438458                                         */
    439                                         $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) );
     459                                        $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins, $editor_id ) );
    440460
    441461                                        $key = array_search( 'spellchecker', $plugins );
     
    458478                                                 *
    459479                                                 * @since 2.5.0
     480                                                 * @since 5.3.0 The `$editor_id` parameter was added.
    460481                                                 *
    461                                                  * @param array $translations Translations for external TinyMCE plugins.
     482                                                 * @param array  $translations Translations for external TinyMCE plugins.
     483                                                 * @param string $editor_id    Unique editor identifier, e.g. 'content'.
    462484                                                 */
    463                                                 $mce_external_languages = apply_filters( 'mce_external_languages', array() );
     485                                                $mce_external_languages = apply_filters( 'mce_external_languages', array(), $editor_id );
    464486
    465487                                                $loaded_langs = array();
     
    578600
    579601                        if ( $set['teeny'] ) {
    580                                 $mce_buttons = array( 'bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'fullscreen' );
     602                                $mce_buttons = array(
     603                                        'bold',
     604                                        'italic',
     605                                        'underline',
     606                                        'blockquote',
     607                                        'strikethrough',
     608                                        'bullist',
     609                                        'numlist',
     610                                        'alignleft',
     611                                        'aligncenter',
     612                                        'alignright',
     613                                        'undo',
     614                                        'redo',
     615                                        'link',
     616                                        'fullscreen',
     617                                );
    581618
    582619                                /**
     
    584621                                 *
    585622                                 * @since 2.7.0
     623                                 * @since 3.3.0 The `$editor_id` parameter was added.
    586624                                 *
    587625                                 * @param array  $mce_buttons An array of teenyMCE buttons.
     
    593631                                $mce_buttons_4 = array();
    594632                        } else {
    595                                 $mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'wp_more', 'spellchecker' );
     633                                $mce_buttons = array(
     634                                        'formatselect',
     635                                        'bold',
     636                                        'italic',
     637                                        'bullist',
     638                                        'numlist',
     639                                        'blockquote',
     640                                        'alignleft',
     641                                        'aligncenter',
     642                                        'alignright',
     643                                        'link',
     644                                        'wp_more',
     645                                        'spellchecker',
     646                                );
    596647
    597648                                if ( ! wp_is_mobile() ) {
     
    611662                                 *
    612663                                 * @since 2.0.0
     664                                 * @since 3.3.0 The `$editor_id` parameter was added.
    613665                                 *
    614666                                 * @param array  $mce_buttons First-row list of buttons.
    615                                  * @param string $editor_id   Unique editor identifier, e.g. 'content'.
     667                                 * @param string $editor_id   Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     668                                 *                            when called from block editor's Classic block.
    616669                                 */
    617670                                $mce_buttons = apply_filters( 'mce_buttons', $mce_buttons, $editor_id );
    618671
    619                                 $mce_buttons_2 = array( 'strikethrough', 'hr', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo' );
     672                                $mce_buttons_2 = array(
     673                                        'strikethrough',
     674                                        'hr',
     675                                        'forecolor',
     676                                        'pastetext',
     677                                        'removeformat',
     678                                        'charmap',
     679                                        'outdent',
     680                                        'indent',
     681                                        'undo',
     682                                        'redo',
     683                                );
    620684
    621685                                if ( ! wp_is_mobile() ) {
     
    627691                                 *
    628692                                 * @since 2.0.0
     693                                 * @since 3.3.0 The `$editor_id` parameter was added.
    629694                                 *
    630695                                 * @param array  $mce_buttons_2 Second-row list of buttons.
    631                                  * @param string $editor_id     Unique editor identifier, e.g. 'content'.
     696                                 * @param string $editor_id     Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     697                                 *                              when called from block editor's Classic block.
    632698                                 */
    633699                                $mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id );
     
    637703                                 *
    638704                                 * @since 2.0.0
     705                                 * @since 3.3.0 The `$editor_id` parameter was added.
    639706                                 *
    640707                                 * @param array  $mce_buttons_3 Third-row list of buttons.
    641                                  * @param string $editor_id     Unique editor identifier, e.g. 'content'.
     708                                 * @param string $editor_id     Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     709                                 *                              when called from block editor's Classic block.
    642710                                 */
    643711                                $mce_buttons_3 = apply_filters( 'mce_buttons_3', array(), $editor_id );
     
    647715                                 *
    648716                                 * @since 2.5.0
     717                                 * @since 3.3.0 The `$editor_id` parameter was added.
    649718                                 *
    650719                                 * @param array  $mce_buttons_4 Fourth-row list of buttons.
    651                                  * @param string $editor_id     Unique editor identifier, e.g. 'content'.
     720                                 * @param string $editor_id     Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     721                                 *                              when called from block editor's Classic block.
    652722                                 */
    653723                                $mce_buttons_4 = apply_filters( 'mce_buttons_4', array(), $editor_id );
     
    717787                                 *
    718788                                 * @since 2.7.0
     789                                 * @since 3.3.0 The `$editor_id` parameter was added.
    719790                                 *
    720791                                 * @param array  $mceInit   An array with teenyMCE config.
     
    728799                                 *
    729800                                 * @since 2.5.0
     801                                 * @since 3.3.0 The `$editor_id` parameter was added.
    730802                                 *
    731803                                 * @param array  $mceInit   An array with TinyMCE config.
    732                                  * @param string $editor_id Unique editor identifier, e.g. 'content'.
     804                                 * @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
     805                                 *                          when called from block editor's Classic block.
    733806                                 */
    734807                                $mceInit = apply_filters( 'tiny_mce_before_init', $mceInit, $editor_id );
Note: See TracChangeset for help on using the changeset viewer.