Skip to content

Commit bbed6bd

Browse files
committed
Fix: Ensure block template content is only modified if the template exists
1 parent ceba29e commit bbed6bd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/wp-includes/block-template-utils.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,11 +1385,13 @@ function get_block_file_template( $id, $template_type = 'wp_template' ) {
13851385

13861386
$block_template = WP_Block_Templates_Registry::get_instance()->get_by_slug( $slug );
13871387

1388-
$block_template->content = apply_block_hooks_to_content(
1389-
$block_template->content,
1390-
$block_template,
1391-
'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata'
1392-
);
1388+
if ( $block_template ) {
1389+
$block_template->content = apply_block_hooks_to_content(
1390+
$block_template->content,
1391+
$block_template,
1392+
'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata'
1393+
);
1394+
}
13931395

13941396
/**
13951397
* Filters the block template object after it has been (potentially) fetched from the theme file.

0 commit comments

Comments
 (0)