wppaste
WordPress

WP_Comments_List_Table::handle_row_actions( WP_Comment $item, string $column_name, string $primary ): string

Since
4.3.0, 5.9.0
Source
wp-admin/includes/class-wp-comments-list-table.php:690
Generates and displays row actions 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_Comment
The comment object.
$column_namestring
Current column name.
$primarystring
Primary column name.

Return value

string
Row actions output for comments. An empty string if the current column is not the primary column, or if the current user cannot edit the comment.

Performance profile

How much work a call to WP_Comments_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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
197–261

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

Plugin surface
1 hook

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

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, cache, serialize, query 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 · 4 distinct outcomes

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

WhenInstructionsCalls it makes
$primary === false && $the_comment_status !== "trash"197–204wp_get_comment_status(), wp_create_nonce(), esc_html(), wp_create_nonce(), esc_html(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), array_filter(), apply_filters(), get_user_setting(), __()
$primary === false && $the_comment_status !== "trash"201–206wp_get_comment_status(), wp_create_nonce(), esc_html(), wp_create_nonce(), esc_html(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), _x(), array_filter(), apply_filters(), get_user_setting(), __()
$primary === false && $the_comment_status !== "trash"254–259wp_get_comment_status(), wp_create_nonce(), esc_html(), wp_create_nonce(), esc_html(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), esc_attr__(), __(), esc_attr__(), __(), sprintf(), esc_attr__(), __(), sprintf(), array_filter(), apply_filters(), get_user_setting(), __()
$primary === false && $the_comment_status !== "trash"258–261wp_get_comment_status(), wp_create_nonce(), esc_html(), wp_create_nonce(), esc_html(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), sprintf(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), __(), esc_url(), esc_attr__(), _x(), esc_attr__(), __(), esc_attr__(), __(), sprintf(), esc_attr__(), __(), sprintf(), array_filter(), apply_filters(), get_user_setting(), __()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev470197–26130
8.5470197–26130
8.4470197–2613019 more instructions than PHP 8.3
8.3451191–25430
8.2451191–25430
8.1451191–25430
7.4451191–25430

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_Comments_List_Table::handle_row_actions() runs, in this order:

  1. apply_filters( comment_row_actions )filterline 860 (+170 into the body)

    Filters the action links displayed for each comment in the Comments list table.

Uses · 11

  • wp_get_comment_status()Retrieves the status of a comment by comment ID.
  • esc_html()Escaping for HTML blocks.
  • wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
  • esc_url()Checks and cleans a URL.
  • esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
  • __()Retrieves the translation of $text.
  • _x()Retrieves translated string with gettext context.
  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • get_user_setting()Retrieves user interface setting value based on setting name.
  • wp_doing_ajax()Determines whether the current request is a WordPress Ajax request.
  • get_comment_meta()Retrieves comment meta field for a comment.

Source code

	protected function handle_row_actions( $item, $column_name, $primary ) {		global $comment_status; 		if ( $primary !== $column_name ) {			return '';		} 		if ( ! $this->user_can ) {			return '';		} 		// Restores the more descriptive, specific name for use within this method.		$comment = $item; 		$the_comment_status = wp_get_comment_status( $comment ); 		$output = ''; 		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) );		$del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) ); 		$action_string = 'comment.php?action=%s&c=' . $comment->comment_ID . '&%s'; 		$approve_url   = sprintf( $action_string, 'approvecomment', $approve_nonce );		$unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce );		$spam_url      = sprintf( $action_string, 'spamcomment', $del_nonce );		$unspam_url    = sprintf( $action_string, 'unspamcomment', $del_nonce );		$trash_url     = sprintf( $action_string, 'trashcomment', $del_nonce );		$untrash_url   = sprintf( $action_string, 'untrashcomment', $del_nonce );		$delete_url    = sprintf( $action_string, 'deletecomment', $del_nonce ); 		// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.		$actions = array(			'approve'   => '',			'unapprove' => '',			'reply'     => '',			'quickedit' => '',			'edit'      => '',			'spam'      => '',			'unspam'    => '',			'trash'     => '',			'untrash'   => '',			'delete'    => '',		); 		// Not looking at all comments.		if ( $comment_status && 'all' !== $comment_status ) {			if ( 'approved' === $the_comment_status ) {				$actions['unapprove'] = sprintf(					'<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>',					esc_url( $unapprove_url ),					"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=unapproved",					esc_attr__( 'Unapprove this comment' ),					__( 'Unapprove' )				);			} elseif ( 'unapproved' === $the_comment_status ) {				$actions['approve'] = sprintf(					'<a href="%s" data-wp-lists="%s" class="vim-a vim-destructive aria-button-if-js" aria-label="%s">%s</a>',					esc_url( $approve_url ),					"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=approved",					esc_attr__( 'Approve this comment' ),					__( 'Approve' )				);			}		} else {			$actions['approve'] = sprintf(				'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',				esc_url( $approve_url ),				"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",				esc_attr__( 'Approve this comment' ),				__( 'Approve' )			); 			$actions['unapprove'] = sprintf(				'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',				esc_url( $unapprove_url ),				"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",				esc_attr__( 'Unapprove this comment' ),				__( 'Unapprove' )			);

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 $comment 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-comments-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.