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:
Andrew Nacin
2013-12-05 06:37:20 +00:00
parent 721ffcbb07
commit 006045395c
7 changed files with 53 additions and 13 deletions

View File

@@ -107,8 +107,14 @@ foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false,
continue;
$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.
$ptype_for_id = sanitize_html_class( $ptype );
if ( is_string( $ptype_obj->menu_icon ) ) {
$menu_icon = esc_url( $ptype_obj->menu_icon );
// Special handling for data:image/svg+xml and Dashicons.
if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) {
$menu_icon = $ptype_obj->menu_icon;
} else {
$menu_icon = esc_url( $ptype_obj->menu_icon );
}
$ptype_class = $ptype_for_id;
} else {
$menu_icon = 'none';