wppaste
WordPress

block_core_tabs_generate_tabs_list( array $innerblocks = array(), string $tabs_id = '' ): array

Since
7.1.0
Source
wp-includes/blocks/tabs.php:18
Extract tabs list from tab-panel innerblocks.

Compatibility

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

Present in 1 of the 5 tracked releases, added in 7.1.0, and compiles on PHP 7.4 through 8.6-dev.

Parameters

$innerblocksarrayoptional
Parsed inner blocks of tabs block.Default: array()
$tabs_idstringoptional
Unique ID for the tabs instance, used to generate tab IDs.Default: ''

Return value

array
List of tab IDs.

Performance profile

How much work a call to block_core_tabs_generate_tabs_list() 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
6–19

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

Plugin surface
None

Nothing here hands control to plugin code.

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()one call below block_core_tabs_generate_tabs_list()

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

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

WhenInstructionsCalls it makes
always6–19none

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev476–1912
8.5476–1912
8.4476–1912
8.3476–1912
8.2476–1912
8.1476–19123 fewer instructions than PHP 7.4
7.4506–1912

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

Used by · 1

Source code

function block_core_tabs_generate_tabs_list( array $innerblocks = array(), string $tabs_id = '' ): array {	$tabs_list = array(); 	// Find tab-panel block	foreach ( $innerblocks as $inner_block ) {		if ( 'core/tab-panels' === ( $inner_block['blockName'] ?? '' ) ) {			$tab_index = 0;			foreach ( $inner_block['innerBlocks'] ?? array() as $tab_block ) {				if ( 'core/tab-panel' === ( $tab_block['blockName'] ?? '' ) ) {					$attrs = $tab_block['attrs'] ?? array(); 					$tab_id = ! empty( $attrs['anchor'] )						? $attrs['anchor']						: ( ! empty( $tabs_id )							? $tabs_id . '-tab-' . $tab_index							: 'tab-' . $tab_index ); 					$tabs_list[] = esc_attr( $tab_id );					++$tab_index;				}			}			break;		}	} 	return $tabs_list;}

Changelog

Introduced in 7.1.0.

Signature, return type and hooks compared across 1 parsed release.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/blocks/tabs.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.