Make WordPress Core


Ignore:
Timestamp:
10/19/2020 08:27:34 PM (4 years ago)
Author:
antpb
Message:

Media: Add 'Uploaded to' for individual media items in the media editor.
Adds a link in the media editor showing which post a media item was uploaded to.
Props karmatosed, garrett-eclipse, Mista-Flo, SergeyBiryukov, joemcgill, hellofromTonya.
Fixes #46866.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r49193 r49207  
    38103810    $author = new WP_User( $attachment->post_author );
    38113811    if ( $author->exists() ) {
    3812         $response['authorName'] = html_entity_decode( $author->display_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
     3812        $response['authorName'] = html_entity_decode( $author->display_name ? $author->display_name : $author->nickname, ENT_QUOTES, get_bloginfo( 'charset' ) );
     3813        $response['authorLink'] = get_edit_user_link( $author->ID );
    38133814    } else {
    38143815        $response['authorName'] = __( '(no author)' );
     
    38173818    if ( $attachment->post_parent ) {
    38183819        $post_parent = get_post( $attachment->post_parent );
    3819     } else {
    3820         $post_parent = false;
    3821     }
    3822 
    3823     if ( $post_parent ) {
    3824         $parent_type = get_post_type_object( $post_parent->post_type );
    3825 
    3826         if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $attachment->post_parent ) ) {
    3827             $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
    3828         }
    3829 
    3830         if ( $parent_type && current_user_can( 'read_post', $attachment->post_parent ) ) {
     3820        if ( $post_parent ) {
    38313821            $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
     3822            $response['uploadedToLink']  = get_edit_post_link( $attachment->post_parent, 'raw' );
    38323823        }
    38333824    }
Note: See TracChangeset for help on using the changeset viewer.