I want to add a custom button to the tinyMCE toolbar in the 'Add New Post' screen which when clicked, will insert text into the new post.
I have tried using this code (from http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php):
wp_admin_css('thickbox');
wp_print_scripts('jquery-ui-core');
wp_print_scripts('jquery-ui-tabs');
wp_print_scripts('post');
wp_print_scripts('editor');
add_thickbox();
wp_print_scripts('media-upload');
setup : function(ed)
{
// Add a custom button
ed.addButton('mybutton',
{
title : 'My button',
image : 'img/example.gif',
onclick : function()
{
// Add you own code to execute something on click
ed.focus();
ed.selection.setContent('Hello world!');
}
});
}
but it fails to compile. It error's at the line with 'setup : function(ed)'
Is it failing because I need to reference tinyMCE.js? I couldn't find that file under my WordPress installation on the server.
is there a better way of creating the button?