WP_Media_List_Table::handle_row_actions() WordPress Method

The WP_Media_List_Table::handle_row_actions() method is used to handle the default row actions for the media list table. This method is used to handle the default row actions for the media list table. The row actions are the links that are displayed at the end of each row in the table. The handle_row_actions() method allows you to override the default row actions. This can be useful if you want to add your own custom actions or remove some of the default actions. The default row actions are: -Edit -Delete -View You can override the default row actions by using the following filter: wp_media_list_table_row_actions This filter allows you to modify the array of row actions. The array is keyed by the action name and the value is the link HTML. For example, to remove the Edit action, you would use the following code: add_filter( 'wp_media_list_table_row_actions', 'my_custom_row_actions', 10, 2 ); function my_custom_row_actions( $actions, $post ) { unset( $actions['edit'] ); return $actions; }

WP_Media_List_Table::handle_row_actions( WP_Post $item, string $column_name, string $primary ) #

Generates and displays row action links.


Parameters

$item

(WP_Post)(Required)Attachment being acted upon.

$column_name

(string)(Required)Current column name.

$primary

(string)(Required)Primary column name.


Top ↑

Return

(string) Row actions output for media attachments, or an empty string if the current column is not the primary column.


Top ↑

Source

File: wp-admin/includes/class-wp-media-list-table.php

	protected function handle_row_actions( $item, $column_name, $primary ) {
		if ( $primary !== $column_name ) {
			return '';
		}

		$att_title = _draft_or_post_title();
		$actions   = $this->_get_row_actions(
			$item, // WP_Post object for an attachment.
			$att_title
		);

		return $this->row_actions( $actions );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Renamed $post to $item to match parent class for PHP 8 named parameter support.
4.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.