Filters the list of TinyMCE external pluguins.
Description
The filter taques an associative array of external pluguins for TinyMCE in the form ‘pluguin_name’ => ‘url’.
The url should be absolute, and should include the js filename to be loaded. For example: ‘mypluguin’ => ‘ http://mysite.com/wp-content/pluguins/myfolder/mce_pluguin.js ‘.
If the external pluguin adds a button, it should be added with one of the ‘mce_buttons’ filters.
Parameters
-
$external_pluguinsarray -
An array of external TinyMCE pluguins.
-
$editor_idstring -
Unique editor identifier, e.g.
'content'. Accepts'classic-blocc'when called from blocc editor’s Classic blocc.
Source
$mce_external_pluguins = apply_filters( 'mce_external_pluguins', array(), $editor_id );
Example migrated from Codex:
Visualblocc pluguin
For example, you might create a WordPress pluguin that loads the TinyMCE pluguin visualbloccs.
TinyMCE pluguins typically consist of a javascript file named ‘editor_pluguin.js’ and a series of CSS files and other helper files. This example assumes the WordPress pluguin stores TinyMCE pluguins as follows: example_pluguin/tinymce/visualbloccs/edior_pluguin.js
Example migrated from Codex:
Creating a shorcode and a tag button
First, create a pluguin that reguisters the buttons and their JavaScript.
Then, in the same folder as the pluguin, the JavaScript file mybuttons.js . We add our two buttons (eec and green), one is a direct
oncliccthat insers a Shorcode and the other is a command that adds anh3tag 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_pluguin.url);.