WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#17273 closed defect (bug) (fixed)

Admin Bar Edit link should support Attachments

Reported by: dd32 Owned by: dd32
Milestone: 3.2 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

Currently the Admin bar presents a Edit link for any post type for which the user can edit the post and, show_ui = true.

Attachments pass every check, except due to their inbuilt nature, show_ui is false.

  • wp-includes/admin-bar.php

     
    165165        if ( empty($current_object) ) 
    166166                return; 
    167167 
    168         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 ) && $post_type_object->show_ui ) { 
     168        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 ) && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) ) { 
    169169                $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item,  'href' => get_edit_post_link( $current_object->ID ) ) ); 
    170170        } elseif ( ! empty( $current_object->taxonomy ) &&  ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) { 
    171171                $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 ) ) ); 

Can anyone see a better method other than the above patch?

Change History (2)

comment:1 @nacin4 years ago

Looks good to me.

comment:2 @dd324 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In [17778]:

Support Edit link on the Admin Bar for Attachments. Fixes #17273

Note: See TracTickets for help on using tickets.