| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') || exit; |
| 4 |
|
| 5 |
global $stbldr_matched_template; |
| 6 |
|
| 7 |
$blockspare_tb_is_block_theme = function_exists('wp_is_block_theme') && wp_is_block_theme(); |
| 8 |
|
| 9 |
// 1. PRE-RENDER BLOCKS: Process blocks BEFORE outputting <head> so WordPress |
| 10 |
// registers all Interactivity API script modules and generates the importmap in wp_head(). |
| 11 |
$rendered_header = ''; |
| 12 |
$rendered_footer = ''; |
| 13 |
$rendered_content = ''; |
| 14 |
|
| 15 |
if ($stbldr_matched_template instanceof WP_Post) { |
| 16 |
$rendered_content = do_blocks($stbldr_matched_template->post_content); |
| 17 |
} |
| 18 |
|
| 19 |
if ($blockspare_tb_is_block_theme) { |
| 20 |
$rendered_header = do_blocks('<!-- wp:template-part {"slug":"header","theme":"' . esc_attr(get_stylesheet()) . '","tagName":"header"} /-->'); |
| 21 |
$rendered_footer = do_blocks('<!-- wp:template-part {"slug":"footer","theme":"' . esc_attr(get_stylesheet()) . '","tagName":"footer"} /-->'); |
| 22 |
} |
| 23 |
|
| 24 |
if ($blockspare_tb_is_block_theme) : |
| 25 |
?> |
| 26 |
<!DOCTYPE html> |
| 27 |
<html <?php language_attributes(); ?>> |
| 28 |
|
| 29 |
<head> |
| 30 |
<meta charset="<?php bloginfo('charset'); ?>"> |
| 31 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 32 |
<?php wp_head(); ?> |
| 33 |
</head> |
| 34 |
|
| 35 |
<body <?php body_class(); ?>> |
| 36 |
<?php wp_body_open(); ?> |
| 37 |
<div class="wp-site-blocks"> |
| 38 |
<?php echo $rendered_header; // phpcs:ignore WordPress.Security.EscapeOutput |
| 39 |
?> |
| 40 |
|
| 41 |
<main id="wp--skip-link--target" class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained" style="margin-top:var(--wp--preset--spacing--60)"> |
| 42 |
<?php echo $rendered_content; // phpcs:ignore WordPress.Security.EscapeOutput |
| 43 |
?> |
| 44 |
</main> |
| 45 |
|
| 46 |
<?php echo $rendered_footer; // phpcs:ignore WordPress.Security.EscapeOutput |
| 47 |
?> |
| 48 |
</div> |
| 49 |
|
| 50 |
<?php wp_footer(); ?> |
| 51 |
</body> |
| 52 |
|
| 53 |
</html> |
| 54 |
<?php |
| 55 |
else : |
| 56 |
// Fallback for classic themes |
| 57 |
get_header(); |
| 58 |
?> |
| 59 |
<main id="wp--skip-link--target" class="wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained" style="margin-top:var(--wp--preset--spacing--60)"> |
| 60 |
<?php echo $rendered_content; // phpcs:ignore WordPress.Security.EscapeOutput |
| 61 |
?> |
| 62 |
</main> |
| 63 |
<?php |
| 64 |
get_footer(); |
| 65 |
endif; |
| 66 |
|