mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Editor: Skip file_exist check for core blocks.
In `register_block_type_from_metadata` function, skip calling `file_exists` on core blocks. Core blocks are part of the codebase and will never not exist. Not calling this function is better for performance, as the file lookup can be expensive. Props spacedmonkey, joemcgill. Fixes #58385. git-svn-id: https://develop.svn.wordpress.org/trunk@55910 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
559e6cecf4
commit
0bfc842f80
@ -326,13 +326,15 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
||||
trailingslashit( $file_or_folder ) . 'block.json' :
|
||||
$file_or_folder;
|
||||
|
||||
if ( ! file_exists( $metadata_file ) ) {
|
||||
$is_core_block = str_starts_with( $file_or_folder, ABSPATH . WPINC );
|
||||
|
||||
if ( ! $is_core_block && ! file_exists( $metadata_file ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to get metadata from the static cache for core blocks.
|
||||
$metadata = false;
|
||||
if ( str_starts_with( $file_or_folder, ABSPATH . WPINC ) ) {
|
||||
if ( $is_core_block ) {
|
||||
$core_block_name = str_replace( ABSPATH . WPINC . '/blocks/', '', $file_or_folder );
|
||||
if ( ! empty( $core_blocks_meta[ $core_block_name ] ) ) {
|
||||
$metadata = $core_blocks_meta[ $core_block_name ];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user