[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Block Bindings API: WP_Block_Bindings_Source class. 4 * 5 * 6 * @package WordPress 7 * @subpackage Block Bindings 8 * @since 6.5.0 9 */ 10 11 /** 12 * Class representing block bindings source. 13 * 14 * This class is designed for internal use by the Block Bindings registry. 15 * 16 * @since 6.5.0 17 * @access private 18 * 19 * @see WP_Block_Bindings_Registry 20 */ 21 final class WP_Block_Bindings_Source { 22 23 /** 24 * The name of the source. 25 * 26 * @since 6.5.0 27 * @var string 28 */ 29 public $name; 30 31 /** 32 * The label of the source. 33 * 34 * @since 6.5.0 35 * @var string 36 */ 37 public $label; 38 39 40 /** 41 * The function used to get the value from the source. 42 * 43 * @since 6.5.0 44 * @var callable 45 */ 46 private $get_value_callback; 47 48 /** 49 * The context added to the blocks needed by the source. 50 * 51 * @since 6.5.0 52 * @var array|null 53 */ 54 public $uses_context = null; 55 56 /** 57 * Constructor. 58 * 59 * Do not use this constructor directly. Instead, use the 60 * `WP_Block_Bindings_Registry::register` method or the `register_block_bindings_source` function. 61 * 62 * @since 6.5.0 63 * 64 * @param string $name The name of the source. 65 * @param array $source_properties The properties of the source. 66 */ 67 public function __construct( string $name, array $source_properties ) { 68 $this->name = $name; 69 foreach ( $source_properties as $property_name => $property_value ) { 70 $this->$property_name = $property_value; 71 } 72 } 73 74 /** 75 * Retrieves the value from the source. 76 * 77 * @since 6.5.0 78 * 79 * @param array $source_args Array containing source arguments used to look up the override value, i.e. {"key": "foo"}. 80 * @param WP_Block $block_instance The block instance. 81 * @param string $attribute_name The name of the target attribute. 82 * 83 * @return mixed The value of the source. 84 */ 85 public function get_value( array $source_args, $block_instance, string $attribute_name ) { 86 return call_user_func_array( $this->get_value_callback, array( $source_args, $block_instance, $attribute_name ) ); 87 } 88 89 /** 90 * Wakeup magic method. 91 * 92 * @since 6.5.0 93 */ 94 public function __wakeup() { 95 throw new \LogicException( __CLASS__ . ' should never be unserialized' ); 96 } 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 2 08:20:01 2024 | Cross-referenced by PHPXref |