# bbp-core/2.5.1/templates/bbpress-wrapper.php

Forumax – AI Powered Advanced Community Forum Plugin, version 2.5.1. 132 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.5.1/code/templates/bbpress-wrapper.php
- Raw: https://pluginprobe.com/plugins/bbp-core/2.5.1/raw/templates/bbpress-wrapper.php
- Modified: 2026-10-12T12:43:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.5.1/code/templates/bbpress-wrapper.php#L10-L20`.

```php
<?php
/**
 * Forumax – bbPress Wrapper Template for Block / FSE Themes
 *
 * Provides a complete page scaffold that works with block (FSE) themes which do
 * not ship classic PHP template files (header.php, footer.php, etc.).
 *
 * NOTE: We do NOT manually render the sidebar here. Forumax's own templates
 * (content-archive-forum.php, content-single-topic.php, etc.) already render
 * the sidebar via their own layout containers. Rendering it again here would
 * produce duplicate sidebars. We only provide the outer page chrome.
 *
 * @package Forumax
 * @since   2.3.1
 */

defined( 'ABSPATH' ) || exit;

/**
 * Safely get rendered block template part HTML with fallback.
 *
 * In block (FSE) themes, template parts must be rendered before wp_head() so
 * that Gutenberg layout styles (flex, space-between, gap, constrained layout, etc.)
 * are registered in the Style Engine and enqueued via wp_enqueue_stored_styles() in <head>.
 *
 * @param string $part The template part name (e.g., 'header', 'footer').
 * @param string $tag_name Optional HTML tag name (e.g., 'header', 'footer').
 * @return string Rendered HTML.
 */
function forumax_get_block_template_part_html( $part, $tag_name = '' ) {
	if ( empty( $tag_name ) ) {
		$tag_name = ( 'header' === $part || 'footer' === $part ) ? $part : 'div';
	}

	if ( function_exists( 'get_block_template' ) ) {
		$template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' );
		if ( ! $template_part && get_stylesheet() !== get_template() ) {
			$template_part = get_block_template( get_template() . '//' . $part, 'wp_template_part' );
		}

		if ( $template_part && function_exists( 'do_blocks' ) ) {
			return do_blocks( '<!-- wp:template-part {"slug":"' . esc_attr( $part ) . '","tagName":"' . esc_attr( $tag_name ) . '"} /-->' );
		}
	}

	// Fallback if no block template part found.
	ob_start();
	if ( 'header' === $part ) {
		forumax_minimal_header();
	} elseif ( 'footer' === $part ) {
		forumax_minimal_footer();
	}
	return ob_get_clean();
}

/**
 * Safely render a block template part with fallback.
 *
 * @param string $part The template part name (e.g., 'header', 'footer').
 */
function forumax_render_block_template_part( $part ) {
	echo forumax_get_block_template_part_html( $part );
}

/**
 * Minimal header fallback when theme has no header template part.
 */
function forumax_minimal_header() {
	?>
	<header class="forumax-fallback-header" style="padding: 20px 40px; border-bottom: 1px solid #eee;">
		<div style="max-width: 1200px; margin: 0 auto;">
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" style="text-decoration: none; color: inherit;">
				<strong><?php bloginfo( 'name' ); ?></strong>
			</a>
		</div>
	</header>
	<?php
}

/**
 * Minimal footer fallback when theme has no footer template part.
 */
function forumax_minimal_footer() {
	?>
	<footer class="forumax-fallback-footer" style="padding: 20px 40px; border-top: 1px solid #eee; margin-top: 40px;">
		<div style="max-width: 1200px; margin: 0 auto; text-align: center; color: #666;">
			&copy; <?php echo esc_html( gmdate( 'Y' ) ); ?> <?php bloginfo( 'name' ); ?>
		</div>
	</footer>
	<?php
}

// Pre-render header and footer before wp_head() so Gutenberg collects block support layout styles.
$forumax_header_html = forumax_get_block_template_part_html( 'header', 'header' );
$forumax_footer_html = forumax_get_block_template_part_html( 'footer', 'footer' );
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>

<?php echo $forumax_header_html; ?>

<main id="frmx-bbpress-main" class="frmx-bbpress-page">
	<?php
	// Check if bbPress has content to display
	if ( function_exists( 'bbp_is_single_forum' ) && ( bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_archive() || bbp_is_forum_archive() || bbp_is_single_user() || bbp_is_single_view() || bbp_is_search() || bbp_is_topic_tag() ) ) {
		// Use bbPress content
		while ( have_posts() ) :
			the_post();
			the_content();
		endwhile;
	} else {
		// Fallback - just show the content
		while ( have_posts() ) :
			the_post();
			the_content();
		endwhile;
	}
	?>
</main>

<?php echo $forumax_footer_html; ?>

<?php wp_footer(); ?>
</body>
</html>

```
