WordPress.org

Ready to get started?Download WordPress

Forums

Ultimate TinyMCE
[resolved] Remove button? (6 posts)

  1. spudnic072
    Member
    Posted 1 year ago #

    Hey, great plugin sofar.

    I see there are options to add additional buttons, but are there ways so that i can remove some of the standard ones? ie: paste from word, etc. im looking to make the editor lighter and load faster.

    http://wordpress.org/extend/plugins/ultimate-tinymce/

  2. Marventus
    Member
    Plugin Author

    Posted 1 year ago #

    Hello there.
    All buttons added by UTMCE can be removed. However, in order to remove the icons that are added by WP, you would need a filter for each one of the first 2 rows. You would need a code like this:

    /* Row 1 */
    function userf_buttons_1($buttons) {
    	$remove = array('bold','italic');
    	foreach($remove as $rem) {
    		if ( in_array($rem, $buttons) )
    			unset($buttons[array_search($rem, $buttons)]);
    	}
    	return $buttons;
    }
    add_filter("mce_buttons", "userf_buttons_1");
    
    /* Row 2 */
    function userf_buttons_2($buttons) {
    	$remove = array('formatselect','underline');
    	foreach($remove as $rem) {
    		if ( in_array($rem, $buttons) )
    			unset($buttons[array_search($rem, $buttons)]);
    	}
    	return $buttons;
    }
    add_filter("mce_buttons_2", "userf_buttons_2");

    Please note that, for each function, there is a $remove array with some buttons as an example. What you need to do is replace the values of each one with the names of the buttons you would like to remove from the editor on a per row basis.

    Here is a list of all the button handles added by WP on rows 1 and 2:
    Row 1: bold, italic, strikethrough, bullist, numlist, blockquote, justifyleft, justifycenter, justifyright, link, unlink, wp_more, spellchecker, fullscreen.
    Row 2: formatselect, underline, justifyfull, forecolor, pastetext, pasteword, removeformat, charmap, outdent, indent, undo, redo, wp_help.

  3. spudnic072
    Member
    Posted 1 year ago #

    Awsome! thanks ill give that a try.

  4. spudnic072
    Member
    Posted 1 year ago #

    That worked great, thanks!

    Is there a way to add custom buttons? Ones that are not already included with the plugin? I would like to be able to have text wrapped in <blizz></blizz> when i highlight it and click the custom button.

    I hope this is possible. I have an plugin that does this, but when using bbpress it doesn't get added to the editor.

  5. Marventus
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah, you totally can. If you already have a plugin that is compatible with tinymce, all you have to do is:
    1. Add the plugin handle to the $buttons array;
    2. Register the JS file (as an url) that the plugin requires in order to work via the mce_external_plugins hook.
    So, assuming the blizz plugin's handle was blizz, you would go:

    function userf_add_buttons($buttons) {
        $buttons[] = 'blizz'
    }
    add_filter('mce_buttons', 'userf_add_buttons');
    
    function userf_register_buttons($plugins_array) {
        $plugins_array['blizz'] = 'url/to/main/addon/js/file.js';
        return $plugins_array;
    }
    add_filter('mce_external_plugins, 'userf_register_buttons')

    That would add your custom plugin on row 1 of the editor. If you wanted it on row 2, you would have to add the filter to mce_buttons_2:

    add_filter('mce_buttons_2', 'userf_add_buttons');
  6. Josh (WP Edit)
    Moderator and Editor Customizer
    Plugin Author

    Posted 1 year ago #

    Hi spudnic072, and thanks for your support in our plugin!

    I'm going to mark this thread as resolved. Please feel free to change it in the future.

    Also, we certainly wouldn't mind if you wanted to submit a rating and review for our plugin. You can do it from the main plugin page.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.