Title: WP_Media_List_Table::_get_row_actions
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Media_List_Table::_get_row_actions( WP_Post $post, string $att_title ): array<string,

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Gets the row actions for a media item.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#parameters)󠁿

 `$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)required

The current [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
object.

`$att_title`stringrequired

The attachment title.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#return)󠁿

 array<string, string> An array of row actions.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#source)󠁿

    ```php
    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 &#8220;%s&#8221;' ), $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&amp;post=$post->ID", 'untrash-post_' . $post->ID ) ),
    				/* translators: %s: Attachment title. */
    				esc_attr( sprintf( __( 'Restore &#8220;%s&#8221; 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&amp;post=$post->ID", 'trash-post_' . $post->ID ) ),
    				/* translators: %s: Attachment title. */
    				esc_attr( sprintf( __( 'Move &#8220;%s&#8221; 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&amp;post=$post->ID", 'delete-post_' . $post->ID ) ),
    				$show_confirmation,
    				/* translators: %s: Attachment title. */
    				esc_attr( sprintf( __( 'Delete &#8220;%s&#8221; 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 &#8220;%s&#8221;' ), $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 &#8220;%s&#8221; 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 &#8220;%s&#8221;' ), $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 &#8220;%s&#8221; 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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-media-list-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-wp-media-list-table.php#L802)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-media-list-table.php#L802-L908)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#hooks)󠁿

 [apply_filters( ‘media_row_actions’, string[] $actions, WP_Post $post, bool $detached )](https://developer.wordpress.org/reference/hooks/media_row_actions/)

Filters the action links for each attachment in the Media list table.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#related)󠁿

| Uses | Description | 
| [get_edit_post_link()](https://developer.wordpress.org/reference/functions/get_edit_post_link/)`wp-includes/link-template.php` |

Retrieves the edit post link for post.

  | 
| [wp_get_attachment_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_url/)`wp-includes/post.php` |

Retrieves the URL for an attachment.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [wp_nonce_url()](https://developer.wordpress.org/reference/functions/wp_nonce_url/)`wp-includes/functions.php` |

Retrieves URL with nonce added to URL query.

  | 
| [get_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/)`wp-includes/link-template.php` |

Retrieves the full permalink for the current post or post ID.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 8 more](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#)

| Used by | Description | 
| [WP_Media_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_media_list_table/handle_row_actions/)`wp-admin/includes/class-wp-media-list-table.php` |

Generates and displays row action links.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_media_list_table/_get_row_actions/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_media_list_table%2F_get_row_actions%2F)
before being able to contribute a note or feedback.