Skip to content

Commit

Permalink
Add do_block_template_part function (#30345)
Browse files Browse the repository at this point in the history
* Add do_block_template_part function

* Add functions for the header & footer template-parts

* rename functions

* rename functions
  • Loading branch information
aristath authored Apr 8, 2021
1 parent 3dc3322 commit 030dce8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/full-site-editing/template-parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,36 @@ function gutenberg_filter_template_part_area( $type ) {
trigger_error( $warning_message, E_USER_NOTICE );
return WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
}

/**
* Print a template-part.
*
* @param string $part The template-part to print. Use "header" or "footer".
*
* @return void
*/
function gutenberg_block_template_part( $part ) {
$template_part = gutenberg_get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' );
if ( ! $template_part || empty( $template_part->content ) ) {
return;
}
echo do_blocks( $template_part->content );
}

/**
* Print the header template-part.
*
* @return void
*/
function gutenberg_block_header_area() {
gutenberg_block_template_part( 'header' );
}

/**
* Print the footer template-part.
*
* @return void
*/
function gutenberg_block_footer_area() {
gutenberg_block_template_part( 'footer' );
}

0 comments on commit 030dce8

Please sign in to comment.