Skip to content

Commit

Permalink
Template Part block: Use _build_block_template_result_from_post (#55811)
Browse files Browse the repository at this point in the history
In the Template Part block's `render` method, use `_build_block_template_result_from_post()` to build a `WP_Block_Template` object instead of doing the same "post-processing" in a manual way.
  • Loading branch information
ockham authored Nov 6, 2023
1 parent 417eff2 commit ec8ce3b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function render_block_core_template_part( $attributes ) {
if ( $template_part_post ) {
// A published post might already exist if this template part was customized elsewhere
// or if it's part of a customized template.
$content = $template_part_post->post_content;
$area_terms = get_the_terms( $template_part_post, 'wp_template_part_area' );
if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
$area = $area_terms[0]->name;
$block_template = _build_block_template_result_from_post( $template_part_post );
$content = $block_template->content;
if ( isset( $block_template->area ) ) {
$area = $block_template->area;
}
/**
* Fires when a block template part is loaded from a template post stored in the database.
Expand Down

1 comment on commit ec8ce3b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ec8ce3b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6772412499
📝 Reported issues:

Please sign in to comment.