TinyMCE for WordPress - markhowellsmead/helpers GitHub Wiki
The WordPress admin area uses Tiny MCE for the RTE editors. To add a button of your own, take the following steps. (Example is for adding the functionality in a plugin; example files are here.)
- Add the functionality via Classes/TinyMCE.php. You'll need to customize this file so that it references your own plugin: from the namespace to the plugin key and any translations.
- Include the file to the plugin's main
__construct
function. Wrap it inif(is_admin()){…}
so that it doesn't get called unnecessarily in the frontend. - Then initialize the object immediately in the plugin
__construct
function usingnew TinyMCE();
.
The class adds the following files:
- mce_buttons.css contains the CSS styling rules for the button. Preferably use the Dashicons font. (Full icon documentation here.)
- mce_buttons.js creates and adds the button to the toolbar, including the click handler function.