Make WordPress Core


Ignore:
Timestamp:
02/02/2024 08:22:11 PM (12 months ago)
Author:
gziolo
Message:

Editor: Refactor the way block bindings sources are handled

It fixes the coding style issues reported. It goes further and improves the code quality it other places where the logic for block bindings was added.

Follow-up for [57514].
Props: gziolo, mukesh27, youknowriad, santosguillamot.
See #60282.

File:
1 edited

Legend:

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

    r57514 r57526  
    2020 * @since 6.5.0
    2121 *
    22  * @param string   $source_name       The name of the source. It must be a string containing a namespace prefix, i.e.
    23  *                                    `my-plugin/my-custom-source`. It must only contain lowercase alphanumeric
    24  *                                    characters, the forward slash `/` and dashes.
    25  * @param array    $source_properties {
     22 * @param string $source_name       The name of the source. It must be a string containing a namespace prefix, i.e.
     23 *                                  `my-plugin/my-custom-source`. It must only contain lowercase alphanumeric
     24 *                                  characters, the forward slash `/` and dashes.
     25 * @param array  $source_properties {
    2626 *     The array of arguments that are used to register a source.
    2727 *
     
    4141 * @return array|false Source when the registration was successful, or `false` on failure.
    4242 */
    43 function register_block_bindings_source( $source_name, array $source_properties ) {
     43function register_block_bindings_source( string $source_name, array $source_properties ) {
    4444    return WP_Block_Bindings_Registry::get_instance()->register( $source_name, $source_properties );
    4545}
     
    5353 * @return array|false The unregistered block bindings source on success and `false` otherwise.
    5454 */
    55 function unregister_block_bindings_source( $source_name ) {
     55function unregister_block_bindings_source( string $source_name ) {
    5656    return WP_Block_Bindings_Registry::get_instance()->unregister( $source_name );
    5757}
     
    6767    return WP_Block_Bindings_Registry::get_instance()->get_all_registered();
    6868}
     69
     70/**
     71 * Retrieves a registered block bindings source.
     72 *
     73 * @since 6.5.0
     74 *
     75 * @param string $source_name The name of the source.
     76 * @return array|null The registered block bindings source, or `null` if it is not registered.
     77 */
     78function get_block_bindings_source( string $source_name ) {
     79    return WP_Block_Bindings_Registry::get_instance()->get_registered( $source_name );
     80}
Note: See TracChangeset for help on using the changeset viewer.