wppaste
WordPress

get_block_bindings_supported_attributes( string $block_type ): array

Since
6.9.0, 7.1.0
Source
wp-includes/block-bindings.php:142
Retrieves the list of block attributes supported by block bindings.

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 3 of the 5 tracked releases, added in 7.1.0, and compiles on PHP 7.4 through 8.6-dev.

Parameters

$block_typestring
The block type whose supported attributes are being retrieved.

Return value

array
The list of block attributes that are supported by block bindings.

Performance profile

How much work a call to get_block_bindings_supported_attributes() 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
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
18–21

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

Plugin surface
2 hooks

Third-party callbacks on 'block_bindings_supported_attributes', 'block_bindings_supported_attributes_{$block_type}' run inside this call, and their cost is not bounded by anything here.

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()called directly

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 get_block_bindings_supported_attributes() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always18–21apply_filters(), apply_filters()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev2218–212
8.52218–212
8.42218–212
8.32218–212
8.22218–212
8.12218–2121 fewer instruction than PHP 7.4
7.42318–222

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

2 hooks fire while get_block_bindings_supported_attributes() runs, in this order:

  1. apply_filters( block_bindings_supported_attributes )filterline 167 (+25 into the body)

    Filters the supported block attributes for block bindings.

  2. apply_filters( block_bindings_supported_attributes_{$block_type} )filterline 183 (+41 into the body)

    Filters the supported block attributes for block bindings.

Uses · 1

  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 1

Source code

function get_block_bindings_supported_attributes( $block_type ) {	$block_bindings_supported_attributes = array(		'core/paragraph'          => array( 'content' ),		'core/heading'            => array( 'content' ),		'core/list-item'          => array( 'content' ),		'core/image'              => array( 'id', 'url', 'title', 'alt', 'caption' ),		'core/button'             => array( 'url', 'text', 'linkTarget', 'rel' ),		'core/post-date'          => array( 'datetime' ),		'core/navigation-link'    => array( 'url' ),		'core/navigation-submenu' => array( 'url' ),	); 	$supported_block_attributes =		isset( $block_type, $block_bindings_supported_attributes[ $block_type ] ) ?			$block_bindings_supported_attributes[ $block_type ] :			array(); 	/**	 * Filters the supported block attributes for block bindings.	 *	 * @since 6.9.0	 *	 * @param string[] $supported_block_attributes The block's attributes that are supported by block bindings.	 * @param string   $block_type                 The block type whose attributes are being filtered.	 */	$supported_block_attributes = apply_filters(		'block_bindings_supported_attributes',		$supported_block_attributes,		$block_type	); 	/**	 * Filters the supported block attributes for block bindings.	 *	 * The dynamic portion of the hook name, `$block_type`, refers to the block type	 * whose attributes are being filtered.	 *	 * @since 6.9.0	 *	 * @param string[] $supported_block_attributes The block's attributes that are supported by block bindings.	 */	$supported_block_attributes = apply_filters(		"block_bindings_supported_attributes_{$block_type}",		$supported_block_attributes	); 	return $supported_block_attributes;}

Changelog

Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.

  1. 6.9.7
  2. 7.0.4
  3. 7.1.0

Signature, return type and hooks compared across 3 parsed releases.

7.1.0
Added support for the List Item block.from the docblock
6.9.0
Introduced.from the docblock

About this page

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