Skip to content

Instantly share code, notes, and snippets.

@damianwajer
Last active April 6, 2017 09:57
Show Gist options
  • Select an option

  • Save damianwajer/8269a5a106abf6d2e848 to your computer and use it in GitHub Desktop.

Select an option

Save damianwajer/8269a5a106abf6d2e848 to your computer and use it in GitHub Desktop.
[WordPress] Add extra buttons to WordPress editor (TinyMCE)
<?php
/**
* Additional buttons in TinyMCE editor
*
* @param $buttons
*
* @return array
*/
function wp_extra_buttons( $buttons ) {
$buttons[] = 'hr';
$buttons[] = 'sub';
$buttons[] = 'sup';
$buttons[] = 'fontselect';
$buttons[] = 'fontsizeselect';
$buttons[] = 'styleselect';
$buttons[] = 'backcolor';
$buttons[] = 'image';
$buttons[] = 'media';
$buttons[] = 'anchor';
$buttons[] = 'wp_page';
$buttons[] = 'cut';
$buttons[] = 'copy';
$buttons[] = 'paste';
$buttons[] = 'code';
$buttons[] = 'cleanup';
return $buttons;
}
add_filter( 'mce_buttons_3', 'wp_extra_buttons' );
<?php
/**
* External plugins for TinyMCE Editor
*
* @param $plugin_array
*
* @return array
*/
function wp_mce_external_plugins( $plugin_array ) {
$plugin_array['print'] = get_template_directory_uri() . '/js/admin/editor_plugin.js';
return $plugin_array;
}
add_filter( 'mce_external_plugins', 'wp_mce_external_plugins' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment