phpcsswordpresscolor-schemecustom-theme

Wordpress - Add a new Admin Color Scheme using functions.php


In the Wordpress UI, on the Profile page (../wp-admin/profile.php), there are eight default Admin Color Schemes that you can select as options: enter image description here

I've found where the CSS for these schemes is created (../wp-admin/css/colors/) and made my own folder with CSS to match.

First off, I can't even get my color scheme to display on the Profile page so I can test it. In ../wp-admin/profile.php it's just this:

define('IS_PROFILE_PAGE', true);

/** Load User Editing Page */
require_once( dirname( __FILE__ ) . '/user-edit.php' );

and in ../wp-admin/user-edit.php here's the section that spits out the color schemes:

<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
<tr class="user-admin-color-wrap">
<th scope="row"><?php _e('Admin Color Scheme')?></th>
<td><?php
    /**
     * Fires in the 'Admin Color Scheme' section of the user editing screen.
     *
     * The section is only enabled if a callback is hooked to the action,
     * and if there is more than one defined color scheme for the admin.
     *
     * @since 3.0.0
     * @since 3.8.1 Added `$user_id` parameter.
     *
     * @param int $user_id The user ID.
     */
    do_action( 'admin_color_scheme_picker', $user_id );
?></td>
</tr>
<?php
endif; // $_wp_admin_css_colors

So my questions are:

  1. How do I get it to display my color scheme on the Profile page so that I can test it and edit it?
  2. Once I'm satisfied with how it looks, how do I put the color scheme in my custom theme's functions.php file so I can import it with every theme install and not have to worry about WordPress erasing it with updates?
  3. How do I set this color scheme as the default one for users?

Let me know if I need to add further details, thanks for the help guys!


Solution

  • For anyone who's wondering: I found an answer! Thanks to help from @Manas Khandelwal, I was able to locate a working site that generated a CSS file for me. It served as a great starting point and I edited it from the basic file it started out with.

    Here's the site and I'd highly recommend it: https://wpadmincolors.com/

    Just follow the instructions to put it in your theme. Thanks guys!