'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.

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?



Solution 1:[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
} 

Solution 2:[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 );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 aghigi