WordPress: how to hide toolbar in post editor?

I have a Custom Post Type (Products) in my WordPress web site.

This is a WooCommerce Product, if it’s necessary to know.

Read More

I need to hide toolbar (1) into wp-editor on Add Product page.
Also I need to hide “Add media” button (2) and “Visual/Text” tabs (3).

How do I hide them?

Maybe it make sense to change this WordPress Editor to the textarea with the same value of “name” attribute with using of some hooks?

how to hide toolbar in post editor?

Related posts

3 comments

  1. You can use function.php or plugin to manage this code.You need to put a action.

    Remove media button:

    function z_remove_media_controls() {
         remove_action( 'media_buttons', 'media_buttons' );
    }
     add_action('admin_head','z_remove_media_controls');
    

    Remove Visual tab

    add_filter( 'admin_footer', 'custom_edit_page_js', 99);
    
    function custom_edit_page_js(){ 
    echo '  <style type="text/css">
            a#content-tmce, a#content-tmce:hover, #qt_content_fullscreen{
                display:none;
            }
            </style>';
    echo '  <script type="text/javascript">
            jQuery(document).ready(function(){
                jQuery("#content-tmce").attr("onclick", null);
            });
            </script>'; 
    }
    

    You can Identify post type is,

    if( get_post_type() == 'product' && is_admin()) {
        //do some stuff
    } 
    
  2. I found here this elegant solution:

    function wpse_199918_wp_editor_settings( $settings, $editor_id ) {
        if ( $editor_id === 'content' && get_current_screen()->post_type === 'custom_post_type' ) {
            $settings['tinymce']   = false;
            $settings['quicktags'] = false;
            $settings['media_buttons'] = false;
        }
    
        return $settings;
    }
    
    add_filter( 'wp_editor_settings', 'wpse_199918_wp_editor_settings', 10, 2 );
    
  3. I have found this solution:

        function hide_toolbar_TinyMCE( $in ) {
            $in['toolbar1'] = '';
            $in['toolbar2'] = '';
            $in['toolbar'] = false;
            return $in; 
        }
        add_filter( 'tiny_mce_before_init', 'hide_toolbar_TinyMCE' );
    

    But it hide toolbar everywhere, because this is “filter” but not “action”.
    How do I hide it only on Product (Custom Post Type) Add/Edit page?

Comments are closed.