wppaste
WordPress

WP_Block_Bindings_Registry

Since
6.5.0
Source
wp-includes/class-wp-block-bindings-registry.php:17
Core class used for interacting with block bindings sources.

Compatibility

WordPress
since 6.5.0
  • 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).

Properties · 3

$sourcesWP_Block_Bindings_Source[]private
Holds the registered block bindings sources, keyed by source identifier.
$instanceWP_Block_Bindings_Registry|nullprivate static
Container for the main instance of the class.
$allowed_source_propertiesstring[]private
Supported source properties that can be passed to the registered source.

Methods · 7

Source code

final class WP_Block_Bindings_Registry { 	/**	 * Holds the registered block bindings sources, keyed by source identifier.	 *	 * @since 6.5.0	 * @var WP_Block_Bindings_Source[]	 */	private $sources = array(); 	/**	 * Container for the main instance of the class.	 *	 * @since 6.5.0	 * @var WP_Block_Bindings_Registry|null	 */	private static $instance = null; 	/**	 * Supported source properties that can be passed to the registered source.	 *	 * @since 6.5.0	 * @var string[]	 */	private $allowed_source_properties = array(		'label',		'get_value_callback',		'uses_context',	); 	/**	 * Registers a new block bindings source.	 *	 * This is a low-level method. For most use cases, it is recommended to use	 * the `register_block_bindings_source()` function instead.	 *	 * @see register_block_bindings_source()	 *	 * Sources are used to override block's original attributes with a value	 * coming from the source. Once a source is registered, it can be used by a	 * block by setting its `metadata.bindings` attribute to a value that refers	 * to the source.	 *	 * @since 6.5.0	 *	 * @param string $source_name       The name of the source. It must be a string containing a namespace prefix, i.e.	 *                                  `my-plugin/my-custom-source`. It must only contain lowercase alphanumeric	 *                                  characters, the forward slash `/` and dashes.	 * @param array  $source_properties {	 *     The array of arguments that are used to register a source.	 *	 *     @type string   $label              The label of the source.	 *     @type callable $get_value_callback A callback executed when the source is processed during block rendering.	 *                                        The callback should have the following signature:	 *	 *                                        `function( $source_args, $block_instance, $attribute_name ): mixed`	 *                                            - @param array    $source_args    Array containing source arguments	 *                                                                              used to look up the override value,	 *                                                                              i.e. {"key": "foo"}.	 *                                            - @param WP_Block $block_instance The block instance.	 *                                            - @param string   $attribute_name The name of the target attribute.	 *                                        The callback has a mixed return type; it may return a string to override	 *                                        the block's original value, null, false to remove an attribute, etc.	 *     @type string[] $uses_context       Optional. Array of values to add to block `uses_context` needed by the source.	 * }	 * @return WP_Block_Bindings_Source|false Source when the registration was successful, or `false` on failure.	 */	public function register( string $source_name, array $source_properties ) {		if ( ! is_string( $source_name ) ) {			_doing_it_wrong(				__METHOD__,				__( 'Block bindings source name must be a string.' ),				'6.5.0'			);			return false;		} 		if ( preg_match( '/[A-Z]+/', $source_name ) ) {			_doing_it_wrong(				__METHOD__,

Changelog

Introduced in 6.5.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.

About this page

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