Custom Buttons in TinyMCE
-
I’ve been digging through all the Codex and the TinyMCE docs but I can’t get a new button on the tMCE editor. I want to add a new button to apply some classes to the selected element; it’s for a small plugin I’m doing. I don’t get an error code, but the button isn’t added.
This is the code:
thickbox.php$thickboxPath = get_bloginfo('url')."/wp-content/plugins/thickbox/"; function myplugin_addbuttons() { 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_myplugin_tinymce_plugin"); add_filter('mce_buttons', 'register_myplugin_button'); } } function register_myplugin_button($buttons) { array_push($buttons, "button"); return $buttons; } function add_myplugin_tinymce_plugin($plugin_array) { $plugin_array['myplugin'] = $thickboxPath . 'tinymce/editor_plugin.js'; return $plugin_array; } add_action('init', 'myplugin_addbuttons');tinymce/editor_plugin.js
(function(){ tinymce.PluginManager.requireLangPack('addthickbox'); tinymce.create('tinymce.plugins.AddThickbox', { init : function(ed, url) { ed.addButton('button', { title : 'addthickbox.desc', image : url + './../images/class.png' }); }, createControl : function(n, cm) { return null; }, getInfo : function() { return { longname : "AddThickbox", author : 'Elliot', authorurl : 'http://ilovecolors.com.ar/', infourl : 'http://ilovecolors.com.ar/', version : "1.0" }; } }); tinymce.PluginManager.add('addthickbox', tinymce.plugins.AddThickbox); })();tinymce/langs/en.js
tinyMCE.addI18n("en.addthickbox",{ desc : 'Description' });Could you pleeeeaasssseee give me a hand? I just don’t know what I’m doing wrong, the image is in its place. Please, point me some tutorial, give me an advice, anything would help!!
Thanks in advance!!
The topic ‘Custom Buttons in TinyMCE’ is closed to new replies.