Skip to content

Commit 9eebbbe

Browse files
authored
Remove unnecessary variable
Consolidates initial read from template file into the `content` property in the `WP_Block_Template` instance removing the need for a separate `$template_content` variable.
1 parent 6c43311 commit 9eebbbe

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ function _remove_theme_attribute_from_template_part_block( &$block ) {
518518
*/
519519
function _build_block_template_result_from_file( $template_file, $template_type ) {
520520
$default_template_types = get_default_block_template_types();
521-
$template_content = file_get_contents( $template_file['path'] );
522521
$theme = get_stylesheet();
523522

524523
$template = new WP_Block_Template();
@@ -532,7 +531,7 @@ function _build_block_template_result_from_file( $template_file, $template_type
532531
$template->has_theme_file = true;
533532
$template->is_custom = true;
534533
$template->modified = null;
535-
$template->content = $template_content;
534+
$template->content = file_get_contents( $template_file['path'] );
536535

537536
if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) {
538537
$template->description = $default_template_types[ $template_file['slug'] ]['description'];
@@ -555,7 +554,7 @@ function _build_block_template_result_from_file( $template_file, $template_type
555554
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $template );
556555
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $template );
557556
}
558-
$blocks = parse_blocks( $template_content );
557+
$blocks = parse_blocks( $template->content );
559558
$template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );
560559

561560
return $template;

0 commit comments

Comments
 (0)