Skip to content

Commit

Permalink
Remove unnecessary variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nerrad authored Nov 13, 2023
1 parent 6c43311 commit 9eebbbe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ function _remove_theme_attribute_from_template_part_block( &$block ) {
*/
function _build_block_template_result_from_file( $template_file, $template_type ) {
$default_template_types = get_default_block_template_types();
$template_content = file_get_contents( $template_file['path'] );
$theme = get_stylesheet();

$template = new WP_Block_Template();
Expand All @@ -532,7 +531,7 @@ function _build_block_template_result_from_file( $template_file, $template_type
$template->has_theme_file = true;
$template->is_custom = true;
$template->modified = null;
$template->content = $template_content;
$template->content = file_get_contents( $template_file['path'] );

if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) {
$template->description = $default_template_types[ $template_file['slug'] ]['description'];
Expand All @@ -555,7 +554,7 @@ function _build_block_template_result_from_file( $template_file, $template_type
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $template );
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $template );
}
$blocks = parse_blocks( $template_content );
$blocks = parse_blocks( $template->content );
$template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );

return $template;
Expand Down

0 comments on commit 9eebbbe

Please sign in to comment.