Allow Text tab in the classic editor

This additional option for a role returns back the “Text” tab in the WordPress classic post/page editor. It’s useful when you switch off the “Text” tab by default for all uses except administrator.

no text tab in the editor
No text tab in the editor

We can achieve this adding the code below to active theme functions.php file or setup it as a Must Use plugin:

// Hide Text tab in the WP classic editor by default
function my_editor_settings( $settings ) {
    
    $user = wp_get_current_user();    
    if ( in_array('administrator', $user->roles ) ) {
        // do not restrict administrator
        return $settings;
    }
    
    $settings['quicktags'] = false;
    
    return $settings;
}

add_filter('wp_editor_settings', 'my_editor_settings');

The next piece of code adds for all existing user roles at the bottom of URE page the additional option “Add Text tab to editor”:

// Add option "Allow Text tab" for user role at URE
add_filter( 'ure_role_additional_options', 'add_allow_text_tab_to_editor_option', 10, 1 );

function add_allow_text_tab_to_editor_option( $items ) {
    $item = URE_Role_Additional_Options::create_item( 'add_allow_text_tab_to_editor', esc_html__('Add Text tab to editor', 'user-role-editor'), 'wp_editor_settings', 'add_allow_text_tab_to_editor' );
    $items[$item->id] = $item;
    
    return $items;
}

function add_allow_text_tab_to_editor( $settings ) {

    $settings['quicktags'] = true;
    
    return $settings;    
}

add text tab to editor
Add text tab to editor

If this option is turned ON for some user role, user with role sees both ‘Visual’ and ‘Text’ tab in the WordPress classic text editor, like below:
text tab is available
Text tab is available