WP_Block::refresh_context_dependents()
Updates the context for the current block and its inner blocks.
The method updates the context of inner blocks, if any, by passing down any context values the block provides (provides_context).
If the block has inner blocks, the method recursively processes them by creating new instances of WP_Block for each inner block and updating their context based on the block's provides_context property.
Method of the class: WP_Block{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$WP_Block = new WP_Block(); $WP_Block->refresh_context_dependents();
Changelog
Since 6.8.0 | Introduced. |
WP_Block::refresh_context_dependents() WP Block::refresh context dependents code WP 6.8.1
public function refresh_context_dependents() { /* * Merging the `$context` property here is not ideal, but for now needs to happen because of backward compatibility. * Ideally, the `$context` property itself would not be filterable directly and only the `$available_context` would be filterable. * However, this needs to be separately explored whether it's possible without breakage. */ $this->available_context = array_merge( $this->available_context, $this->context ); if ( ! empty( $this->block_type->uses_context ) ) { foreach ( $this->block_type->uses_context as $context_name ) { if ( array_key_exists( $context_name, $this->available_context ) ) { $this->context[ $context_name ] = $this->available_context[ $context_name ]; } } } $this->refresh_parsed_block_dependents(); }