Remove text tab

I would like to ask whether there is a function to remove/turn off the Text tab for users ?

Enough good codes here to make a clean CMS, only this one I can not find.

Screenshot

2 Answers
2

This requires two steps:

1) First, we need to hide the editor tabs, which can be accomplished easily enough using CSS. We’ll output some CSS to the admin head to do that:

function hide_editor_tabs() {
    global $pagenow;

    // Only output the CSS if we're on the edit post or add new post screens.
    if ( ! ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) ) {
        return;
    }

?>
<style>
    .wp-editor-tabs {
        display: none;
    }
</style>
<?php

}
add_action( 'admin_head', 'hide_editor_tabs' );

Keep in mind that while we could hide only one of the tabs, like the OP requested, we should actually hide both of them. Since there are only two of them total, it would not make any sense to hide only one, and then have one tab remaining, which would then have no purpose.

2) Next, we need to force the visual editor to be the default. Since we have hidden the tabs in step one, users will not be able to switch away from the default.

function force_default_editor() {
    return 'tinymce';
}
add_filter( 'wp_default_editor', 'force_default_editor' );

If you want to force the text editor instead, just change return 'tinymce'; to return 'text'; in step 2.

Leave a Comment