While designing the new MD Admin Panel I needed to come up with a way to make the panel look a little creative without going too over-the-top on the design.
Then it dawned on me that WordPress introduced multiple admin color schemes not too long ago and I went off to the races to figure out how I could use that color data myself to reuse.
After digging around, it turns out it’s pretty easy:
$admin_color = get_user_option( 'admin_color' );
$colors = $_wp_admin_css_colors[$admin_color]->colors;
For use in any PHP function or file. Mind your php tags.
Let’s break it down a little bit:
- Call the
$_wp_admin_css_colors global variable to get Admin Color Scheme data.
- Get the user’s current color scheme choice as set in their profile and store it in the
- Using the
$admin_color variable, trickle down the object to get a list of the admin colors hex codes and store in the
 => #222
 => #333
 => #0073aa
 => #00a0d2
See for yourself:
<?php print_r( $colors ); ?>
From there you can pick any color down the list by echo’ing the Array item:
<?php echo $color; ?>
The best part is that the colors will update based on a user’s color choice, so your colors will always stay consistent with any Admin Color Scheme.