. * * @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( '' ); } } // 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() { ?>
> >