File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/lib/block-template-utils.php
<?php
function gtm_do_template( $slug, $theme = null, $template_type = 'wp_template' ) {
// Reference: https://github.com/WordPress/gutenberg/blob/d0fa111d992660d05cc7ced418de1a7ca7c693ff/packages/block-library/src/template-part/index.php
if ( ! $theme ) {
$theme = get_template();
}
static $seen_ids = [];
$content = null;
$template_part_id = null;
$template = get_block_template( sprintf( '%s//%s', $theme, $slug ), $template_type );
if ( $template ) {
$content = $template->content;
$template_part_id = $template->id;
}
if ( isset( $seen_ids[$template_part_id] ) ) { // Prevent infinite nested block
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.
esc_html__( '[block rendering halted]', 'gutenmate' ) :
'';
}
// Run through the actions that are typically taken on the_content.
$seen_ids[$template_part_id] = true;
$content = do_blocks( $content );
unset( $seen_ids[$template_part_id] );
$content = wptexturize( $content );
$content = convert_smilies( $content );
$content = shortcode_unautop( $content );
$content = wp_filter_content_tags( $content );
$content = do_shortcode( $content );
// Handle embeds for block template parts.
global $wp_embed;
$content = $wp_embed->autoembed( $content );
return $content;
}
function gtm_do_template_part( $slug, $theme = null ) {
return gtm_do_template( $slug, $theme, 'wp_template_part' );
}