wppaste
WordPress

WP_Terms_List_Table::_rows( string $taxonomy, array $terms, array $children, int $start, int $per_page, int $count, int $parent_term = 0, int $level = 0 )

Source
wp-admin/includes/class-wp-terms-list-table.php:274

Compatibility

WordPress
core
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

$taxonomystring
$termsarray
$childrenarray
$startint
$per_pageint
$countint
$parent_termintoptional
Default: 0
$levelintoptional
Default: 0

Performance profile

How much work a call to WP_Terms_List_Table::_rows() 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
Scales with input

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

Instructions
12–16

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
2

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

What it touches

  • querycontent queryget_term()called directly
  • hookthird-party callbacksapply_filters()one call below WP_Terms_List_Table::_rows()

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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always12–16none

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev9312–1614
8.59312–1614
8.49312–16143 fewer instructions than PHP 8.3
8.39612–1614
8.29612–1614
8.19612–16141 fewer instruction than PHP 7.4
7.49712–1614

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.

Uses · 3

Used by · 2

Source code

	private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent_term = 0, $level = 0 ) { 		$end = $start + $per_page; 		foreach ( $terms as $key => $term ) { 			if ( $count >= $end ) {				break;			} 			if ( $term->parent !== $parent_term && empty( $_REQUEST['s'] ) ) {				continue;			} 			// If the page starts in a subtree, print the parents.			if ( $count === $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {				$my_parents = array();				$parent_ids = array();				$p          = $term->parent; 				while ( $p ) {					$my_parent    = get_term( $p, $taxonomy );					$my_parents[] = $my_parent;					$p            = $my_parent->parent; 					if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops.						break;					} 					$parent_ids[] = $p;				} 				unset( $parent_ids ); 				$num_parents = count( $my_parents ); 				while ( $my_parent = array_pop( $my_parents ) ) {					echo "\t";					$this->single_row( $my_parent, $level - $num_parents );					--$num_parents;				}			} 			if ( $count >= $start ) {				echo "\t";				$this->single_row( $term, $level );			} 			++$count; 			unset( $terms[ $key ] ); 			if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) {				$this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );			}		}	}

Changelog

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.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 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.