From 9350b6f3889ea0100f172ea1c5be4bd737587a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Wed, 9 Oct 2024 00:33:48 +0200 Subject: [PATCH 1/2] Rename wp_register_block_template() to register_block_template() --- src/wp-includes/block-template.php | 2 +- tests/phpunit/tests/block-template.php | 4 ++-- tests/phpunit/tests/rest-api/wpRestTemplatesController.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php index d42a74479c4e3..fc70c15669e9d 100644 --- a/src/wp-includes/block-template.php +++ b/src/wp-includes/block-template.php @@ -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 ); } diff --git a/tests/phpunit/tests/block-template.php b/tests/phpunit/tests/block-template.php index 9ec506a414a46..e777b4839562d 100644 --- a/tests/phpunit/tests/block-template.php +++ b/tests/phpunit/tests/block-template.php @@ -443,7 +443,7 @@ public function test_get_block_templates_paths_dir_doesnt_exists() { 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(); @@ -465,7 +465,7 @@ public function test_get_block_template_from_registry() { 'title' => 'Test Template', ); - wp_register_block_template( $template_name, $args ); + register_block_template( $template_name, $args ); $template = get_block_template( 'block-theme//test-template' ); diff --git a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php index db0183aa78986..ee5158b27e1a5 100644 --- a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php +++ b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php @@ -546,7 +546,7 @@ public function test_get_item_from_registry() { '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 ); From 7c5c4012a5b8fd8a2162b577b367d89eea536990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Wed, 9 Oct 2024 00:35:47 +0200 Subject: [PATCH 2/2] Rename wp_unregister_block_template() to unregister_block_template() --- src/wp-includes/block-template.php | 2 +- tests/phpunit/tests/block-template.php | 4 ++-- tests/phpunit/tests/rest-api/wpRestTemplatesController.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php index fc70c15669e9d..2a75231ae4e90 100644 --- a/src/wp-includes/block-template.php +++ b/src/wp-includes/block-template.php @@ -390,6 +390,6 @@ function 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 ); } diff --git a/tests/phpunit/tests/block-template.php b/tests/phpunit/tests/block-template.php index e777b4839562d..d88895c872be1 100644 --- a/tests/phpunit/tests/block-template.php +++ b/tests/phpunit/tests/block-template.php @@ -449,7 +449,7 @@ public function test_get_block_templates_from_registry() { $this->assertArrayHasKey( $template_name, $templates ); - wp_unregister_block_template( $template_name ); + unregister_block_template( $template_name ); } /** @@ -471,7 +471,7 @@ public function test_get_block_template_from_registry() { $this->assertSame( 'Test Template', $template->title ); - wp_unregister_block_template( $template_name ); + unregister_block_template( $template_name ); } /** diff --git a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php index ee5158b27e1a5..ad8cf945f971e 100644 --- a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php +++ b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php @@ -566,7 +566,7 @@ public function test_get_item_from_registry() { $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 );