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/menu.php

    r25133 r26664  
    108108    $ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.
    109109    $ptype_for_id = sanitize_html_class( $ptype );
     110
    110111    if ( is_string( $ptype_obj->menu_icon ) ) {
    111         $menu_icon   = esc_url( $ptype_obj->menu_icon );
     112        // Special handling for data:image/svg+xml and Dashicons.
     113        if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) {
     114            $menu_icon = $ptype_obj->menu_icon;
     115        } else {
     116            $menu_icon = esc_url( $ptype_obj->menu_icon );
     117        }
    112118        $ptype_class = $ptype_for_id;
    113119    } else {
Note: See TracChangeset for help on using the changeset viewer.