I have added a custom button to the tinymce to insert my shortcodes, but I have so many and I want to make a splitbutton instead and I can’t figure how. Anyone can help. Here’s the code that I’ve used to create the normal button:
in functions.php :
/**
Hook into WordPress
*/
add_action('init', 'onehalf_button');
/**
Create Our Initialization Function
*/
function onehalf_button() {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
return;
}
if ( get_user_option('rich_editing') == 'true' ) {
add_filter( 'mce_external_plugins', 'add_plugin' );
add_filter( 'mce_buttons', 'register_button' );
}
}
/**
Register Button
*/
function register_button( $buttons ) {
array_push( $buttons, "|", "onehalf" );
return $buttons;
}
/**
Register TinyMCE Plugin
*/
function add_plugin( $plugin_array ) {
$plugin_array['onehalf'] = get_bloginfo( 'template_url' ) . '/js/tinymce_buttons.js';
return $plugin_array;
}
and in the custom plugin .js
// JavaScript Document
(function() {
tinymce.create('tinymce.plugins.onehalf', {
init : function(ed, url) {
ed.addButton('onehalf', {
title : 'One Half Column',
image : url+'/mylink.png',
onclick : function() {
ed.selection.setContent('[one_half]' + ed.selection.getContent() + '[/one_half]');
}
});
},
createControl : function(n, cm) {
return null;
},
});
tinymce.PluginManager.add('onehalf', tinymce.plugins.onehalf);
})();
I’ve found something here http://tinymce.moxiecode.com/tryit/listbox_splitbutton.php but can’t figure out how to implement it into WP.
Anyone can help? Thanks.