A wordpress admin color scheme is simply a set of colors which define the look and feel of the admin area. By default WordPress comes with 8 different admin color schemes. Defining yours is easy. Just follow the guide 🙂
Achieving our goal will only take 2 steps:
- First we create our color scheme
- Finally we set it as default for all users
1-Create the color scheme
There are 2 ways to create the color theme: the hardest one which is to create it yourself or generate it. Like my daddy use to say, if you don’t want to waste time, just hang the time wasters! So let’s just go for the easiest way here 🙂 : access http://themergency.com/generators/admin-color-scheme-generator, fill the form, generate and download your color scheme in a zip file.
There are two ways to add the generated color scheme to your wordpress installation:
- The first is to directly use the zip file as a plugin. You only have to install and activate it.
- The second way which I prefer is to include it in your theme. To include the color scheme in your theme, unzip the generated file and copy the unzipped folder in your theme directory. You will see a php class file inside the folder. Include it in your theme function.php file. In my case, I use this code to include it in the theme function.php file:
require_once get_template_directory() . '/darkblue-admin-color-scheme/darkblue-admin-color-scheme.php';
Then you need to edit the darkblue-admin-color-scheme.php file. Search for the add_color_scheme function. Inside this function, replace the second parameter of the wp_admin_css_color “ plugins_url( your_colorscheme.css’, __FILE__ )” by the url of your color scheme main css file “get_template_directory() . ‘/your-admin-color-scheme-folder/’.’your_colorscheme.css’” in my case:
get_template_directory() . ‘/darkblue-admin-color-scheme/’.’darkblue.css’
2. Set the color scheme as default for all user
Now add the following code to the function.php file of your theme. This code simply returns the color scheme you want when wordpress query the current user color scheme from database.
add_filter( 'get_user_option_admin_color', function( $color_scheme ) { $color_scheme = 'your_color_sheme_name'; return $color_scheme; }, 5 );
This set the chosen color scheme as default but it doesn’t remove the admin color scheme picker from the profile page. To achieve that, you can add this code to your function.php file:
remove_action("admin_color_scheme_picker", "admin_color_scheme_picker");