mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Allow for Dashicons and base64-encoded data:image/svg+xml URIs when specifying menu icons.
Both of these icons can be colored to match the color scheme, including hover states. Both are accepted for register_post_type()'s menu_icon argument, and also add_menu_page()'s $icon_url argument. To use a Dashicon, pass the name of the helper class, e.g. 'dashicons-piechart'. To use an SVG, pass a valid data URI string starting with 'data:image/svg+xml;base64,'. props helen. fixes #25147. git-svn-id: https://develop.svn.wordpress.org/trunk@26664 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -618,9 +618,21 @@ function wp_color_scheme_settings() {
|
||||
|
||||
$color_scheme = get_user_option( 'admin_color' );
|
||||
|
||||
if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
|
||||
echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) . ";</script>\n";
|
||||
// It's possible to have a color scheme set that is no longer registered.
|
||||
if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
|
||||
$color_scheme = 'fresh';
|
||||
}
|
||||
|
||||
if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
|
||||
$icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
|
||||
} elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
|
||||
$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
|
||||
} else {
|
||||
// Fall back to the default set of icon colors if the default scheme is missing.
|
||||
$icon_colors = array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' );
|
||||
}
|
||||
|
||||
echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
|
||||
}
|
||||
add_action( 'admin_head', 'wp_color_scheme_settings' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user