Make WordPress Core


Ignore:
Timestamp:
09/23/2024 12:33:14 PM (10 months ago)
Author:
gziolo
Message:

Block Bindings: Adds context needed by sources during its processing

Extends block context during block bindings processing. This implies that the context is extended ONLY for the blocks where bindings are defined and only when rendered on the page.

Props santosguillamot, gziolo, artemiosans, cbravobernal.
Fixes #61642.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block.php

    r59009 r59080  
    300300            if ( null === $block_binding_source ) {
    301301                continue;
     302            }
     303
     304            // Adds the necessary context defined by the source.
     305            if ( ! empty( $block_binding_source->uses_context ) ) {
     306                foreach ( $block_binding_source->uses_context as $context_name ) {
     307                    if ( array_key_exists( $context_name, $this->available_context ) ) {
     308                        $this->context[ $context_name ] = $this->available_context[ $context_name ];
     309                    }
     310                }
    302311            }
    303312
Note: See TracChangeset for help on using the changeset viewer.