WordPress/wp-includes/blocks/index.php
spacedmonkey 1634a10025 Editor: Use register_block_type_from_metadata in register_core_block_types_from_metadata.
Use `register_block_type_from_metadata` in `register_core_block_types_from_metadata` function instead of `register_block_type`. This saves an unnecessary call to `file_exists` in `register_block_type` as core block files will always exist. 

Props nihar007, spacedmonkey, mukesh27, gziolo, sudipatel007.
Fixes #58342.
Built from https://develop.svn.wordpress.org/trunk@55879


git-svn-id: http://core.svn.wordpress.org/trunk@55391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-05 09:31:23 +00:00

30 lines
793 B
PHP

<?php
/**
* Used to set up all core blocks used with the block editor.
*
* @package WordPress
*/
define( 'BLOCKS_PATH', ABSPATH . WPINC . '/blocks/' );
// Include files required for core blocks registration.
require BLOCKS_PATH . 'legacy-widget.php';
require BLOCKS_PATH . 'widget-group.php';
require BLOCKS_PATH . 'require-dynamic-blocks.php';
/**
* Registers core block types using metadata files.
* Dynamic core blocks are registered separately.
*
* @since 5.5.0
*/
function register_core_block_types_from_metadata() {
$block_folders = require BLOCKS_PATH . 'require-static-blocks.php';
foreach ( $block_folders as $block_folder ) {
register_block_type_from_metadata(
BLOCKS_PATH . $block_folder
);
}
}
add_action( 'init', 'register_core_block_types_from_metadata' );