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.


git-svn-id: https://develop.svn.wordpress.org/trunk@49207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Anthony Burchell
2020-10-19 20:27:34 +00:00
parent 8f88adf9d5
commit ec624193eb
4 changed files with 71 additions and 31 deletions
+16
View File
@@ -458,6 +458,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@@ -467,6 +469,8 @@ form#tags-filter {
#post-body .misc-pub-post-status:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-uploadedby:before,
#post-body .misc-pub-uploadedto:before,
#post-body .misc-pub-revisions:before,
#post-body .misc-pub-response-to:before,
#post-body .misc-pub-comment-status:before {
@@ -495,6 +499,18 @@ form#tags-filter {
top: -1px;
}
#post-body .misc-pub-uploadedby:before {
content: "\f110";
position: relative;
top: -1px;
}
#post-body .misc-pub-uploadedto:before {
content: "\f318";
position: relative;
top: -1px;
}
#post-body .misc-pub-revisions:before {
content: "\f321";
}
+31 -1
View File
@@ -3288,7 +3288,37 @@ function attachment_submitbox_metadata() {
$att_url = wp_get_attachment_url( $attachment_id );
?>
$author = get_userdata( $post->post_author );
$uploaded_by_name = __( '(no author)' );
$uploaded_by_link = '';
if ( $author->exists() ) {
$uploaded_by_name = $author->display_name ? $author->display_name : $author->nickname;
$uploaded_by_link = get_edit_user_link( $author->ID );
} ?>
<div class="misc-pub-section misc-pub-uploadedby">
<?php if ( $uploaded_by_link ) : ?>
<?php _e( 'Uploaded by:' ); ?> <a href="<?php echo $uploaded_by_link ?>"><strong><?php echo $uploaded_by_name ?></strong></a>
<?php else: ?>
<?php _e( 'Uploaded by:' ); ?> <strong><?php echo $uploaded_by_name ?></strong>
<?php endif; ?>
</div>
<?php if ( $post->post_parent ) :
$post_parent = get_post( $post->post_parent );
if ( $post_parent ) :
$uploaded_to_title = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
$uploaded_to_link = get_edit_post_link( $post->post_parent, 'raw' ); ?>
<div class="misc-pub-section misc-pub-uploadedto">
<?php if ( $uploaded_to_link ) : ?>
<?php _e( 'Uploaded to:' ); ?> <a href="<?php echo $uploaded_to_link ?>"><strong><?php echo $uploaded_to_title; ?></strong></a>
<?php else: ?>
<?php _e( 'Uploaded to:' ); ?> <strong><?php echo $uploaded_to_title; ?></strong>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="misc-pub-section misc-pub-attachment">
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" id="attachment_url" value="<?php echo esc_attr( $att_url ); ?>" />