Make WordPress Core


Ignore:
Timestamp:
02/16/2024 12:53:16 PM (13 months ago)
Author:
gziolo
Message:

Editor: Merge uses_context defined by block bindings sources with block types

Adds logic that fixes the limitation for souces by allowing merging the uses_context defined by block bindings sources into supported block types. Each source defines the context it needs and it is added to the block types that are using the block bindings API.

Fixes #60525.
Props santosguillamot, gziolo, czapla, thekt12.

File:
1 edited

Legend:

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

    r57562 r57641  
    4747
    4848    /**
     49     * The context added to the blocks needed by the source.
     50     *
     51     * @since 6.5.0
     52     * @var array|null
     53     */
     54    public $uses_context = null;
     55
     56    /**
    4957     * Constructor.
    5058     *
     
    5866     */
    5967    public function __construct( string $name, array $source_properties ) {
    60         $this->name               = $name;
    61         $this->label              = $source_properties['label'];
    62         $this->get_value_callback = $source_properties['get_value_callback'];
     68        $this->name = $name;
     69        foreach ( $source_properties as $property_name => $property_value ) {
     70            $this->$property_name = $property_value;
     71        }
    6372    }
    6473
Note: See TracChangeset for help on using the changeset viewer.