Make WordPress Core


Ignore:
Timestamp:
12/05/2013 06:37:20 AM (11 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r26601 r26664  
    619619    $color_scheme = get_user_option( 'admin_color' );
    620620
     621    // It's possible to have a color scheme set that is no longer registered.
     622    if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
     623        $color_scheme = 'fresh';
     624    }
     625
    621626    if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
    622         echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) . ";</script>\n";
    623     }
     627        $icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
     628    } elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
     629        $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
     630    } else {
     631        // Fall back to the default set of icon colors if the default scheme is missing.
     632        $icon_colors = array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' );
     633    }
     634
     635    echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
    624636}
    625637add_action( 'admin_head', 'wp_color_scheme_settings' );
Note: See TracChangeset for help on using the changeset viewer.