Opened 12 years ago
Closed 4 months ago
#28324 closed feature request (wontfix)
Add primary and secondary color definitions to admin color schemes and add function to retrieve color scheme info
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.8 |
| Component: | Administration | Keywords: | reporter-feedback close |
| Focuses: | ui, administration | Cc: |
Description
I'd like to be able to implement a user's selected admin color scheme into my plugin admin UI design but, at this point in time, using wp_admin_css_color() to register a color scheme only asks for an array of colors and then depends on a stylesheet to use said colors so there's no way for me to, at the very least, detect a primary and secondary color to use in my design.
From what I can tell, most color schemes have what they consider to be the primary and secondary color, and they use those colors for primary buttons and admin menu links and such, but there's no way for someone else to detect those color values.
It would also be nice if there was a function to retrieve the color scheme info. Perhaps something like this:
function get_user_admin_color() {
global $_wp_admin_css_colors;
if ( ( $user_admin_color = get_user_option( 'admin_color' ) )
&& isset( $_wp_admin_css_colors[ $user_admin_color ] ) ) {
return $_wp_admin_css_colors[ $user_admin_color ];
}
return false;
}
But the big request is changes to the wp_admin_css_color() function so, at the very least, a primary and secondary color can be defined and stored in $_wp_admin_css_colors. Perhaps something like this?
function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array(), $primary_color = NULL, $secondary_color = NULL ) {
global $_wp_admin_css_colors;
// If a primary color is not defined, use first color from $colors array
if ( ! isset( $primary_color ) && count( $colors ) >= 1 )
$primary_color = $colors[0];
// If a secondary color is not defined, use second color from $colors array
if ( ! isset( $secondary_color ) && count( $colors ) >= 2 )
$secondary_color = $colors[1];
if ( ! isset( $_wp_admin_css_colors ) )
$_wp_admin_css_colors = array();
$_wp_admin_css_colors[$key] = (object) array(
'name' => $name,
'url' => $url,
'primary_color' => $primary_color,
'secondary_color => $secondary_color,
'colors' => $colors,
'icon_colors' => $icons,
);
}
Change History (7)
#2
@
12 years ago
There are helper classes for plugins to leverage the active color scheme:
tags/3.9.1/src/wp-admin/css/common.css#L662.
#5
@
11 years ago
- Version changed from trunk to 3.8
Indeed, there are helper CSS classes. See also my reply on #28953 (which I'm closing as a duplicate):
What would the use case be for this? These registered colors are only useful for showing a palette and for the icon colors. They shouldn't be indicative of specific primary/secondary colors, so I'm not sure having a function for them would be a great idea.
#7
@
4 months ago
- Keywords close added
- Resolution set to wontfix
- Status changed from new to closed
I am going to move this for now to close based on the fact there are helper classes and the closure of the other issue as a duplicate. This doesn't mean that further consideration couldn't be made, but for now let's move this ticket on. We can always review if others have strong feelings.
Closely related: #26691