Editor: Extend register_block_type to accept the path file or folder with block.json

Rather than using two distinct methods to register block types in WordPress core, let's make `register_block_type` the canonical method to deal with all use cases. In practice, the patch proposed extends its usage to work as a proxy to `register_block_type_from_metadata`. It should remove some confusion that we observed and let us be more explicit what's the latest recommendation.

Props matveb, mcsf.
Fixes #53233.



git-svn-id: https://develop.svn.wordpress.org/trunk@50927 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2021-05-19 13:50:09 +00:00
parent fe9ab38075
commit 6ad4e34c54
3 changed files with 53 additions and 33 deletions
+12
View File
@@ -382,6 +382,18 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
);
}
/**
* @ticket 53233
*/
function test_block_register_block_type_proxy_for_metadata() {
$result = register_block_type(
DIR_TESTDATA . '/blocks/notice'
);
$this->assertInstanceOf( 'WP_Block_Type', $result );
$this->assertSame( 'tests/notice', $result->name );
}
/**
* @ticket 52301
*/