Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example WP plugin to show how to register TinyMCE plugins in WordPress
<?php
/**
* @package TinyMCE_example_plugin
* @version 1.0
*/
/*
Plugin Name: TinyMCE example plugin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Your Name
Version: 1.0
Author URI: http://example.com/
*/
/**
* Filters TinyMCE buttons
*
* @since 2.0.0
*
* @param array $buttons First-row list of buttons
* @param string $editor_id Unique editor identifier, e.g. 'content'.
*/
function example_plugin_register_buttons( $buttons ) {
$buttons[] = 'table';
$buttons[] = 'prism';
return $buttons;
}
// add new buttons to the first row
add_filter( 'mce_buttons', 'example_plugin_register_buttons' );
/**
* Filters the list of TinyMCE external plugins
*
* @since 2.5.0
*
* @param array $external_plugins An array of external TinyMCE plugins
*/
function example_plugin_register_plugin( $plugin_array ) {
$plugin_array['table'] = plugins_url( '/mce/table/plugin.min.js', __FILE__ );
$plugin_array['prism'] = plugins_url( '/mce/prism/plugin.js', __FILE__ );
return $plugin_array;
}
// Load the TinyMCE plugin
add_filter( 'mce_external_plugins', 'example_plugin_register_plugin' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.