Media: Ensure that uploaded images get a success notification by users with `upload_files` capability.

There was an early `wp_die` that was preventing the success notification from being sent in the upload process. 

Fixes #44581.

Props pbiron, mikeschroder, joemcgill, rebasaurus, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48128 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock 2020-06-22 23:51:09 +00:00
parent 800cfa8a82
commit 4cbe419d15
1 changed files with 5 additions and 4 deletions

View File

@ -45,9 +45,6 @@ if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] )
if ( 'attachment' !== $post->post_type ) { if ( 'attachment' !== $post->post_type ) {
wp_die( __( 'Invalid post type.' ) ); wp_die( __( 'Invalid post type.' ) );
} }
if ( ! current_user_can( 'edit_post', $id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
}
switch ( $_REQUEST['fetch'] ) { switch ( $_REQUEST['fetch'] ) {
case 3: case 3:
@ -55,7 +52,11 @@ if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] )
if ( $thumb_url ) { if ( $thumb_url ) {
echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />'; echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
} }
if ( current_user_can( 'edit_post', $id ) ) {
echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>'; echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
} else {
echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>';
}
// Title shouldn't ever be empty, but use filename just in case. // Title shouldn't ever be empty, but use filename just in case.
$file = get_attached_file( $post->ID ); $file = get_attached_file( $post->ID );