Edit File by line
/home/barbar84/www/wp-inclu...
File: class-wp-editor.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Facilitates adding of the WordPress editor as used on the Write and Edit screens.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 3.3.0
[5] Fix | Delete
*
[6] Fix | Delete
* Private, not included by default. See wp_editor() in wp-includes/general-template.php.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
final class _WP_Editors {
[10] Fix | Delete
public static $mce_locale;
[11] Fix | Delete
[12] Fix | Delete
private static $mce_settings = array();
[13] Fix | Delete
private static $qt_settings = array();
[14] Fix | Delete
private static $plugins = array();
[15] Fix | Delete
private static $qt_buttons = array();
[16] Fix | Delete
private static $ext_plugins;
[17] Fix | Delete
private static $baseurl;
[18] Fix | Delete
private static $first_init;
[19] Fix | Delete
private static $this_tinymce = false;
[20] Fix | Delete
private static $this_quicktags = false;
[21] Fix | Delete
private static $has_tinymce = false;
[22] Fix | Delete
private static $has_quicktags = false;
[23] Fix | Delete
private static $has_medialib = false;
[24] Fix | Delete
private static $editor_buttons_css = true;
[25] Fix | Delete
private static $drag_drop_upload = false;
[26] Fix | Delete
private static $translation;
[27] Fix | Delete
private static $tinymce_scripts_printed = false;
[28] Fix | Delete
private static $link_dialog_printed = false;
[29] Fix | Delete
[30] Fix | Delete
private function __construct() {}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Parse default arguments for the editor instance.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 3.3.0
[36] Fix | Delete
*
[37] Fix | Delete
* @param string $editor_id HTML ID for the textarea and TinyMCE and Quicktags instances.
[38] Fix | Delete
* Should not contain square brackets.
[39] Fix | Delete
* @param array $settings {
[40] Fix | Delete
* Array of editor arguments.
[41] Fix | Delete
*
[42] Fix | Delete
* @type bool $wpautop Whether to use wpautop(). Default true.
[43] Fix | Delete
* @type bool $media_buttons Whether to show the Add Media/other media buttons.
[44] Fix | Delete
* @type string $default_editor When both TinyMCE and Quicktags are used, set which
[45] Fix | Delete
* editor is shown on page load. Default empty.
[46] Fix | Delete
* @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false.
[47] Fix | Delete
* Requires the media modal.
[48] Fix | Delete
* @type string $textarea_name Give the textarea a unique name here. Square brackets
[49] Fix | Delete
* can be used here. Default $editor_id.
[50] Fix | Delete
* @type int $textarea_rows Number rows in the editor textarea. Default 20.
[51] Fix | Delete
* @type string|int $tabindex Tabindex value to use. Default empty.
[52] Fix | Delete
* @type string $tabfocus_elements The previous and next element ID to move the focus to
[53] Fix | Delete
* when pressing the Tab key in TinyMCE. Default ':prev,:next'.
[54] Fix | Delete
* @type string $editor_css Intended for extra styles for both Visual and Text editors.
[55] Fix | Delete
* Should include `<style>` tags, and can use "scoped". Default empty.
[56] Fix | Delete
* @type string $editor_class Extra classes to add to the editor textarea element. Default empty.
[57] Fix | Delete
* @type bool $teeny Whether to output the minimal editor config. Examples include
[58] Fix | Delete
* Press This and the Comment editor. Default false.
[59] Fix | Delete
* @type bool $dfw Deprecated in 4.1. Unused.
[60] Fix | Delete
* @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to
[61] Fix | Delete
* TinyMCE using an array. Default true.
[62] Fix | Delete
* @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to
[63] Fix | Delete
* Quicktags using an array. Default true.
[64] Fix | Delete
* }
[65] Fix | Delete
* @return array Parsed arguments array.
[66] Fix | Delete
*/
[67] Fix | Delete
public static function parse_settings( $editor_id, $settings ) {
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Filters the wp_editor() settings.
[71] Fix | Delete
*
[72] Fix | Delete
* @since 4.0.0
[73] Fix | Delete
*
[74] Fix | Delete
* @see _WP_Editors::parse_settings()
[75] Fix | Delete
*
[76] Fix | Delete
* @param array $settings Array of editor arguments.
[77] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
[78] Fix | Delete
* when called from block editor's Classic block.
[79] Fix | Delete
*/
[80] Fix | Delete
$settings = apply_filters( 'wp_editor_settings', $settings, $editor_id );
[81] Fix | Delete
[82] Fix | Delete
$set = wp_parse_args(
[83] Fix | Delete
$settings,
[84] Fix | Delete
array(
[85] Fix | Delete
// Disable autop if the current post has blocks in it.
[86] Fix | Delete
'wpautop' => ! has_blocks(),
[87] Fix | Delete
'media_buttons' => true,
[88] Fix | Delete
'default_editor' => '',
[89] Fix | Delete
'drag_drop_upload' => false,
[90] Fix | Delete
'textarea_name' => $editor_id,
[91] Fix | Delete
'textarea_rows' => 20,
[92] Fix | Delete
'tabindex' => '',
[93] Fix | Delete
'tabfocus_elements' => ':prev,:next',
[94] Fix | Delete
'editor_css' => '',
[95] Fix | Delete
'editor_class' => '',
[96] Fix | Delete
'teeny' => false,
[97] Fix | Delete
'_content_editor_dfw' => false,
[98] Fix | Delete
'tinymce' => true,
[99] Fix | Delete
'quicktags' => true,
[100] Fix | Delete
)
[101] Fix | Delete
);
[102] Fix | Delete
[103] Fix | Delete
self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() );
[104] Fix | Delete
[105] Fix | Delete
if ( self::$this_tinymce ) {
[106] Fix | Delete
if ( false !== strpos( $editor_id, '[' ) ) {
[107] Fix | Delete
self::$this_tinymce = false;
[108] Fix | Delete
_deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' );
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
self::$this_quicktags = (bool) $set['quicktags'];
[113] Fix | Delete
[114] Fix | Delete
if ( self::$this_tinymce ) {
[115] Fix | Delete
self::$has_tinymce = true;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if ( self::$this_quicktags ) {
[119] Fix | Delete
self::$has_quicktags = true;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
if ( empty( $set['editor_height'] ) ) {
[123] Fix | Delete
return $set;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) {
[127] Fix | Delete
// A cookie (set when a user resizes the editor) overrides the height.
[128] Fix | Delete
$cookie = (int) get_user_setting( 'ed_size' );
[129] Fix | Delete
[130] Fix | Delete
if ( $cookie ) {
[131] Fix | Delete
$set['editor_height'] = $cookie;
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if ( $set['editor_height'] < 50 ) {
[136] Fix | Delete
$set['editor_height'] = 50;
[137] Fix | Delete
} elseif ( $set['editor_height'] > 5000 ) {
[138] Fix | Delete
$set['editor_height'] = 5000;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
return $set;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
/**
[145] Fix | Delete
* Outputs the HTML for a single instance of the editor.
[146] Fix | Delete
*
[147] Fix | Delete
* @since 3.3.0
[148] Fix | Delete
*
[149] Fix | Delete
* @param string $content Initial content for the editor.
[150] Fix | Delete
* @param string $editor_id HTML ID for the textarea and TinyMCE and Quicktags instances.
[151] Fix | Delete
* Should not contain square brackets.
[152] Fix | Delete
* @param array $settings See _WP_Editors::parse_settings() for description.
[153] Fix | Delete
*/
[154] Fix | Delete
public static function editor( $content, $editor_id, $settings = array() ) {
[155] Fix | Delete
$set = self::parse_settings( $editor_id, $settings );
[156] Fix | Delete
$editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"';
[157] Fix | Delete
$tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
[158] Fix | Delete
$default_editor = 'html';
[159] Fix | Delete
$buttons = '';
[160] Fix | Delete
$autocomplete = '';
[161] Fix | Delete
$editor_id_attr = esc_attr( $editor_id );
[162] Fix | Delete
[163] Fix | Delete
if ( $set['drag_drop_upload'] ) {
[164] Fix | Delete
self::$drag_drop_upload = true;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
if ( ! empty( $set['editor_height'] ) ) {
[168] Fix | Delete
$height = ' style="height: ' . (int) $set['editor_height'] . 'px"';
[169] Fix | Delete
} else {
[170] Fix | Delete
$height = ' rows="' . (int) $set['textarea_rows'] . '"';
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
if ( ! current_user_can( 'upload_files' ) ) {
[174] Fix | Delete
$set['media_buttons'] = false;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
if ( self::$this_tinymce ) {
[178] Fix | Delete
$autocomplete = ' autocomplete="off"';
[179] Fix | Delete
[180] Fix | Delete
if ( self::$this_quicktags ) {
[181] Fix | Delete
$default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
[182] Fix | Delete
// 'html' is used for the "Text" editor tab.
[183] Fix | Delete
if ( 'html' !== $default_editor ) {
[184] Fix | Delete
$default_editor = 'tinymce';
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
$buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' .
[188] Fix | Delete
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n";
[189] Fix | Delete
$buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' .
[190] Fix | Delete
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n";
[191] Fix | Delete
} else {
[192] Fix | Delete
$default_editor = 'tinymce';
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active';
[197] Fix | Delete
$wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class;
[198] Fix | Delete
[199] Fix | Delete
if ( $set['_content_editor_dfw'] ) {
[200] Fix | Delete
$wrap_class .= ' has-dfw';
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">';
[204] Fix | Delete
[205] Fix | Delete
if ( self::$editor_buttons_css ) {
[206] Fix | Delete
wp_print_styles( 'editor-buttons' );
[207] Fix | Delete
self::$editor_buttons_css = false;
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
if ( ! empty( $set['editor_css'] ) ) {
[211] Fix | Delete
echo $set['editor_css'] . "\n";
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
if ( ! empty( $buttons ) || $set['media_buttons'] ) {
[215] Fix | Delete
echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">';
[216] Fix | Delete
[217] Fix | Delete
if ( $set['media_buttons'] ) {
[218] Fix | Delete
self::$has_medialib = true;
[219] Fix | Delete
[220] Fix | Delete
if ( ! function_exists( 'media_buttons' ) ) {
[221] Fix | Delete
require ABSPATH . 'wp-admin/includes/media.php';
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">';
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Fires after the default media button(s) are displayed.
[228] Fix | Delete
*
[229] Fix | Delete
* @since 2.5.0
[230] Fix | Delete
*
[231] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'.
[232] Fix | Delete
*/
[233] Fix | Delete
do_action( 'media_buttons', $editor_id );
[234] Fix | Delete
echo "</div>\n";
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n";
[238] Fix | Delete
echo "</div>\n";
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
$quicktags_toolbar = '';
[242] Fix | Delete
[243] Fix | Delete
if ( self::$this_quicktags ) {
[244] Fix | Delete
if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && 'post' === $GLOBALS['current_screen']->base ) {
[245] Fix | Delete
$toolbar_id = 'ed_toolbar';
[246] Fix | Delete
} else {
[247] Fix | Delete
$toolbar_id = 'qt_' . $editor_id_attr . '_toolbar';
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
$quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>';
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
/**
[254] Fix | Delete
* Filters the HTML markup output that displays the editor.
[255] Fix | Delete
*
[256] Fix | Delete
* @since 2.1.0
[257] Fix | Delete
*
[258] Fix | Delete
* @param string $output Editor's HTML markup.
[259] Fix | Delete
*/
[260] Fix | Delete
$the_editor = apply_filters(
[261] Fix | Delete
'the_editor',
[262] Fix | Delete
'<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' .
[263] Fix | Delete
$quicktags_toolbar .
[264] Fix | Delete
'<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' .
[265] Fix | Delete
'id="' . $editor_id_attr . '">%s</textarea></div>'
[266] Fix | Delete
);
[267] Fix | Delete
[268] Fix | Delete
// Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat).
[269] Fix | Delete
if ( self::$this_tinymce ) {
[270] Fix | Delete
add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
/**
[274] Fix | Delete
* Filters the default editor content.
[275] Fix | Delete
*
[276] Fix | Delete
* @since 2.1.0
[277] Fix | Delete
*
[278] Fix | Delete
* @param string $content Default editor content.
[279] Fix | Delete
* @param string $default_editor The default editor for the current user.
[280] Fix | Delete
* Either 'html' or 'tinymce'.
[281] Fix | Delete
*/
[282] Fix | Delete
$content = apply_filters( 'the_editor_content', $content, $default_editor );
[283] Fix | Delete
[284] Fix | Delete
// Remove the filter as the next editor on the same page may not need it.
[285] Fix | Delete
if ( self::$this_tinymce ) {
[286] Fix | Delete
remove_filter( 'the_editor_content', 'format_for_editor' );
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
// Back-compat for the `htmledit_pre` and `richedit_pre` filters.
[290] Fix | Delete
if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) {
[291] Fix | Delete
/** This filter is documented in wp-includes/deprecated.php */
[292] Fix | Delete
$content = apply_filters_deprecated( 'htmledit_pre', array( $content ), '4.3.0', 'format_for_editor' );
[293] Fix | Delete
} elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) {
[294] Fix | Delete
/** This filter is documented in wp-includes/deprecated.php */
[295] Fix | Delete
$content = apply_filters_deprecated( 'richedit_pre', array( $content ), '4.3.0', 'format_for_editor' );
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
if ( false !== stripos( $content, 'textarea' ) ) {
[299] Fix | Delete
$content = preg_replace( '%</textarea%i', '&lt;/textarea', $content );
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
printf( $the_editor, $content );
[303] Fix | Delete
echo "\n</div>\n\n";
[304] Fix | Delete
[305] Fix | Delete
self::editor_settings( $editor_id, $set );
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
/**
[309] Fix | Delete
* @since 3.3.0
[310] Fix | Delete
*
[311] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'.
[312] Fix | Delete
* @param array $set Array of editor arguments.
[313] Fix | Delete
*/
[314] Fix | Delete
public static function editor_settings( $editor_id, $set ) {
[315] Fix | Delete
if ( empty( self::$first_init ) ) {
[316] Fix | Delete
if ( is_admin() ) {
[317] Fix | Delete
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 );
[318] Fix | Delete
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 );
[319] Fix | Delete
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 );
[320] Fix | Delete
} else {
[321] Fix | Delete
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 );
[322] Fix | Delete
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 );
[323] Fix | Delete
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 );
[324] Fix | Delete
}
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
if ( self::$this_quicktags ) {
[328] Fix | Delete
[329] Fix | Delete
$qtInit = array(
[330] Fix | Delete
'id' => $editor_id,
[331] Fix | Delete
'buttons' => '',
[332] Fix | Delete
);
[333] Fix | Delete
[334] Fix | Delete
if ( is_array( $set['quicktags'] ) ) {
[335] Fix | Delete
$qtInit = array_merge( $qtInit, $set['quicktags'] );
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
if ( empty( $qtInit['buttons'] ) ) {
[339] Fix | Delete
$qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close';
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
if ( $set['_content_editor_dfw'] ) {
[343] Fix | Delete
$qtInit['buttons'] .= ',dfw';
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
/**
[347] Fix | Delete
* Filters the Quicktags settings.
[348] Fix | Delete
*
[349] Fix | Delete
* @since 3.3.0
[350] Fix | Delete
*
[351] Fix | Delete
* @param array $qtInit Quicktags settings.
[352] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'.
[353] Fix | Delete
*/
[354] Fix | Delete
$qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id );
[355] Fix | Delete
[356] Fix | Delete
self::$qt_settings[ $editor_id ] = $qtInit;
[357] Fix | Delete
[358] Fix | Delete
self::$qt_buttons = array_merge( self::$qt_buttons, explode( ',', $qtInit['buttons'] ) );
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
if ( self::$this_tinymce ) {
[362] Fix | Delete
[363] Fix | Delete
if ( empty( self::$first_init ) ) {
[364] Fix | Delete
$baseurl = self::get_baseurl();
[365] Fix | Delete
$mce_locale = self::get_mce_locale();
[366] Fix | Delete
$ext_plugins = '';
[367] Fix | Delete
[368] Fix | Delete
if ( $set['teeny'] ) {
[369] Fix | Delete
[370] Fix | Delete
/**
[371] Fix | Delete
* Filters the list of teenyMCE plugins.
[372] Fix | Delete
*
[373] Fix | Delete
* @since 2.7.0
[374] Fix | Delete
* @since 3.3.0 The `$editor_id` parameter was added.
[375] Fix | Delete
*
[376] Fix | Delete
* @param array $plugins An array of teenyMCE plugins.
[377] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'.
[378] Fix | Delete
*/
[379] Fix | Delete
$plugins = apply_filters(
[380] Fix | Delete
'teeny_mce_plugins',
[381] Fix | Delete
array(
[382] Fix | Delete
'colorpicker',
[383] Fix | Delete
'lists',
[384] Fix | Delete
'fullscreen',
[385] Fix | Delete
'image',
[386] Fix | Delete
'wordpress',
[387] Fix | Delete
'wpeditimage',
[388] Fix | Delete
'wplink',
[389] Fix | Delete
),
[390] Fix | Delete
$editor_id
[391] Fix | Delete
);
[392] Fix | Delete
} else {
[393] Fix | Delete
[394] Fix | Delete
/**
[395] Fix | Delete
* Filters the list of TinyMCE external plugins.
[396] Fix | Delete
*
[397] Fix | Delete
* The filter takes an associative array of external plugins for
[398] Fix | Delete
* TinyMCE in the form 'plugin_name' => 'url'.
[399] Fix | Delete
*
[400] Fix | Delete
* The url should be absolute, and should include the js filename
[401] Fix | Delete
* to be loaded. For example:
[402] Fix | Delete
* 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'.
[403] Fix | Delete
*
[404] Fix | Delete
* If the external plugin adds a button, it should be added with
[405] Fix | Delete
* one of the 'mce_buttons' filters.
[406] Fix | Delete
*
[407] Fix | Delete
* @since 2.5.0
[408] Fix | Delete
* @since 5.3.0 The `$editor_id` parameter was added.
[409] Fix | Delete
*
[410] Fix | Delete
* @param array $external_plugins An array of external TinyMCE plugins.
[411] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
[412] Fix | Delete
* when called from block editor's Classic block.
[413] Fix | Delete
*/
[414] Fix | Delete
$mce_external_plugins = apply_filters( 'mce_external_plugins', array(), $editor_id );
[415] Fix | Delete
[416] Fix | Delete
$plugins = array(
[417] Fix | Delete
'charmap',
[418] Fix | Delete
'colorpicker',
[419] Fix | Delete
'hr',
[420] Fix | Delete
'lists',
[421] Fix | Delete
'media',
[422] Fix | Delete
'paste',
[423] Fix | Delete
'tabfocus',
[424] Fix | Delete
'textcolor',
[425] Fix | Delete
'fullscreen',
[426] Fix | Delete
'wordpress',
[427] Fix | Delete
'wpautoresize',
[428] Fix | Delete
'wpeditimage',
[429] Fix | Delete
'wpemoji',
[430] Fix | Delete
'wpgallery',
[431] Fix | Delete
'wplink',
[432] Fix | Delete
'wpdialogs',
[433] Fix | Delete
'wptextpattern',
[434] Fix | Delete
'wpview',
[435] Fix | Delete
);
[436] Fix | Delete
[437] Fix | Delete
if ( ! self::$has_medialib ) {
[438] Fix | Delete
$plugins[] = 'image';
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
/**
[442] Fix | Delete
* Filters the list of default TinyMCE plugins.
[443] Fix | Delete
*
[444] Fix | Delete
* The filter specifies which of the default plugins included
[445] Fix | Delete
* in WordPress should be added to the TinyMCE instance.
[446] Fix | Delete
*
[447] Fix | Delete
* @since 3.3.0
[448] Fix | Delete
* @since 5.3.0 The `$editor_id` parameter was added.
[449] Fix | Delete
*
[450] Fix | Delete
* @param array $plugins An array of default TinyMCE plugins.
[451] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block'
[452] Fix | Delete
* when called from block editor's Classic block.
[453] Fix | Delete
*/
[454] Fix | Delete
$plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins, $editor_id ) );
[455] Fix | Delete
[456] Fix | Delete
$key = array_search( 'spellchecker', $plugins, true );
[457] Fix | Delete
if ( false !== $key ) {
[458] Fix | Delete
// Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors.
[459] Fix | Delete
// It can be added with 'mce_external_plugins'.
[460] Fix | Delete
unset( $plugins[ $key ] );
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
if ( ! empty( $mce_external_plugins ) ) {
[464] Fix | Delete
[465] Fix | Delete
/**
[466] Fix | Delete
* Filters the translations loaded for external TinyMCE 3.x plugins.
[467] Fix | Delete
*
[468] Fix | Delete
* The filter takes an associative array ('plugin_name' => 'path')
[469] Fix | Delete
* where 'path' is the include path to the file.
[470] Fix | Delete
*
[471] Fix | Delete
* The language file should follow the same format as wp_mce_translation(),
[472] Fix | Delete
* and should define a variable ($strings) that holds all translated strings.
[473] Fix | Delete
*
[474] Fix | Delete
* @since 2.5.0
[475] Fix | Delete
* @since 5.3.0 The `$editor_id` parameter was added.
[476] Fix | Delete
*
[477] Fix | Delete
* @param array $translations Translations for external TinyMCE plugins.
[478] Fix | Delete
* @param string $editor_id Unique editor identifier, e.g. 'content'.
[479] Fix | Delete
*/
[480] Fix | Delete
$mce_external_languages = apply_filters( 'mce_external_languages', array(), $editor_id );
[481] Fix | Delete
[482] Fix | Delete
$loaded_langs = array();
[483] Fix | Delete
$strings = '';
[484] Fix | Delete
[485] Fix | Delete
if ( ! empty( $mce_external_languages ) ) {
[486] Fix | Delete
foreach ( $mce_external_languages as $name => $path ) {
[487] Fix | Delete
if ( @is_file( $path ) && @is_readable( $path ) ) {
[488] Fix | Delete
include_once $path;
[489] Fix | Delete
$ext_plugins .= $strings . "\n";
[490] Fix | Delete
$loaded_langs[] = $name;
[491] Fix | Delete
}
[492] Fix | Delete
}
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
foreach ( $mce_external_plugins as $name => $url ) {
[496] Fix | Delete
if ( in_array( $name, $plugins, true ) ) {
[497] Fix | Delete
unset( $mce_external_plugins[ $name ] );
[498] Fix | Delete
continue;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function