WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/16/2010 03:29:34 AM (12 years ago)
Author:
nacin
Message:

Fix menu icons for custom post types. Fixes #12992, props wmrom.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/menu.php

    r14097 r14100  
    8080$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
    8181
    82 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-posts', 'menu-posts', 'div' );
     82$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
    8383    $submenu['edit.php'][5]  = array( __('Edit'), 'edit_posts', 'edit.php' );
    8484    /* translators: add new post */
     
    105105    $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
    106106
    107 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-pages', 'menu-pages', 'div' );
     107$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
    108108    $submenu['edit.php?post_type=page'][5] = array( __('Edit'), 'edit_pages', 'edit.php?post_type=page' );
    109109    /* translators: add new page */
     
    115115
    116116foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) {
    117     $ptype_obj = get_post_type_object($ptype);
    118     $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.
    119     $menu_icon = is_string($ptype_obj->menu_icon) ? esc_url($ptype_obj->menu_icon) : 'div';
     117    $ptype_obj = get_post_type_object( $ptype );
     118    $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.
     119    if ( is_string( $ptype_obj->menu_icon ) ) {
     120        $menu_icon   = esc_url( $ptype_obj->menu_icon );
     121        $ptype_class = sanitize_html_class( $ptype );
     122    } else {
     123        $menu_icon   = 'div';
     124        $ptype_class = 'post';
     125    }
    120126
    121127    // if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position.
     
    124130        $ptype_menu_position++;
    125131
    126     $menu[$ptype_menu_position] = array(esc_attr($ptype_obj->label), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-posts', 'menu-' . sanitize_html_class($ptype), $menu_icon);
     132    $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->label ), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon );
    127133    $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), $ptype_obj->edit_type_cap,  "edit.php?post_type=$ptype");
    128134    /* translators: add new custom post type */
Note: See TracChangeset for help on using the changeset viewer.