[ 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 * The function used to get the value from the source. 41 * 42 * @since 6.5.0 43 * @var callable 44 */ 45 private $get_value_callback; 46 47 /** 48 * The context added to the blocks needed by the source. 49 * 50 * @since 6.5.0 51 * @var string[]|null 52 */ 53 public $uses_context = null; 54 55 /** 56 * Constructor. 57 * 58 * Do not use this constructor directly. Instead, use the 59 * `WP_Block_Bindings_Registry::register` method or the `register_block_bindings_source` function. 60 * 61 * @since 6.5.0 62 * 63 * @param string $name The name of the source. 64 * @param array $source_properties The properties of the source. 65 */ 66 public function __construct( string $name, array $source_properties ) { 67 $this->name = $name; 68 foreach ( $source_properties as $property_name => $property_value ) { 69 $this->$property_name = $property_value; 70 } 71 } 72 73 /** 74 * Retrieves the value from the source. 75 * 76 * @since 6.5.0 77 * 78 * @param array $source_args Array containing source arguments used to look up the override value, i.e. {"key": "foo"}. 79 * @param WP_Block $block_instance The block instance. 80 * @param string $attribute_name The name of the target attribute. 81 * 82 * @return mixed The value of the source. 83 */ 84 public function get_value( array $source_args, $block_instance, string $attribute_name ) { 85 return call_user_func_array( $this->get_value_callback, array( $source_args, $block_instance, $attribute_name ) ); 86 } 87 88 /** 89 * Wakeup magic method. 90 * 91 * @since 6.5.0 92 */ 93 public function __wakeup() { 94 throw new \LogicException( __CLASS__ . ' should never be unserialized' ); 95 } 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |