apply_filters( 'mce_external_plugins', array $external_plugins , string $editor_id )
Filters the list of TinyMCE external plugins.
Contents
Description
The filter takes an associative array of external plugins for TinyMCE in the form ‘plugin_name’ => ‘url’.
The url should be absolute, and should include the js filename to be loaded. For example: ‘myplugin’ => ‘http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js‘.
If the external plugin adds a button, it should be added with one of the ‘mce_buttons’ filters.
Parameters
-
$external_plugins
array -
An array of external TinyMCE plugins.
-
$editor_id
string -
Unique editor identifier, e.g.
'content'
. Accepts'classic-block'
when called from block editor's Classic block.
More Information
This filter may be useful for loading any of the TinyMCE core plugins, many of which are not included by default in WordPress, as well as any custom TinyMCE plugins you may want to create.
Plugin Version Compatibility:
TinyMCE plugins must be compatible with the version of TinyMCE included in WordPress.
It may also be helpful to check when the particular plugin was introduced. For example, the visualblocks plugin was introduced in TinyMCE version 3.5b1.
WordPress 3.9 had a major update with TinyMCE 4.0.
If you find that your plugin script is not getting added, make sure you are adding your plugin ‘id’ => scripturl with the ‘mce_external_plugins’ filter, but not the ‘tiny_mce_plugins’ filter, or else the script file will not be registered.
Source
File: wp-includes/class-wp-editor.php
.
View all references
$mce_external_plugins = apply_filters( 'mce_external_plugins', array(), $editor_id );
Changelog
Version | Description |
---|---|
5.3.0 | The $editor_id parameter was added. |
2.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example migrated from Codex:
Visualblock plugin
For example, you might create a WordPress plugin that loads the TinyMCE plugin visualblocks.
TinyMCE plugins typically consist of a javascript file named ‘editor_plugin.js’ and a series of CSS files and other helper files. This example assumes the WordPress plugin stores TinyMCE plugins as follows: example_plugin/tinymce/visualblocks/edior_plugin.js
Example migrated from Codex:
Creating a shortcode and a tag button
First, create a plugin that registers the buttons and their JavaScript.
Then, in the same folder as the plugin, the JavaScript file mybuttons.js. We add our two buttons (eek and green), one is a direct
onclick
that inserts a Shortcode and the other is a command that adds anh3
tag to the selected text in the editor.You can pass PHP values to the JavaScript file printing directly in
admin_head
:And then, access it in mybuttons.js with
console.log(my_plugin.url);
.