PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
← All changes | templates/bbpress-wrapper.php +14 -39 trunk → 2.5.0 View file →
@@ -16,54 +16,33 @@
16 16
17 17 defined( 'ABSPATH' ) || exit;
18 18
19 19 /**
20 - * Safely get rendered block template part HTML with fallback.
20 + * Safely render a block template part with fallback.
21 21 *
22 - * In block (FSE) themes, template parts must be rendered before wp_head() so
23 - * that Gutenberg layout styles (flex, space-between, gap, constrained layout, etc.)
24 - * are registered in the Style Engine and enqueued via wp_enqueue_stored_styles() in <head>.
25 - *
26 22 * @param string $part The template part name (e.g., 'header', 'footer').
27 - * @param string $tag_name Optional HTML tag name (e.g., 'header', 'footer').
28 - * @return string Rendered HTML.
29 23 */
30 -function forumax_get_block_template_part_html( $part, $tag_name = '' ) {
31 - if ( empty( $tag_name ) ) {
32 - $tag_name = ( 'header' === $part || 'footer' === $part ) ? $part : 'div';
24 +function forumax_render_block_template_part( $part ) {
25 + // Check if block_template_part function exists (WP 5.9+)
26 + if ( ! function_exists( 'block_template_part' ) ) {
27 + return;
33 28 }
34 29
35 - if ( function_exists( 'get_block_template' ) ) {
36 - $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' );
37 - if ( ! $template_part && get_stylesheet() !== get_template() ) {
38 - $template_part = get_block_template( get_template() . '//' . $part, 'wp_template_part' );
39 - }
30 + // Check if the template part exists in the theme
31 + $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' );
40 32
41 - if ( $template_part && function_exists( 'do_blocks' ) ) {
42 - return do_blocks( '<!-- wp:template-part {"slug":"' . esc_attr( $part ) . '","tagName":"' . esc_attr( $tag_name ) . '"} /-->' );
43 - }
44 - }
45 -
46 - // Fallback if no block template part found.
47 - ob_start();
48 - if ( 'header' === $part ) {
33 + if ( $template_part ) {
34 + block_template_part( $part );
35 + } elseif ( 'header' === $part ) {
36 + // Minimal fallback header
49 37 forumax_minimal_header();
50 38 } elseif ( 'footer' === $part ) {
39 + // Minimal fallback footer
51 40 forumax_minimal_footer();
52 41 }
53 - return ob_get_clean();
54 42 }
55 43
56 44 /**
57 - * Safely render a block template part with fallback.
58 - *
59 - * @param string $part The template part name (e.g., 'header', 'footer').
60 - */
61 -function forumax_render_block_template_part( $part ) {
62 - echo forumax_get_block_template_part_html( $part );
63 -}
64 -
65 -/**
66 45 * Minimal header fallback when theme has no header template part.
67 46 */
68 47 function forumax_minimal_header() {
69 48 ?>
@@ -88,12 +67,8 @@
88 67 </div>
89 68 </footer>
90 69 <?php
91 70 }
92 -
93 -// Pre-render header and footer before wp_head() so Gutenberg collects block support layout styles.
94 -$forumax_header_html = forumax_get_block_template_part_html( 'header', 'header' );
95 -$forumax_footer_html = forumax_get_block_template_part_html( 'footer', 'footer' );
96 71 ?><!DOCTYPE html>
97 72 <html <?php language_attributes(); ?>>
98 73 <head>
99 74 <meta charset="<?php bloginfo( 'charset' ); ?>">
@@ -102,9 +77,9 @@
102 77 </head>
103 78 <body <?php body_class(); ?>>
104 79 <?php wp_body_open(); ?>
105 80
106 -<?php echo $forumax_header_html; ?>
81 +<?php forumax_render_block_template_part( 'header' ); ?>
107 82
108 83 <main id="frmx-bbpress-main" class="frmx-bbpress-page">
109 84 <?php
110 85 // Check if bbPress has content to display
@@ -123,9 +98,9 @@
123 98 }
124 99 ?>
125 100 </main>
126 101
127 -<?php echo $forumax_footer_html; ?>
102 +<?php forumax_render_block_template_part( 'footer' ); ?>
128 103
129 104 <?php wp_footer(); ?>
130 105 </body>
131 106 </html>