Hooking into register_admin_color_schemes

No, you can’t hook into that function since there is no do_action or apply_filters in it, the function itself hooks to admin_init. So if your goal is to add new color schemes you have to hook your code the same way, so using your example, the required code would be something like this:

// Define the function that registers the color schemes.
function wpse244982_register_admin_color_schemes() {
    wp_admin_css_color( 'ffa', _x( 'My Custom Color Combo', 'admin color scheme' ),
        admin_url( "/my-plugin=directory/css/colors/my-custom-color-combo/colors$suffix.css" ),
        array( '#ffffff', '#ffcd00', '#c7a589', '#9ea476' ),
        array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
    );

    // Maybe more colors schemes here
    // wp_admin_css_color(...);
    // wp_admin_css_color(...);
}

// Hook it to admin_init as WordPress does
add_action( 'admin_init', 'wpse244982_register_admin_color_schemes');

Leave a Comment