Editor: Remove prefix from wp_(un)register_block_template() functions.

Removes the `wp_` prefix from block template registration functions for consistency with other block related registration functions.

* `wp_register_block_template()` becomes `register_block_template()`.
* `wp_unregister_block_template()` becomes `unregister_block_template()`.

Props aljullu, aristath, youknowriad, swissspidy.
Fixes #62193.



git-svn-id: https://develop.svn.wordpress.org/trunk@59201 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2024-10-09 22:09:30 +00:00
parent ccb77c523a
commit 4ccb5b4af0
3 changed files with 8 additions and 8 deletions

View File

@ -377,7 +377,7 @@ function _resolve_template_for_new_post( $wp_query ) {
* }
* @return WP_Block_Template|WP_Error The registered template object on success, WP_Error object on failure.
*/
function wp_register_block_template( $template_name, $args = array() ) {
function register_block_template( $template_name, $args = array() ) {
return WP_Block_Templates_Registry::get_instance()->register( $template_name, $args );
}
@ -390,6 +390,6 @@ function wp_register_block_template( $template_name, $args = array() ) {
* @return WP_Block_Template|WP_Error The unregistered template object on success, WP_Error object on failure or if the
* template doesn't exist.
*/
function wp_unregister_block_template( $template_name ) {
function unregister_block_template( $template_name ) {
return WP_Block_Templates_Registry::get_instance()->unregister( $template_name );
}

View File

@ -443,13 +443,13 @@ class Tests_Block_Template extends WP_UnitTestCase {
public function test_get_block_templates_from_registry() {
$template_name = 'test-plugin//test-template';
wp_register_block_template( $template_name );
register_block_template( $template_name );
$templates = get_block_templates();
$this->assertArrayHasKey( $template_name, $templates );
wp_unregister_block_template( $template_name );
unregister_block_template( $template_name );
}
/**
@ -465,13 +465,13 @@ class Tests_Block_Template extends WP_UnitTestCase {
'title' => 'Test Template',
);
wp_register_block_template( $template_name, $args );
register_block_template( $template_name, $args );
$template = get_block_template( 'block-theme//test-template' );
$this->assertSame( 'Test Template', $template->title );
wp_unregister_block_template( $template_name );
unregister_block_template( $template_name );
}
/**

View File

@ -546,7 +546,7 @@ class Tests_REST_WpRestTemplatesController extends WP_Test_REST_Controller_Testc
'post_types' => array( 'post', 'page' ),
);
wp_register_block_template( $template_name, $args );
register_block_template( $template_name, $args );
$request = new WP_REST_Request( 'GET', '/wp/v2/templates/test-plugin//test-template' );
$response = rest_get_server()->dispatch( $request );
@ -566,7 +566,7 @@ class Tests_REST_WpRestTemplatesController extends WP_Test_REST_Controller_Testc
$this->assertSame( 'Test Template', $data['title']['rendered'], 'Template title mismatch.' );
$this->assertSame( 'test-plugin', $data['plugin'], 'Plugin name mismatch.' );
wp_unregister_block_template( $template_name );
unregister_block_template( $template_name );
$request = new WP_REST_Request( 'GET', '/wp/v2/templates/test-plugin//test-template' );
$response = rest_get_server()->dispatch( $request );