Make WordPress Core

Changeset 14014


Ignore:
Timestamp:
04/06/2010 04:32:08 AM (14 years ago)
Author:
markjaquith
Message:

Add menu_position and menu_icon params to register_post_type(). props ptahdunbar. fixes #12541

Location:
trunk
Files:
2 edited

Legend:

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

    r13841 r14014  
    117117    $_wp_last_object_menu++;
    118118    $ptype_obj = get_post_type_object($ptype);
    119 
    120     $menu[$_wp_last_object_menu] = 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), 'div');
     119    $ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : $_wp_last_object_menu;
     120    $menu_icon = is_string($ptype_obj->menu_icon) ? esc_url($ptype_obj->menu_icon) : 'div';
     121   
     122    $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);
    121123    $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), $ptype_obj->edit_type_cap,  "edit.php?post_type=$ptype");
    122124    /* translators: add new custom post type */
  • trunk/wp-includes/post.php

    r13997 r14014  
    765765 * publicly_queryable - Whether post_type queries can be performed from the front page.  Defaults to whatever public is set as.
    766766 * show_ui - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public.
     767 * menu_position - The position in the menu order the post type should appear. Defaults to the bottom.
     768 * menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon.
    767769 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
    768770 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
     
    793795
    794796    // Args prefixed with an underscore are reserved for internal use.
    795     $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'permalink_epmask' => EP_NONE );
     797    $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_NONE );
    796798    $args = wp_parse_args($args, $defaults);
    797799    $args = (object) $args;
Note: See TracChangeset for help on using the changeset viewer.