wppaste
WordPress

WP_Terms_List_Table::handle_row_actions( WP_Term $item, string $column_name, string $primary ): string

Since
4.3.0, 5.9.0
Source
wp-admin/includes/class-wp-terms-list-table.php:465
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_Term
Tag being acted upon.
$column_namestring
Current column name.
$primarystring
Primary column name.

Return value

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

Performance profile

How much work a call to WP_Terms_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
Heavy

Reaches the database via get_term().

Scaling
Constant

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

Instructions
6–185

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

Plugin surface
3 hooks

Third-party callbacks on 'quick_edit_enabled_for_taxonomy', 'tag_row_actions', '{$taxonomy}_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
  • querycontent queryget_term()one call below WP_Terms_List_Table::handle_row_actions()

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

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

WhenInstructionsCalls it makes
$primary !== false6none
$primary === false && !wp_doing_ajax() && !current_user_can() && !is_term_publicly_viewable()50wp_doing_ajax(), current_user_can(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && !current_user_can() && !is_term_publicly_viewable()52wp_doing_ajax(), wp_get_referer(), current_user_can(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && !current_user_can() && is_term_publicly_viewable()76wp_doing_ajax(), current_user_can(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && !current_user_can() && is_term_publicly_viewable()78wp_doing_ajax(), wp_get_referer(), current_user_can(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && !is_term_publicly_viewable()84wp_doing_ajax(), current_user_can(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && !is_term_publicly_viewable()86wp_doing_ajax(), wp_get_referer(), current_user_can(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && !is_term_publicly_viewable()102wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && !is_term_publicly_viewable()104wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && is_term_publicly_viewable()110wp_doing_ajax(), current_user_can(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && is_term_publicly_viewable()112wp_doing_ajax(), wp_get_referer(), current_user_can(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && !is_term_publicly_viewable()123wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
13 further outcomes, up to 185 instructions
$primary === false && wp_doing_ajax() && !is_term_publicly_viewable()125wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && is_term_publicly_viewable()128wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && is_term_publicly_viewable()130wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && current_user_can() && !is_term_publicly_viewable()136wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && current_user_can() && !is_term_publicly_viewable()138wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && is_term_publicly_viewable()149wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && is_term_publicly_viewable()151wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && current_user_can() && !is_term_publicly_viewable()157wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && current_user_can() && !is_term_publicly_viewable()159wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && current_user_can() && is_term_publicly_viewable()162wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && current_user_can() && is_term_publicly_viewable()164wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && !wp_doing_ajax() && current_user_can() && is_term_publicly_viewable()183wp_doing_ajax(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()
$primary === false && wp_doing_ajax() && current_user_can() && is_term_publicly_viewable()185wp_doing_ajax(), wp_get_referer(), current_user_can(), wp_unslash(), urlencode(), get_edit_term_link(), add_query_arg(), esc_url(), __(), sprintf(), esc_attr(), __(), apply_filters(), __(), sprintf(), esc_attr(), __(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_attr(), __(), is_term_publicly_viewable(), get_term_link(), __(), sprintf(), esc_attr(), __(), apply_filters(), apply_filters(), ->row_actions()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1876–18461 fewer instruction than PHP 8.5
8.51886–1856
8.41886–18563 more instructions than PHP 8.3
8.31856–1826
8.21856–1826
8.11856–18261 fewer instruction than PHP 7.4
7.41866–1826

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 · 3

3 hooks fire while WP_Terms_List_Table::handle_row_actions() runs, in this order:

  1. apply_filters( quick_edit_enabled_for_taxonomy )filterline 501 (+36 into the body)

    Filters whether Quick Edit should be enabled for the given taxonomy.

  2. apply_filters( tag_row_actions )filterline 544 (+79 into the body)

    Filters the action links displayed for each term in the Tags list table.

  3. apply_filters( {$taxonomy}_row_actions )filterline 562 (+97 into the body)

    Filters the action links displayed for each term in the terms list table.

Uses · 14

Show all 14
  • get_term_link()Generates a permalink for a taxonomy term archive.
  • WP_Terms_List_Table::row_actions()

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.		$tag = $item; 		$taxonomy = $this->screen->taxonomy;		$uri      = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; 		$actions = array(); 		if ( current_user_can( 'edit_term', $tag->term_id ) ) {			$actions['edit'] = sprintf(				'<a href="%s" aria-label="%s">%s</a>',				esc_url(					add_query_arg(						'wp_http_referer',						urlencode( wp_unslash( $uri ) ),						get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )					)				),				/* translators: %s: Taxonomy term name. */				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),				__( 'Edit' )			); 			/**			 * Filters whether Quick Edit should be enabled for the given taxonomy.			 *			 * @since 6.4.0			 *			 * @param bool   $enable   Whether to enable the Quick Edit functionality. Default true.			 * @param string $taxonomy Taxonomy name.			 */			$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy ); 			if ( $quick_edit_enabled ) {				$actions['inline hide-if-no-js'] = sprintf(					'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',					/* translators: %s: Taxonomy term name. */					esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),					__( 'Quick&nbsp;Edit' )				);			}		} 		if ( current_user_can( 'delete_term', $tag->term_id ) ) {			$actions['delete'] = sprintf(				'<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',				wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ),				/* translators: %s: Taxonomy term name. */				esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $tag->name ) ),				__( 'Delete' )			);		} 		if ( is_term_publicly_viewable( $tag ) ) {			$actions['view'] = sprintf(				'<a href="%s" aria-label="%s">%s</a>',				get_term_link( $tag ),				/* translators: %s: Taxonomy term name. */				esc_attr( sprintf( __( 'View &#8220;%s&#8221; archive' ), $tag->name ) ),				__( 'View' )			);		} 		/**		 * Filters the action links displayed for each term in the Tags list table.		 *		 * @since 2.8.0		 * @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter.		 * @since 5.4.2 Restored (un-deprecated).		 *		 * @param string[] $actions An array of action links to be displayed. Default		 *                          'Edit', 'Quick Edit', 'Delete', and 'View'.		 * @param WP_Term  $tag     Term object.		 */		$actions = apply_filters( 'tag_row_actions', $actions, $tag );

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 $tag 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 7.0.4 tag, from src/wp-admin/includes/class-wp-terms-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.