Getting Current WordPress Admin Color Scheme Colors

Here’s a quick and simple one that many of you might not know. This helps dramatically if you want to better match your UI with the current color scheme being used in the WordPress admin dashboard.

function build_admin_colors() {
    global $_wp_admin_css_colors;

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

    $colors = array_merge(
        $_wp_admin_css_colors[ $current_color_scheme ]->colors,
        $_wp_admin_css_colors[ $current_color_scheme ]->icon_colors

    return $colors;

When running this snippet, you’ll get an array containing the hex codes for the current colors and icon colors that are currently in use. Just call that function when you need it.

Leave a Reply