wp/wp-admin/async-upload.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    62 					$file_url = wp_get_attachment_url( $post->ID );
    62 					$file_url = wp_get_attachment_url( $post->ID );
    63 					$title    = $post->post_title ? $post->post_title : wp_basename( $file );
    63 					$title    = $post->post_title ? $post->post_title : wp_basename( $file );
    64 					?>
    64 					?>
    65 					<div class="filename new">
    65 					<div class="filename new">
    66 						<span class="media-list-title"><strong><?php echo esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ); ?></strong></span>
    66 						<span class="media-list-title"><strong><?php echo esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ); ?></strong></span>
    67 						<span class="media-list-subtitle"><?php echo wp_basename( $file ); ?></span>
    67 						<span class="media-list-subtitle"><?php echo esc_html( wp_basename( $file ) ); ?></span>
       
    68 						<div class="attachment-tools">
       
    69 							<?php
       
    70 							if ( current_user_can( 'edit_post', $id ) ) {
       
    71 								echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '">' . _x( 'Edit', 'media item' ) . '</a>';
       
    72 							} else {
       
    73 								echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>';
       
    74 							}
       
    75 							?>
       
    76 							<span class="media-item-copy-container copy-to-clipboard-container edit-attachment">
       
    77 								<button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
       
    78 								<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
       
    79 							</span>
       
    80 						</div>
    68 					</div>
    81 					</div>
    69 				</div>
       
    70 				<div class="attachment-tools">
       
    71 					<span class="media-item-copy-container copy-to-clipboard-container edit-attachment">
       
    72 						<button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button>
       
    73 						<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
       
    74 					</span>
       
    75 					<?php
       
    76 					if ( current_user_can( 'edit_post', $id ) ) {
       
    77 						echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '">' . _x( 'Edit', 'media item' ) . '</a>';
       
    78 					} else {
       
    79 						echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>';
       
    80 					}
       
    81 					?>
       
    82 				</div>
    82 				</div>
    83 			</div>
    83 			</div>
    84 			<?php
    84 			<?php
    85 			break;
    85 			break;
    86 		case 2:
    86 		case 2:
   111 	}
   111 	}
   112 }
   112 }
   113 
   113 
   114 $id = media_handle_upload( 'async-upload', $post_id );
   114 $id = media_handle_upload( 'async-upload', $post_id );
   115 if ( is_wp_error( $id ) ) {
   115 if ( is_wp_error( $id ) ) {
   116 	printf(
   116 	$message = sprintf(
   117 		'<div class="error-div error">%s <strong>%s</strong><br />%s</div>',
   117 		'%s <strong>%s</strong><br />%s',
   118 		sprintf(
   118 		sprintf(
   119 			'<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>',
   119 			'<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>',
   120 			__( 'Dismiss' )
   120 			__( 'Dismiss' )
   121 		),
   121 		),
   122 		sprintf(
   122 		sprintf(
   123 			/* translators: %s: Name of the file that failed to upload. */
   123 			/* translators: %s: Name of the file that failed to upload. */
   124 			__( '&#8220;%s&#8221; has failed to upload.' ),
   124 			__( '&#8220;%s&#8221; has failed to upload.' ),
   125 			esc_html( $_FILES['async-upload']['name'] )
   125 			esc_html( $_FILES['async-upload']['name'] )
   126 		),
   126 		),
   127 		esc_html( $id->get_error_message() )
   127 		esc_html( $id->get_error_message() )
       
   128 	);
       
   129 	wp_admin_notice(
       
   130 		$message,
       
   131 		array(
       
   132 			'additional_classes' => array( 'error-div', 'error' ),
       
   133 			'paragraph_wrap'     => false,
       
   134 		)
   128 	);
   135 	);
   129 	exit;
   136 	exit;
   130 }
   137 }
   131 
   138 
   132 if ( $_REQUEST['short'] ) {
   139 if ( $_REQUEST['short'] ) {