Title: WP_Block_Bindings_Source
Published: April 3, 2024
Last modified: April 28, 2025

---

# class WP_Block_Bindings_Source {}

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#see-also)
 * [Methods](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#methods)
 * [Source](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#wp--skip-link--target)

This class’s access is marked private. This means it is not intended for use by 
plugin or theme developers, only by core. It is listed here for completeness.

Class representing block bindings source.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#description)󠁿

This class is designed for internal use by the Block Bindings registry.

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#see-also)󠁿

 * [WP_Block_Bindings_Registry](https://developer.wordpress.org/reference/classes/wp_block_bindings_registry/)

## 󠀁[Methods](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#methods)󠁿

| Name | Description | 
| [WP_Block_Bindings_Source::__construct](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/__construct/) | Constructor. | 
| [WP_Block_Bindings_Source::__wakeup](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/__wakeup/) | Wakeup magic method. | 
| [WP_Block_Bindings_Source::get_value](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/get_value/) | Calls the callback function specified in the `$get_value_callback` property with the given arguments and returns the result. It can be modified with `block_bindings_source_value` filter. |

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#source)󠁿

    ```php
    final class WP_Block_Bindings_Source {

    	/**
    	 * The name of the source.
    	 *
    	 * @since 6.5.0
    	 * @var string
    	 */
    	public $name;

    	/**
    	 * The label of the source.
    	 *
    	 * @since 6.5.0
    	 * @var string
    	 */
    	public $label;

    	/**
    	 * The function used to get the value from the source.
    	 *
    	 * @since 6.5.0
    	 * @var callable
    	 */
    	private $get_value_callback;

    	/**
    	 * The context added to the blocks needed by the source.
    	 *
    	 * @since 6.5.0
    	 * @var string[]|null
    	 */
    	public $uses_context = null;

    	/**
    	 * Constructor.
    	 *
    	 * Do not use this constructor directly. Instead, use the
    	 * `WP_Block_Bindings_Registry::register` method or the `register_block_bindings_source` function.
    	 *
    	 * @since 6.5.0
    	 *
    	 * @param string $name              The name of the source.
    	 * @param array  $source_properties The properties of the source.
    	 */
    	public function __construct( string $name, array $source_properties ) {
    		$this->name = $name;
    		foreach ( $source_properties as $property_name => $property_value ) {
    			$this->$property_name = $property_value;
    		}
    	}

    	/**
    	 * Calls the callback function specified in the `$get_value_callback` property
    	 * with the given arguments and returns the result. It can be modified with
    	 * `block_bindings_source_value` filter.
    	 *
    	 * @since 6.5.0
    	 * @since 6.7.0 `block_bindings_source_value` filter was added.
    	 *
    	 * @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.
    	 * @return mixed The value of the source.
    	 */
    	public function get_value( array $source_args, $block_instance, string $attribute_name ) {
    		$value = call_user_func_array( $this->get_value_callback, array( $source_args, $block_instance, $attribute_name ) );
    		/**
    		 * Filters the output of a block bindings source.
    		 *
    		 * @since 6.7.0
    		 *
    		 * @param mixed    $value          The computed value for the source.
    		 * @param string   $name           The name of the source.
    		 * @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 an attribute.
    		 */
    		return apply_filters( 'block_bindings_source_value', $value, $this->name, $source_args, $block_instance, $attribute_name );
    	}

    	/**
    	 * Wakeup magic method.
    	 *
    	 * @since 6.5.0
    	 */
    	public function __wakeup() {
    		throw new \LogicException( __CLASS__ . ' should never be unserialized' );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-block-bindings-source.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-block-bindings-source.php#L20)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-block-bindings-source.php#L20-L109)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_block_bindings_source/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_block_bindings_source%2F)
before being able to contribute a note or feedback.