WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get the stylesheet of the currently active admin color scheme to style a plugin to fit into the color context.

As mentioned in this post I had a look at the implementation of admin_color_scheme_picker() in wp-admin/includes/misc.php:564. They use a global variable called $_wp_admin_css_colors but when I try to access (var_dump()) it, it's NULL.

Is there any way to access to actual CSS code?

Why is the global variable NULL? I did a grep -n '$_wp_admin_css_colors' -r . and couldn't find any line where it gets destroyed...


I see it wasn't clear what I exactly want. I don't want to access the actual CSS code, but the color codes that gets parsed into CSS. In wp-includes/general-template.php:2117 the default themes are registered like this:

wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
    admin_url( "css/colors$suffix.css" ),
    array( '#222', '#333', '#0074a2', '#2ea2cc' ),
    array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' )

And I'd like to access the variables like this in PHP. Copying the definition is not an option, since other plugins and themes could add their theme themselves.

share|improve this question

I actually made it!

In my script file, at the to I define a new variable and copy the $_wp_admin_css_colors variable into it using the admin_head hook, since the variable gets destroyed at some later point:

    global $admin_colors; // only needed if colors must be available in classes
    add_action('admin_head', function() {
        global $_wp_admin_css_colors;
        global $admin_colors; // only needed if colors must be available in classes
        $admin_colors = $_wp_admin_css_colors;

    // more script content...
share|improve this answer

The color scheme is stored as user meta:

$color = get_user_meta(get_current_user_id(), 'admin_color', true);

However, the CSS file seems to be generated when having chosen another scheme.

So you just need this:

$admin_css_file = wp_admin_css_uri('css/colors');
share|improve this answer
Please re-read my answer, I clarified, what I really wanted :) – Julian F. Weinert Jan 23 '14 at 17:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.