Skip to content

Commit

Permalink
Editor: Remove prefix from wp_(un)register_block_template() functions.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
peterwilsoncc committed Oct 9, 2024
1 parent ccb77c5 commit 4ccb5b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/wp-includes/block-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand All @@ -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 );
}
8 changes: 4 additions & 4 deletions tests/phpunit/tests/block-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,13 @@ 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();

$this->assertArrayHasKey( $template_name, $templates );

wp_unregister_block_template( $template_name );
unregister_block_template( $template_name );
}

/**
Expand All @@ -465,13 +465,13 @@ 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' );

$this->assertSame( 'Test Template', $template->title );

wp_unregister_block_template( $template_name );
unregister_block_template( $template_name );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/rest-api/wpRestTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down

0 comments on commit 4ccb5b4

Please sign in to comment.