I know how to print the current color scheme by using:

echo get_user_option( 'admin_color', get_current_user_id() );


echo get_user_meta(get_current_user_id(), 'admin_color', true);

but I need to print a specific color of this scheme. In other words I want the $colors array of this function:

<?php wp_admin_css_color( $key, $name, $url, $colors, $icons ); ?>

I have to use colors in the setting page of my plugin but I want to be coherent. Any solution is greatly appreciated!

  • Hi, I need to know the four colors of the color scheme. I know my colors now but I want the colors to change dynamically within the color scheme. This is for a setting page. – isar Dec 14 '14 at 0:20
  • There is an example of the colors array here – isar Dec 14 '14 at 0:28

Color schemes are registered globally within $_wp_admin_css_colors (see wp-includes/general-template.php for reference).

You can return the colors for the current user depending on get_user_meta() for a specific settings page like this:

global $pagenow;
if ( $pagenow == 'options-permalink.php' ) :
  add_action( 'admin_notices', 'get_current_user_admin_color' );
  function get_current_user_admin_color() {
    global $_wp_admin_css_colors;
    $user_admin_color = get_user_meta(get_current_user_id(), 'admin_color', true);

    echo '<pre>';
    echo '</pre>';

Feel free to vary the action hook to fit your needs: maybe admin_notices is to specific, so you may also try something like admin_head.

Moreover $_wp_admin_css_colors[$user_admin_color] is holding even more meta data about the current admin color scheme:

  • [name] Name of the current admin color scheme
  • [url] Absolute path to the current color scheme CSS file
  • [colors] Colors of the current admin color scheme
  • [icon_colors] Icon colors of the current admin color scheme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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