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

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

Parameters

$actionsstring[]required
An array of action links.
$always_visiblebooloptional
Whether the actions should be always visible.

Default:false

Return

string The HTML for the row actions.

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.

Source

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;
	}

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

	$i = 0;

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

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

		$output .= "<span class='$action'>{$link}{$separator}</span>";
	}

	$output .= '</div>';

	$output .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' .
		/* translators: Hidden accessibility text. */
		__( 'Show more details' ) .
	'</span></button>';

	return $output;
}

Changelog

VersionDescription
3.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.