-
-
Save imath/aed2ceb4dc8b47cfef18174f4df9c14d to your computer and use it in GitHub Desktop.
Workaround to load BP Templates into WP FSE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function g_buddypress_template( $template ) { | |
| if ( ! function_exists( 'gutenberg_dir_path' ) ) { | |
| return $template; | |
| } | |
| return gutenberg_dir_path() . 'lib/template-canvas.php'; | |
| } | |
| add_filter( 'bp_buddypress_template', 'g_buddypress_template', 10, 1 ); | |
| function g_buddypress_render_post_content( $attributes, $content = '', $block ) { | |
| if ( ! in_the_loop() ) { | |
| the_post(); | |
| } | |
| $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) ); | |
| /** This filter is documented in wp-includes/post-template.php */ | |
| $content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) ); | |
| return ( | |
| '<div ' . $wrapper_attributes . '>' . | |
| $content . | |
| '</div>' | |
| ); | |
| } | |
| function g_buddypress_override_post_content_renderer( $settings = array(), $metadata = array() ) { | |
| if ( 'core/post-content' === $metadata['name'] && is_buddypress() ) { | |
| $settings['render_callback'] = 'g_buddypress_render_post_content'; | |
| } | |
| return $settings; | |
| } | |
| add_filter( 'block_type_metadata_settings', 'g_buddypress_override_post_content_renderer', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment