[wp-hackers] Admin Color Schemes: generic classes for colors?

Nikola Nikolov nikolov.tmw at gmail.com
Fri Dec 20 15:58:00 UTC 2013


Right - I didn't notice that :doh:

Now I see what you mean, and besides probably copy-pasting the values(or
using JS as you suggested) - which is obviously a very tedious approach, I
don't think you have a lot of options there.


On Fri, Dec 20, 2013 at 5:53 PM, Dino Termini <dino at duechiacchiere.it>wrote:

> Hi Nikola,
>
> WordPress already adds the current color schema class to the body tag. But
> then I don't see anything in the CSS that I could use to recycle, let's
> say, the admin sidebar current background color and use it as the
> background color for my metabox headers. Yes, I could do this in jQuery,
> but I was hoping for a pure CSS approach.
>
> Thank you and happy holidays,
> Dino
>
>
> On 12/20/13, 10:49 AM, Nikola Nikolov wrote:
>
>> Hi Dino,
>>
>> Why don't you try something like this:
>>
>> function add_color_scheme_class( $class ) {
>>      $color = get_user_option( 'admin_color' );
>>      $class .= $color ? " admin-color-{$color} " : ' admin-color-fresh '/*
>> "fresh" is the default */;
>>
>>      return $class;
>> }
>> add_filter( 'admin_body_class', 'add_color_scheme_class', 10 );
>>
>> That should add the classes automatically for you - I know that you wanted
>> a core solution, but I assume for that it would be best to open a
>> ticket(you can do that here - http://core.trac.wordpress.org/ ).
>>
>> Greetings,
>> Nikola
>>
>> PS: I haven't tested the code, but it should work just fine.
>>
>>
>> On Fri, Dec 20, 2013 at 5:26 PM, Dino Termini <dino at duechiacchiere.it
>> >wrote:
>>
>>  Hi folks,
>>>
>>> we are trying to adapt our plugin to the new admin color schemes, and it
>>> would be great if we could have generic CSS class declarations that allow
>>> us to apply the current scheme's background/text colors to our elements.
>>> Something like
>>>
>>> .admin-color-flat .sidebar-background-color{ background-color: #.... }
>>> .admin-color-vineyard .sidebar-background-color{ background-color: #....
>>> }
>>>
>>> This would allow plugin developers to leverage those schemes without
>>> having to reinvent the wheel every time, and would make their plugins
>>> adapt
>>> to any third-party color scheme people may be using on their site.
>>>
>>> Thank you,
>>> Dino.
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>>  _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list