[wp-hackers] Re: Adding custom buttons to TinyMCE v3.x

Alex Rabe alex.cologne at googlemail.com
Sun Mar 9 16:42:26 GMT 2008


This is working for me just fine :

function myplugin_addbuttons() {

	// Don't bother doing this stuff if the current user lacks
permissions
	if ( !current_user_can('edit_posts') && !
current_user_can('edit_pages') ) return;

	// Add only in Rich Editor mode
	if ( get_user_option('rich_editing') == 'true') {

	// add the button for wp21 in a new way
		add_filter("mce_external_plugins", "add_myplugin_tinymce_plugin",
5);
		add_filter('mce_buttons', 'register_myplugin_button', 5);
	}
}

// used to insert button in wordpress 2.1x editor
function register_myplugin_button($buttons) {

	array_push($buttons, "separator", "myplugin");

	return $buttons;
}

// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
function add_myplugin_tinymce_plugin($plugin_array) {

	$plugin_array['myplugin'] = URLPATH.'tinymce/editor_plugin.js';

	return $plugin_array;
}

// init process for button control
add_action('init', 'myplugin_addbuttons');

****

simple editor_plugin.js is descripbed here

http://wiki.moxiecode.com/index.php/TinyMCE:Create_plugin/3.x#Creating_your_own_plugins
or contact me...

Alex


On 9 Mrz., 13:05, Viper007Bond <vi... at viper007bond.com> wrote:
> Ugh, I am horrible with TinyMCE and not much better with Javascript. Trying
> to figure this out is giving me a headache.
>
> Would anyone be willing to throw together for me the most simple of TinyMCE
> plugins showing how to create a new button that just does an alert() or
> whatever? Just so I can see the basics. I can (probably) expand from there.
>
> --
> Viper007Bond |http://www.viper007bond.com/|http://www.finalgear.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hack... at lists.automattic.comhttp://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list