Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename wp_register_block_template() to register_block_template() #7543

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading