Make WordPress Core

Changeset 48279


Ignore:
Timestamp:
07/02/2020 05:20:28 PM (4 years ago)
Author:
gziolo
Message:

Editor: Move core blocks registration to init hook

After working on support for register_block_type_args filter in #49615, it became clear that we need to use init action for core blocks to make it possible to use this filter.

Fixes #50263.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/index.php

    r48262 r48279  
    1919require ABSPATH . WPINC . '/blocks/tag-cloud.php';
    2020
    21 $block_folders = array(
    22     'audio',
    23     'button',
    24     'buttons',
    25     'classic',
    26     'code',
    27     'column',
    28     'columns',
    29     'file',
    30     'gallery',
    31     'group',
    32     'heading',
    33     'html',
    34     'image',
    35     'list',
    36     'media-text',
    37     'missing',
    38     'more',
    39     'nextpage',
    40     'paragraph',
    41     'preformatted',
    42     'pullquote',
    43     'quote',
    44     'separator',
    45     'social-links',
    46     'spacer',
    47     'subhead',
    48     'table',
    49     'text-columns',
    50     'verse',
    51     'video',
    52 );
     21/**
     22 * Registers core block types using metadata files.
     23 * Dynamic core blocks are registered separately.
     24 *
     25 * @since 5.5.0
     26 */
     27function register_core_block_types_from_metadata() {
     28    $block_folders = array(
     29        'audio',
     30        'button',
     31        'buttons',
     32        'classic',
     33        'code',
     34        'column',
     35        'columns',
     36        'file',
     37        'gallery',
     38        'group',
     39        'heading',
     40        'html',
     41        'image',
     42        'list',
     43        'media-text',
     44        'missing',
     45        'more',
     46        'nextpage',
     47        'paragraph',
     48        'preformatted',
     49        'pullquote',
     50        'quote',
     51        'separator',
     52        'social-links',
     53        'spacer',
     54        'subhead',
     55        'table',
     56        'text-columns',
     57        'verse',
     58        'video',
     59    );
    5360
    54 foreach ( $block_folders as $block_folder ) {
    55     register_block_type_from_metadata(
    56         ABSPATH . WPINC . '/blocks/' . $block_folder
    57     );
     61    foreach ( $block_folders as $block_folder ) {
     62        register_block_type_from_metadata(
     63            ABSPATH . WPINC . '/blocks/' . $block_folder
     64        );
     65    }
    5866}
     67add_action( 'init', 'register_core_block_types_from_metadata' );
  • trunk/tests/phpunit/includes/functions.php

    r47882 r48279  
    315315    remove_action( 'init', 'register_block_core_social_link' );
    316316    remove_action( 'init', 'register_block_core_tag_cloud' );
     317    remove_action( 'init', 'register_core_block_types_from_metadata' );
    317318}
    318319tests_add_filter( 'init', '_unhook_block_registration', 1000 );
Note: See TracChangeset for help on using the changeset viewer.