diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php
index 746abf3662..870f36f3ae 100644
--- a/wp-admin/includes/class-wp-media-list-table.php
+++ b/wp-admin/includes/class-wp-media-list-table.php
@@ -748,129 +748,90 @@ class WP_Media_List_Table extends WP_List_Table {
private function _get_row_actions( $post, $att_title ) {
$actions = array();
- if ( $this->detached ) {
- if ( current_user_can( 'edit_post', $post->ID ) ) {
- $actions['edit'] = sprintf(
- '%s',
- get_edit_post_link( $post->ID ),
+ if ( ! $this->is_trash && current_user_can( 'edit_post', $post->ID ) ) {
+ $actions['edit'] = sprintf(
+ '%s',
+ esc_url( get_edit_post_link( $post->ID ) ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
+ __( 'Edit' )
+ );
+ }
+
+ if ( current_user_can( 'delete_post', $post->ID ) ) {
+ if ( $this->is_trash ) {
+ $actions['untrash'] = sprintf(
+ '%s',
+ esc_url( wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) ),
/* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
- __( 'Edit' )
+ esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ),
+ __( 'Restore' )
+ );
+ } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
+ $actions['trash'] = sprintf(
+ '%s',
+ esc_url( wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
+ _x( 'Trash', 'verb' )
);
}
- if ( current_user_can( 'delete_post', $post->ID ) ) {
- if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
- $actions['trash'] = sprintf(
- '%s',
- wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
- _x( 'Trash', 'verb' )
- );
- } else {
- $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
- $actions['delete'] = sprintf(
- '%s',
- wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
- $delete_ays,
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
- __( 'Delete Permanently' )
- );
- }
- }
+ if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
+ $show_confirmation = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
- if ( get_permalink( $post->ID ) ) {
+ $actions['delete'] = sprintf(
+ '%s',
+ esc_url( wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) ),
+ $show_confirmation,
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
+ __( 'Delete Permanently' )
+ );
+ }
+ }
+
+ $attachment_url = wp_get_attachment_url( $post->ID );
+
+ if ( ! $this->is_trash ) {
+ $permalink = get_permalink( $post->ID );
+
+ if ( $permalink ) {
$actions['view'] = sprintf(
'%s',
- get_permalink( $post->ID ),
+ esc_url( $permalink ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
__( 'View' )
);
}
- if ( current_user_can( 'edit_post', $post->ID ) ) {
- $actions['attach'] = sprintf(
- '%s',
- $post->ID,
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
- __( 'Attach' )
- );
- }
- } else {
- if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
- $actions['edit'] = sprintf(
- '%s',
- get_edit_post_link( $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
- __( 'Edit' )
- );
- }
+ $actions['copy'] = sprintf(
+ '%s',
+ esc_url( $attachment_url ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
+ __( 'Copy URL' ),
+ __( 'Copied!' )
+ );
+ }
- if ( current_user_can( 'delete_post', $post->ID ) ) {
- if ( $this->is_trash ) {
- $actions['untrash'] = sprintf(
- '%s',
- wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ),
- __( 'Restore' )
- );
- } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
- $actions['trash'] = sprintf(
- '%s',
- wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
- _x( 'Trash', 'verb' )
- );
- }
+ $actions['download'] = sprintf(
+ '%s',
+ esc_url( $attachment_url ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
+ __( 'Download file' )
+ );
- if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
- $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
- $actions['delete'] = sprintf(
- '%s',
- wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
- $delete_ays,
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
- __( 'Delete Permanently' )
- );
- }
- }
-
- if ( ! $this->is_trash ) {
- if ( get_permalink( $post->ID ) ) {
- $actions['view'] = sprintf(
- '%s',
- get_permalink( $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
- __( 'View' )
- );
- }
-
- $actions['copy'] = sprintf(
- '%s',
- esc_url( wp_get_attachment_url( $post->ID ) ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
- __( 'Copy URL' ),
- __( 'Copied!' )
- );
-
- $actions['download'] = sprintf(
- '%s',
- esc_url( wp_get_attachment_url( $post->ID ) ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
- __( 'Download file' )
- );
- }
+ if ( $this->detached && current_user_can( 'edit_post', $post->ID ) ) {
+ $actions['attach'] = sprintf(
+ '%s',
+ $post->ID,
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
+ __( 'Attach' )
+ );
}
/**
@@ -879,7 +840,8 @@ class WP_Media_List_Table extends WP_List_Table {
* @since 2.8.0
*
* @param string[] $actions An array of action links for each attachment.
- * Default 'Edit', 'Delete Permanently', 'View'.
+ * Includes 'Edit', 'Delete Permanently', 'View',
+ * 'Copy URL' and 'Download file'.
* @param WP_Post $post WP_Post object for the current attachment.
* @param bool $detached Whether the list table contains media not attached
* to any posts. Default true.
diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php
index 7cd8496aff..1ac43f8221 100644
--- a/wp-admin/includes/meta-boxes.php
+++ b/wp-admin/includes/meta-boxes.php
@@ -469,10 +469,20 @@ function attachment_submit_meta_box( $post ) {
ID ) ) {
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
- echo "" . __( 'Move to Trash' ) . '';
+ printf(
+ '%2$s',
+ get_delete_post_link( $post->ID ),
+ __( 'Move to Trash' )
+ );
} else {
- $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
- echo "" . __( 'Delete permanently' ) . '';
+ $show_confirmation = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
+
+ printf(
+ '%3$s',
+ $show_confirmation,
+ get_delete_post_link( $post->ID, '', true ),
+ __( 'Delete permanently' )
+ );
}
}
?>
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 831ced546a..fb601e3fd6 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.3-alpha-55948';
+$wp_version = '6.3-alpha-55949';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.