1
votes

I have a set of WYSIWYG editors that are all initialized via TinyMCE on demand.

In the previous version of TinyMCE I was able to easily remove buttons by specifying the button theme_advanced_buttons1, theme_advanced_buttons2 etc. But since the newest release of TinyMCE 4.0 , it seems as tho that no longer works.

I am running the modern theme, so maybe the theme_advanced_buttons1 doesn't work with the modern theme? I've tried theme_modern_buttons1 , but that didn't work.

I'm thinking it may have changed with the newest release, as there is a new toolbar with the options for 'File, Edit, Insert...' etc.

Anyone know how I can hide the buttons on initialization? Heres the code I'm trying:

```

    // initialize tinyMCE editor on our movie description text area
    function initialize_movie_descriptions() {
        $('.movie_description_editor').each(function() {
            var id = $(this).attr('id');
            tinyMCE.init({
              mode : "exact",
              elements : id,
              theme : "modern",
              plugins: "wordpress,wplink, paste",
              theme_advanced_buttons1: "",
              theme_advanced_buttons2 : "",
              theme_advanced_buttons3: "",
              theme_advanced_resizing : true,
              paste_auto_cleanup_on_paste : true,
                paste_preprocess : function(pl, o) {
                    o.content = o.content;
                },
                paste_postprocess : function(pl, o) {
                    o.node.innerHTML = o.node.innerHTML;
                }
           });       
        });
    }
    initialize_movie_descriptions();

```

Edit Apparently changing the line plugins: "wordpress,wplink, paste", to plugins: "", seems to have removed the 'Insert' menu item in the first toolbar. I guess because it's not loading any plugins now??

3

3 Answers

2
votes

If you don't want all buttons but keep some of the functionality you have to keep to plugins. Simply just add the buttons you want in toolbar. The Same way with the menu:

tinymce
        .init({
            ...
            plugins : [code fullscreen save table contextmenu paste textcolor" ],
            //buttons you want to show, else set "toolbar:false"
            toolbar : "insertfile undo redo | styleselect",
            ...
            menu : {
                ...
                edit : {
                    //menu edit
                    title : 'Edit',
                    //items of menu edit
                    items : 'undo redo | cut copy paste pastetext | selectall'
                },
            ...
});

you can find a list of plugins with their configuration in tinyMCE here: http://www.tinymce.com/wiki.php/Plugins

1
votes

I struggled with the same problem after updating Wordpress to version 4.0. I found the solution on the wiki-advanced-page of TinyMCE. In TinyMCE 4 "theme_advanced_buttons" is replaced by "toolbar". You probably want to hide the "menubar" too, see example below:

tinyMCE.init({
    mode: "exact", // not needed
    theme: "modern", // default - not needed. Only theme available in WP 4.0
    height: height, // e.g. 100
    menubar : false, // you probably don't want to show the [file] etc bar
    block_formats: "Paragraph=p;Header 1=h1;Header 2=h2;Header 3=h3;Header 4=h4;Header 5=h5;Header 6=h6",
    toolbar : "formatselect,bold,italic,underline,removeformat", //choose buttons in bar
});
0
votes

There's a fast way to remove everything you see: Using CSS. Maybe it's not the best one, but is the faster one:

#mceu_15, #mceu_17, #mceu_18 {
display:none; }

Those #mceu numbers are the icons I want to hide (added by annoying plugins ;)

NOTE: You have to add this css on your_theme/admin.css

If it doesn't work look / add in your theme functions this:

function admin_style() {  wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');} add_action('admin_enqueue_scripts', 'admin_style');