Make WordPress Core

Changeset 57375

Timestamp:
01/29/2024 01:06:09 PM (6 months ago)
Author:
gziolo
Message:

Editor: Add Block Bindings API helpers

It is part of the sync from the Gutenberg plugin that introduces the registry for block binding sources required for the new Block Bindings API: WordPress/gutenberg#54536.

See #60282.
Follow-up [57373].
Props czapla, artemiosans, santosguillamot, sc0ttkclark, lgladdy, talldanwp, swissspidy, youknowriad, fabiankaegy, mukesh27.

Location:
trunk
Files:
2 added
3 edited

Legend:

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

    r57373 r57375  
    1111
    1212/**
    13  * Core class used for interacting with block binding sources.
     13 * Core class used for interacting with block binding sources.
    1414 *
    1515 *  @since 6.5.0
     
    2121     *
    2222     * @since 6.5.0
    23      *
    2423     * @var array
    2524     */
     
    3534
    3635    /**
    37      * Registers a new block binding source.
     36     * Registers a new block binding source.
    3837     *
    3938     * Sources are used to override block's original attributes with a value
     
    6766            _doing_it_wrong(
    6867                __METHOD__,
    69                 __( 'Block binding source name must be a string.' ),
     68                __( 'Block binding source name must be a string.' ),
    7069                '6.5.0'
    7170            );
     
    7675            _doing_it_wrong(
    7776                __METHOD__,
    78                 __( 'Block binding source names must not contain uppercase characters.' ),
     77                __( 'Block binding source names must not contain uppercase characters.' ),
    7978                '6.5.0'
    8079            );
     
    8685            _doing_it_wrong(
    8786                __METHOD__,
    88                 __( 'Block binding source names must contain a namespace prefix. Example: my-plugin/my-custom-source' ),
     87                __( 'Block binding source names must contain a namespace prefix. Example: my-plugin/my-custom-source' ),
    8988                '6.5.0'
    9089            );
     
    9594            _doing_it_wrong(
    9695                __METHOD__,
    97                 /* translators: %s: Block binding source name. */
    98                 sprintf( __( 'Block binding source "%s" already registered.' ), $source_name ),
     96                /* translators: %s: Block binding source name. */
     97                sprintf( __( 'Block binding source "%s" already registered.' ), $source_name ),
    9998                '6.5.0'
    10099            );
     
    113112
    114113    /**
    115      * Unregisters a block binding source.
     114     * Unregisters a block binding source.
    116115     *
    117116     * @since 6.5.0
    118117     *
    119      * @param string $source_name Block binding source name including namespace.
    120      * @return array|false The unregistred block binding source on success and `false` otherwise.
     118     * @param string $source_name Block binding source name including namespace.
     119     * @return array|false The unregistred block binding source on success and `false` otherwise.
    121120     */
    122121    public function unregister( $source_name ) {
     
    124123            _doing_it_wrong(
    125124                __METHOD__,
    126                 /* translators: %s: Block binding source name. */
     125                /* translators: %s: Block binding source name. */
    127126                sprintf( __( 'Block binding "%s" not found.' ), $source_name ),
    128127                '6.5.0'
     
    154153     *
    155154     * @param string $source_name The name of the source.
    156      * @return array|null The registered block binding source, or `null` if it is not registered.
     155     * @return array|null The registered block binding source, or `null` if it is not registered.
    157156     */
    158157    public function get_registered( $source_name ) {
     
    165164
    166165    /**
    167      * Checks if a block binding source is registered.
     166     * Checks if a block binding source is registered.
    168167     *
    169168     * @since 6.5.0
    170169     *
    171170     * @param string $source_name The name of the source.
    172      * @return bool `true` if the block binding source is registered, `false` otherwise.
     171     * @return bool `true` if the block binding source is registered, `false` otherwise.
    173172     */
    174173    public function is_registered( $source_name ) {
  • trunk/src/wp-settings.php

    r57373 r57375  
    330330require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-taxonomies.php';
    331331require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php';
     332
    332333require ABSPATH . WPINC . '/class-wp-block-editor-context.php';
    333 require ABSPATH . WPINC . '/class-wp-block-bindings-registry.php';
    334334require ABSPATH . WPINC . '/class-wp-block-type.php';
    335335require ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php';
     
    344344require ABSPATH . WPINC . '/class-wp-classic-to-block-menu-converter.php';
    345345require ABSPATH . WPINC . '/class-wp-navigation-fallback.php';
     346
    346347require ABSPATH . WPINC . '/blocks.php';
    347348require ABSPATH . WPINC . '/blocks/index.php';
  • trunk/tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php

    r57373 r57375  
    142142     * @ticket 60282
    143143     *
     144
    144145     * @covers WP_Block_Bindings_Registry::unregister
    145146     */
Note: See TracChangeset for help on using the changeset viewer.