PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.2
Forumax – AI Powered Advanced Community Forum Plugin v2.4.2
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 2.1.0 All 29 releases
bbp-core / templates / bbpress-wrapper.php

bbpress-wrapper.php in Forumax – AI Powered Advanced Community Forum Plugin 2.4.2, at templates/bbpress-wrapper.php

107 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Forumax – bbPress Wrapper Template for Block / FSE Themes
4 *
5 * Provides a complete page scaffold that works with block (FSE) themes which do
6 * not ship classic PHP template files (header.php, footer.php, etc.).
7 *
8 * NOTE: We do NOT manually render the sidebar here. Forumax's own templates
9 * (content-archive-forum.php, content-single-topic.php, etc.) already render
10 * the sidebar via their own layout containers. Rendering it again here would
11 * produce duplicate sidebars. We only provide the outer page chrome.
12 *
13 * @package Forumax
14 * @since 2.3.1
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * Safely render a block template part with fallback.
21 *
22 * @param string $part The template part name (e.g., 'header', 'footer').
23 */
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;
28 }
29
30 // Check if the template part exists in the theme
31 $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' );
32
33 if ( $template_part ) {
34 block_template_part( $part );
35 } elseif ( 'header' === $part ) {
36 // Minimal fallback header
37 forumax_minimal_header();
38 } elseif ( 'footer' === $part ) {
39 // Minimal fallback footer
40 forumax_minimal_footer();
41 }
42 }
43
44 /**
45 * Minimal header fallback when theme has no header template part.
46 */
47 function forumax_minimal_header() {
48 ?>
49 <header class="forumax-fallback-header" style="padding: 20px 40px; border-bottom: 1px solid #eee;">
50 <div style="max-width: 1200px; margin: 0 auto;">
51 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" style="text-decoration: none; color: inherit;">
52 <strong><?php bloginfo( 'name' ); ?></strong>
53 </a>
54 </div>
55 </header>
56 <?php
57 }
58
59 /**
60 * Minimal footer fallback when theme has no footer template part.
61 */
62 function forumax_minimal_footer() {
63 ?>
64 <footer class="forumax-fallback-footer" style="padding: 20px 40px; border-top: 1px solid #eee; margin-top: 40px;">
65 <div style="max-width: 1200px; margin: 0 auto; text-align: center; color: #666;">
66 &copy; <?php echo esc_html( gmdate( 'Y' ) ); ?> <?php bloginfo( 'name' ); ?>
67 </div>
68 </footer>
69 <?php
70 }
71 ?><!DOCTYPE html>
72 <html <?php language_attributes(); ?>>
73 <head>
74 <meta charset="<?php bloginfo( 'charset' ); ?>">
75 <meta name="viewport" content="width=device-width, initial-scale=1">
76 <?php wp_head(); ?>
77 </head>
78 <body <?php body_class(); ?>>
79 <?php wp_body_open(); ?>
80
81 <?php forumax_render_block_template_part( 'header' ); ?>
82
83 <main id="frmx-bbpress-main" class="frmx-bbpress-page">
84 <?php
85 // Check if bbPress has content to display
86 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() ) ) {
87 // Use bbPress content
88 while ( have_posts() ) :
89 the_post();
90 the_content();
91 endwhile;
92 } else {
93 // Fallback - just show the content
94 while ( have_posts() ) :
95 the_post();
96 the_content();
97 endwhile;
98 }
99 ?>
100 </main>
101
102 <?php forumax_render_block_template_part( 'footer' ); ?>
103
104 <?php wp_footer(); ?>
105 </body>
106 </html>
107