Make WordPress Core

Changeset 57514

Timestamp:
02/01/2024 12:52:54 PM (6 months ago)
Author:
youknowriad
Message:

Editor: Add the Block Bindings API.

This introduces the Block Bindings API for WordPress.

The API allows developers to connects block attributes to different sources. In this PR, two such sources are included: "post meta" and "pattern". Attributes connected to sources can have their HTML replaced by values coming from the source in a way defined by the binding.

Props czapla, lgladdy, gziolo, sc0ttkclark, swissspidy, artemiosans, kevin940726, fabiankaegy, santosguillamot, talldanwp, wildworks.
Fixes #60282.

Location:
trunk
Files:
5 added
6 edited

Legend:

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

    r57500 r57514  
    2020 * @since 6.5.0
    2121 *
    22  * @param string   $source_name       The name of the source.
     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.
    2325 * @param array    $source_properties {
    2426 *     The array of arguments that are used to register a source.
  • trunk/src/wp-includes/class-wp-block-bindings-registry.php

    r57500 r57514  
    4343     * @since 6.5.0
    4444     *
    45      * @param string   $source_name       The name of the source.
     45     * @param string   $source_name       The name of the source. It must be a string containing a namespace prefix, i.e.
     46     *                                    `my-plugin/my-custom-source`. It must only contain lowercase alphanumeric
     47     *                                    characters, the forward slash `/` and dashes.
    4648     * @param array    $source_properties {
    4749     *     The array of arguments that are used to register a source.
  • trunk/src/wp-includes/class-wp-block.php

    r57493 r57514  
    193193
    194194    /**
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
    ��384
     385
     386
     387
     388
     389
     390
     391
     392
    195393     * Generates the render output for the block.
    196394     *
     
    286484            }
    287485        }
     486
     487
     488
     489
    288490
    289491        /**
  • trunk/src/wp-settings.php

    r57503 r57514  
    377377require ABSPATH . WPINC . '/class-wp-script-modules.php';
    378378require ABSPATH . WPINC . '/script-modules.php';
     379
     380
    379381require ABSPATH . WPINC . '/interactivity-api.php';
    380382
  • trunk/tests/phpunit/includes/functions.php

    r56472 r57514  
    340340 */
    341341function _unhook_block_registration() {
     342
    342343    require __DIR__ . '/unregister-blocks-hooks.php';
    343344    remove_action( 'init', 'register_core_block_types_from_metadata' );
     
    345346    remove_action( 'init', 'register_block_core_widget_group' );
    346347    remove_action( 'init', 'register_core_block_types_from_metadata' );
     348
     349
     350
     351
    347352}
    348353tests_add_filter( 'init', '_unhook_block_registration', 1000 );
  • trunk/tests/phpunit/tests/block-bindings/register.php

    r57385 r57514  
    1818
    1919    /**
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
    2033     * Tear down after each test.
    2134     *
     
    2437    public function tear_down() {
    2538        foreach ( get_all_registered_block_bindings_sources() as $source_name => $source_properties ) {
    26             if ( str_starts_with( $source_name, 'test/' ) ) {
    27                 unregister_block_bindings_source( $source_name );
    28             }
     39            unregister_block_bindings_source( $source_name );
    2940        }
    3041
Note: See TracChangeset for help on using the changeset viewer.