WP_Block::__construct()
Constructor.
Populates object properties from the provided block instance argument.
The given array of context values will not necessarily be available on the instance itself, but is treated as the full set of values provided by the block's ancestry. This is assigned to the private available_context property. Only values which are configured to consumed by the block via its registered type will be assigned to the block's context property.
Method of the class: WP_Block{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$WP_Block = new WP_Block(); $WP_Block->__construct( $block, $available_context, $registry );
- $block(array) (required)
An associative array of a single parsed block object. See WP_Block_Parser_Block.
-
blockName(string)
Name of block. -
attrs(array)
Attributes from block comment delimiters. -
innerBlocks(array)
List of inner blocks. An array of arrays that have the same structure as this one. -
innerHTML(string)
HTML from inside block comment delimiters. - innerContent(array)
List of string fragments and null markers where inner blocks were found.
-
- $available_context(array)
- Optional array of ancestry context values.
Default: array() - $registry(WP_Block_Type_Registry)
- Optional block type registry.
Default: null
Changelog
Since 5.5.0 | Introduced. |
WP_Block::__construct() WP Block:: construct code WP 6.8.1
public function __construct( $block, $available_context = array(), $registry = null ) { $this->parsed_block = $block; $this->name = $block['blockName']; if ( is_null( $registry ) ) { $registry = WP_Block_Type_Registry::get_instance(); } $this->registry = $registry; $this->block_type = $registry->get_registered( $this->name ); $this->available_context = $available_context; $this->refresh_context_dependents(); }