| | 143 | $this->refresh_context_dependents(); |
| | 144 | } |
| | 145 | |
| | 146 | /** |
| | 147 | * Updates the context for the current block and its inner blocks. |
| | 148 | * |
| | 149 | * The method updates the context of inner blocks, if any, by passing down |
| | 150 | * any context values the block provides (`provides_context`). |
| | 151 | * |
| | 152 | * If the block has inner blocks, the method recursively processes them by creating new instances of `WP_Block` |
| | 153 | * for each inner block and updating their context based on the block's `provides_context` property. |
| | 154 | * |
| | 155 | * @since 6.8.0 |
| | 156 | */ |
| | 157 | public function refresh_context_dependents() { |
| | 158 | /* |
| | 159 | * Merging the `$context` property here is not ideal, but for now needs to happen because of backward compatibility. |
| | 160 | * Ideally, the `$context` property itself would not be filterable directly and only the `$available_context` would be filterable. |
| | 161 | * However, this needs to be separately explored whether it's possible without breakage. |
| | 162 | */ |
| | 163 | $this->available_context = array_merge( $this->available_context, $this->context ); |
| | 164 | |
| 151 | | if ( ! empty( $block['innerBlocks'] ) ) { |
| | 173 | $this->refresh_parsed_block_dependents(); |
| | 174 | } |
| | 175 | |
| | 176 | /** |
| | 177 | * Updates the parsed block content for the current block and its inner blocks. |
| | 178 | * |
| | 179 | * This method sets the `inner_html` and `inner_content` properties of the block based on the parsed |
| | 180 | * block content provided during initialization. It ensures that the block instance reflects the |
| | 181 | * most up-to-date content for both the inner HTML and any string fragments around inner blocks. |
| | 182 | * |
| | 183 | * If the block has inner blocks, this method initializes a new `WP_Block_List` for them, ensuring the |
| | 184 | * correct content and context are updated for each nested block. |
| | 185 | * |
| | 186 | * @since 6.8.0 |
| | 187 | */ |
| | 188 | public function refresh_parsed_block_dependents() { |
| | 189 | if ( ! empty( $this->parsed_block['innerBlocks'] ) ) { |
| 162 | | $this->inner_blocks = new WP_Block_List( $block['innerBlocks'], $child_context, $registry ); |
| 163 | | } |
| 164 | | |
| 165 | | if ( ! empty( $block['innerHTML'] ) ) { |
| 166 | | $this->inner_html = $block['innerHTML']; |
| 167 | | } |
| 168 | | |
| 169 | | if ( ! empty( $block['innerContent'] ) ) { |
| 170 | | $this->inner_content = $block['innerContent']; |
| | 200 | $this->inner_blocks = new WP_Block_List( $this->parsed_block['innerBlocks'], $child_context, $this->registry ); |
| | 201 | } |
| | 202 | |
| | 203 | if ( ! empty( $this->parsed_block['innerHTML'] ) ) { |
| | 204 | $this->inner_html = $this->parsed_block['innerHTML']; |
| | 205 | } |
| | 206 | |
| | 207 | if ( ! empty( $this->parsed_block['innerContent'] ) ) { |
| | 208 | $this->inner_content = $this->parsed_block['innerContent']; |