Editor: Support filtering arguments in block type registration from metadata
Adds 2 new hooks in `register_block_type_from_metadata`: - Named `block_type_metadata` to filter the content of metadata read from `block.json` - Named `block_type_metadata_settings` to filter the settings object determined from the metadata that is passed to `register_block_type` call Props swissspidy. Fixes #52138. Built from https://develop.svn.wordpress.org/trunk@49948 git-svn-id: http://core.svn.wordpress.org/trunk@49647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2be70e8aa4
commit
a756900974
|
@ -201,6 +201,15 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
|||
}
|
||||
$metadata['file'] = $metadata_file;
|
||||
|
||||
/**
|
||||
* Filters the metadata provided for registering a block type.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*
|
||||
* @param array $metadata Metadata for registering a block type.
|
||||
*/
|
||||
$metadata = apply_filters( 'block_type_metadata', $metadata );
|
||||
|
||||
$settings = array();
|
||||
$property_mappings = array(
|
||||
'title' => 'title',
|
||||
|
@ -252,12 +261,26 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
|||
);
|
||||
}
|
||||
|
||||
return register_block_type(
|
||||
$metadata['name'],
|
||||
/**
|
||||
* Filters the settings determined from the block type metadata.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*
|
||||
* @param array $settings Array of determined settings for registering a block type.
|
||||
* @param array $metadata Metadata provided for registering a block type.
|
||||
*/
|
||||
$settings = apply_filters(
|
||||
'block_type_metadata_settings',
|
||||
array_merge(
|
||||
$settings,
|
||||
$args
|
||||
)
|
||||
),
|
||||
$metadata
|
||||
);
|
||||
|
||||
return register_block_type(
|
||||
$metadata['name'],
|
||||
$settings
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.7-alpha-49947';
|
||||
$wp_version = '5.7-alpha-49948';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue