WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/04/2010 04:58:43 PM (10 years ago)
Author:
ryan
Message:

More custom post type support. Props scribu. see #9674

File:
1 edited

Legend:

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

    r12248 r12597  
    6666$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
    6767
     68foreach ( (array) get_post_types( array('_show' => true) ) as $ptype ) {
     69    $_wp_last_object_menu++;
     70    $ptype_obj = get_post_type_object($ptype);
     71    $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div');
     72    $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), 'edit_posts',  "edit.php?post_type=$ptype");
     73    /* translators: add new custom post type */
     74    $submenu["edit.php?post_type=$ptype"][10]  = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" );
     75
     76    $i = 15;
     77    foreach ( $wp_taxonomies as $tax ) {
     78        if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) )
     79            continue;
     80
     81        $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" );
     82        ++$i;
     83    }
     84}
     85unset($ptype, $ptype_obj);
     86
    6887$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
    6988
Note: See TracChangeset for help on using the changeset viewer.