Make WordPress Core

Ticket #26922: admin-icon-fonts.26922.diff

File admin-icon-fonts.26922.diff, 2.6 KB (added by styledev, 11 years ago)

Patch to add filters to allow for new icon fonts.

  • src/wp-admin/menu-header.php

    diff --git src/wp-admin/menu-header.php src/wp-admin/menu-header.php
    index a32f3a5..35c461c 100644
    function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { 
    8383                // so an icon can be added to div.wp-menu-image as background with CSS.
    8484                // Dashicons and base64-encoded data:image/svg_xml URIs are also handled as special cases.
    8585                if ( ! empty( $item[6] ) ) {
    86                         $img = '<img src="' . $item[6] . '" alt="" />';
    87 
     86                        $img_info = array( 'img' => '<img src="' . $item[6] . '" alt="" />', );
     87                       
    8888                        if ( 'none' === $item[6] || 'div' === $item[6] ) {
    89                                 $img = '<br />';
     89                                $img_info['img'] = '<br />';
    9090                        } elseif ( 0 === strpos( $item[6], 'data:image/svg+xml;base64,' ) ) {
    91                                 $img = '<br />';
    92                                 $img_style = ' style="background-image:url(\'' . esc_attr( $item[6] ) . '\')"';
    93                                 $img_class = ' svg';
     91                                $img_info['img'] = '<br />';
     92                                $img_info['img_style'] = ' style="background-image:url(\'' . esc_attr( $item[6] ) . '\')"';
     93                                $img_info['img_class'] = ' svg';
    9494                        } elseif ( 0 === strpos( $item[6], 'dashicons-' ) ) {
    95                                 $img = '<br />';
    96                                 $img_class = ' dashicons ' . sanitize_html_class( $item[6] );
     95                                $img_info['img'] = '<br />';
     96                                $img_info['img_class'] = ' dashicons ' . sanitize_html_class( $item[6] );
    9797                        }
     98                       
     99                        $img_info = apply_filters('admin_img_class', $img_info, $item[6]);
     100                        extract($img_info);
    98101                }
    99102                $arrow = '<div class="wp-menu-arrow"><div></div></div>';
    100103
  • src/wp-admin/menu.php

    diff --git src/wp-admin/menu.php src/wp-admin/menu.php
    index 5a53cff..997c2e0 100644
    foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false, 
    109109        $ptype_for_id = sanitize_html_class( $ptype );
    110110
    111111        if ( is_string( $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 );
     112                $menu_icon   = false;
     113                $iconClasses = array('dashicons-');
     114                $iconClasses = apply_filters('admin_icon_classes', $iconClasses);
     115               
     116                foreach ($iconClasses as $iconClass) {
     117                        if ( 0 === strpos( $ptype_obj->menu_icon, $iconClass ) ) {
     118                                $menu_icon = $ptype_obj->menu_icon;
     119                        }
     120                }
     121               
     122                if (! $menu_icon ) {
     123                        if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) ) {
     124                                $menu_icon = $ptype_obj->menu_icon;
     125                        } else {
     126                                $menu_icon = esc_url( $ptype_obj->menu_icon );
     127                        }
    117128                }
    118129                $ptype_class = $ptype_for_id;
    119130        } else {