wppaste
WordPress

WP_MS_Users_List_Table::handle_row_actions( WP_User $item, string $column_name, string $primary ): string

Since
4.3.0, 5.9.0
Source
wp-admin/includes/class-wp-ms-users-list-table.php:524
Generates and displays row action links.

Compatibility

WordPress
since 5.9.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$itemWP_User
User being acted upon.
$column_namestring
Current column name.
$primarystring
Primary column name.

Return value

string
Row actions output for users in Multisite, or an empty string if the current column is not the primary column.

Performance profile

How much work a call to WP_MS_Users_List_Table::handle_row_actions() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Moderate

Reads stored settings via get_site_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
6–106

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 107.

Plugin surface
1 hook

Third-party callbacks on 'ms_user_row_actions' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionnetwork optionget_site_option()one call below WP_MS_Users_List_Table::handle_row_actions()

Further down the call graph this can also reach query, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 5 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_MS_Users_List_Table::handle_row_actions() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$primary !== false6none
$primary === false && !current_user_can()34–38get_super_admins(), current_user_can(), current_user_can(), apply_filters(), ->row_actions()
$primary === false && current_user_can()66–70get_super_admins(), current_user_can(), wp_unslash(), urlencode(), get_edit_user_link(), add_query_arg(), esc_url(), __(), current_user_can(), apply_filters(), ->row_actions()
$primary === false && !$super_admins74get_super_admins(), current_user_can(), current_user_can(), wp_unslash(), urlencode(), wp_nonce_url(), add_query_arg(), network_admin_url(), esc_url(), __(), apply_filters(), ->row_actions()
$primary === false && current_user_can() && !$super_admins106get_super_admins(), current_user_can(), wp_unslash(), urlencode(), get_edit_user_link(), add_query_arg(), esc_url(), __(), current_user_can(), wp_unslash(), urlencode(), wp_nonce_url(), add_query_arg(), network_admin_url(), esc_url(), __(), apply_filters(), ->row_actions()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1076–1064
8.51076–1064
8.41076–10643 fewer instructions than PHP 8.3
8.31106–1094
8.21106–1094
8.11106–1094
7.41106–1094

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while WP_MS_Users_List_Table::handle_row_actions() runs, in this order:

  1. apply_filters( ms_user_row_actions )filterline 552 (+28 into the body)

    Filters the action links displayed under each user in the Network Admin Users list table.

Uses · 11

Used by · 1

Source code

	protected function handle_row_actions( $item, $column_name, $primary ) {		if ( $primary !== $column_name ) {			return '';		} 		// Restores the more descriptive, specific name for use within this method.		$user = $item; 		$super_admins = get_super_admins();		$actions      = array(); 		if ( current_user_can( 'edit_user', $user->ID ) ) {			$edit_link       = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );			$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';		} 		if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins, true ) ) {			$actions['delete'] = '<a href="' . esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';		} 		/**		 * Filters the action links displayed under each user in the Network Admin Users list table.		 *		 * @since 3.2.0		 *		 * @param string[] $actions An array of action links to be displayed. Default 'Edit', 'Delete'.		 * @param WP_User  $user    WP_User object.		 */		$actions = apply_filters( 'ms_user_row_actions', $actions, $user ); 		return $this->row_actions( $actions );	}

Changelog

Introduced in 4.3.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.9.0
Renamed $user to $item to match parent class for PHP 8 named parameter support.from the docblock
4.3.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/class-wp-ms-users-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.