Make WordPress Core


Ignore:
Timestamp:
02/16/2024 12:53:16 PM (3 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/block-bindings.php

    r57562 r57641  
    7676 *     The array of arguments that are used to register a source.
    7777 *
    78  *     @type string   $label              The label of the source.
    79  *     @type callback $get_value_callback A callback executed when the source is processed during block rendering.
    80  *                                        The callback should have the following signature:
     78 *     @type string   $label                   The label of the source.
     79 *     @type callback $get_value_callback      A callback executed when the source is processed during block rendering.
     80 *                                             The callback should have the following signature:
    8181 *
    82  *                                        `function ($source_args, $block_instance,$attribute_name): mixed`
    83  *                                            - @param array    $source_args    Array containing source arguments
    84  *                                                                              used to look up the override value,
    85  *                                                                              i.e. {"key": "foo"}.
    86  *                                            - @param WP_Block $block_instance The block instance.
    87  *                                            - @param string   $attribute_name The name of an attribute .
    88  *                                        The callback has a mixed return type; it may return a string to override
    89  *                                        the block's original value, null, false to remove an attribute, etc.
     82 *                                             `function ($source_args, $block_instance,$attribute_name): mixed`
     83 *                                                 - @param array    $source_args    Array containing source arguments
     84 *                                                                                   used to look up the override value,
     85 *                                                                                   i.e. {"key": "foo"}.
     86 *                                                 - @param WP_Block $block_instance The block instance.
     87 *                                                 - @param string   $attribute_name The name of an attribute .
     88 *                                             The callback has a mixed return type; it may return a string to override
     89 *                                             the block's original value, null, false to remove an attribute, etc.
     90 *     @type array    $uses_context (optional) Array of values to add to block `uses_context` needed by the source.
    9091 * }
    9192 * @return WP_Block_Bindings_Source|false Source when the registration was successful, or `false` on failure.
Note: See TracChangeset for help on using the changeset viewer.