Swap Color Schemes When Switching Between Network and Site Admins

I wanted to find a way to make it just a little bit more obvious when I switched between the network and site admins. But I didn’t want to have to do a lot of actual customizing. So using built in styles, I found I could just swap the color schemes.

add_action( 'admin_print_styles', 'admin_color_swap', 99 );
function admin_color_swap() {
    if ( is_network_admin() ) {
        global $current_user;
        get_currentuserinfo();
        $selected = $current_user->admin_color;
        $swapped = array( 'fresh' => 'classic', 'classic' => 'fresh' );
        $new = $swapped[$selected];        
        echo '<link rel="stylesheet" type="text/css" href="/wp-admin/css/colors-'.$new.'.css" />';
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: