Ticket #14772: 14772.CPT-new-content.diff
File 14772.CPT-new-content.diff, 2.3 KB (added by , 13 years ago) |
---|
-
wp-includes/admin-bar.php
180 180 if ( empty($current_object) ) 181 181 return; 182 182 183 // @todo Use proper type name in edit strings184 183 if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) ) { 185 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit Post' ), 'href' => get_edit_post_link( $current_object->ID ), ) );184 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link( $current_object->ID ), ) ); 186 185 } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) ) { 187 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit Post' ), 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ), ) );186 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ), ) ); 188 187 } 189 188 } 190 189 191 190 function wp_admin_bar_new_content_menu() { 192 191 global $wp_admin_bar; 193 192 194 // @todo Handle CPTs, use post type object for strings 195 $actions = array( 196 'post-new.php' => array(__('Post'), 'edit_posts', 'new-post'), 197 'post-new.php?post_type=page' => array(__('Page'), 'edit_pages', 'new-page'), 198 ); 199 200 $user_can = false; 201 foreach ( $actions as $action ) { 202 if ( current_user_can($action[1]) ) { 203 $user_can = true; 204 break; 205 } 193 $actions = array(); 194 foreach ( (array) get_post_types( array('show_ui' => true, 'show_in_menu' => true) ) as $ptype ) { 195 $ptype_obj = get_post_type_object( $ptype ); 196 if ( $ptype_obj->show_in_menu !== true || ! current_user_can( $ptype_obj->cap->edit_posts ) ) 197 continue; 198 199 $actions["post-new.php?post_type=$ptype"] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, "new-$ptype" ); 206 200 } 207 201 208 if ( !$user_can)202 if ( empty( $actions ) ) 209 203 return; 210 204 211 205 $wp_admin_bar->add_menu( array( 'id' => 'new-content', 'title' => __( 'New Content' ), 'href' => '', ) );