Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add do_block_template_part function #30345

Merged
merged 4 commits into from
Apr 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
Addison-Stavlo marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* 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' );
}