block_core_tabs_generate_tabs_list( array $innerblocks = array(), string $tabs_id = '' ): array
- Since
- 7.1.0
- Source
wp-includes/blocks/tabs.php:18
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
- Scaling
- Scales with input
- Instructions
- 6–19
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 47.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 6–19 | none |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 47 | 6–19 | 12 | |
| 8.5 | 47 | 6–19 | 12 | |
| 8.4 | 47 | 6–19 | 12 | |
| 8.3 | 47 | 6–19 | 12 | |
| 8.2 | 47 | 6–19 | 12 | |
| 8.1 | 47 | 6–19 | 12 | 3 fewer instructions than PHP 7.4 |
| 7.4 | 50 | 6–19 | 12 |
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
- esc_attr()Escaping for HTML attributes.
Used by · 1
- block_core_tabs_provide_context()Filter to provide tabs list context to core/tabs and core/tab-list blocks.
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.