Parameters
$post
WP_Postrequired$att_title
stringrequired
Source
private function _get_row_actions( $post, $att_title ) {
$actions = array();
if ( ! $this->is_trash && current_user_can( 'edit_post', $post->ID ) ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
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(
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
esc_url( 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(
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
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 ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
$show_confirmation = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
$actions['delete'] = sprintf(
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
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(
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
esc_url( $permalink ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
__( 'View' )
);
}
if ( $attachment_url ) {
$actions['copy'] = sprintf(
'<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>',
esc_url( $attachment_url ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
__( 'Copy URL' ),
__( 'Copied!' )
);
}
}
if ( $attachment_url ) {
$actions['download'] = sprintf(
'<a href="%s" aria-label="%s" download>%s</a>',
esc_url( $attachment_url ),
/* 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(
'<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
$post->ID,
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
__( 'Attach' )
);
}
/**
* Filters the action links for each attachment in the Media list table.
*
* @since 2.8.0
*
* @param string[] $actions An array of action links for each attachment.
* 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.
*/
return apply_filters( 'media_row_actions', $actions, $post, $this->detached );
}
Hooks
- apply_filters( ‘media_row_actions’,
string[] $actions ,WP_Post $post ,bool $detached ) Filters the action links for each attachment in the Media list table.
User Contributed Notes
You must log in before being able to contribute a note or feedback.