WP_List_Table::row_actions() WordPress Method

The WP_List_Table::row_actions() method is used to generate the HTML for the row action links on a list table. This method is called by the WP_List_Table::display_rows() method for each row in the list table. The row_actions() method accepts two arguments: an array of actions (which should be associative arrays with 'label' and 'url' keys), and a boolean value for whether to escape the labels. The method returns a string of HTML for the action links.

WP_List_Table::row_actions( string[] $actions, bool $always_visible = false ) #

Generates the required HTML for a list of row action links.


Parameters

$actions

(string[])(Required)An array of action links.

$always_visible

(bool)(Optional)Whether the actions should be always visible.

Default value: false


Top ↑

Return

(string) The HTML for the row actions.


Top ↑

More Information

Call this method (usually from one of your column methods) to insert a row actions div. The $actions parameter should be an associative array, where the key is the name of the action and the value is a link.


Top ↑

Source

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

	protected function row_actions( $actions, $always_visible = false ) {
		$action_count = count( $actions );

		if ( ! $action_count ) {
			return '';
		}

		$mode = get_user_setting( 'posts_list_mode', 'list' );

		if ( 'excerpt' === $mode ) {
			$always_visible = true;
		}

		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';

		$i = 0;

		foreach ( $actions as $action => $link ) {
			++$i;

			$sep = ( $i < $action_count ) ? ' | ' : '';

			$out .= "<span class='$action'>$link$sep</span>";
		}

		$out .= '</div>';

		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';

		return $out;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.1.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.