customize admin color scheme with my own colors on multisite

I want to use the same set of colors in admin section (wp-admin) of all sites hosted on a multisite install.
I have added the following code to my child theme:

wp_admin_css_color(
    'MyAdminColors',
    __( 'My Admin Colors'),
    get_template_directory_uri() . '/cssadmin/KPCMS/colors.css',
    array( '#8e1e07', '#fff', '#ff9201', '#d3cbae' ),
    array( 'base' => '#FF6C1C', 'focus' => '#FFFFFF', 'current' => '#FFFFFF' )
);

With that, I can select "My Admin Colors" in my profile, but it is not applied.

How should I manage the CSS files, as SASS is involved.

Please tell me how files should be organized in my child theme to get things done.

  • Adam Czajczyk
    • Support Gorilla

    Hello Luce,

    I hope you're well today and thank you for your question!

    As you have put style files into the child theme, you will want to use "get_stylesheet_directory_uri()" function instead of "get_template_directory_uri()" in your code. The "get_template_directory_uir()" always returns an URL of the parent theme so your CSS file is not available there.

    Alternatively, you may just move your file to the parent theme :slight_smile:

    Other than that, you may use any "folder/file" structure as long as it's reflected in your code.

    If you have any additional questions, let me know please.

    Kind regards,
    Adam

  • Éric Malalel
    • The Incredible Code Injector

    Well, I need something more in fact.
    Now my child theme loads the CSS, so when I edit my profile and select my color set, I can see the colors changing in the WP admin.
    Here is my folder structure:

    And here is the content of the KPS folder which contains the CSS:

    Currently, these files are just copy of files of the standard "sunrise" color set.
    I thought that, by editing only the "colors.scss" file, SASS would regenerate the CSS files, but it looks like nothing is happening: even when I edit and save this file, I still get the standard "sunrise" colors.
    What do I need to do next to have SASS regenerate my CSS with my own colors?

  • Éric Malalel
    • The Incredible Code Injector

    Well, I have put aside the SCSS issue, as I have a workaround by editing the css file itself, and as I have another issue which is more a problem.

    When I log to the admin panel of a site of my multisite install with an admin account and edit my profile, I can select my color scheme, I can see my customized colors applied to admin menus, but as soon as I click on "update profile", the default scheme color is automatically selected and applied.

    here is my code, what is wrong there?

    wp_admin_css_color(
        'KPS',
        'Knowledge Places',
        get_stylesheet_directory_uri() . '/adminCSS/KPS/colors.css',
        array( '#8e1e07', '#fff', '#ff9201', '#d3cbae' ),
        array( 'base' => '#FF6C1C', 'focus' => '#FFFFFF', 'current' => '#FFFFFF' )
    );
    add_filter( 'get_user_option_admin_color', function( $color_scheme ) {
    	$color_scheme = 'KPS';
    	return $color_scheme;
    }, 5 );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.