Skip to content

Commit d81d19c

Browse files
authored
Create bbpress-compat.php
1 parent cd74459 commit d81d19c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/bbpress-compat.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
if( class_exists( 'bbpress' ) ) {
4+
5+
add_filter('bbp_template_include', function ($template) {
6+
if(is_bbpress()) {
7+
return get_page_template();
8+
}
9+
return $template;
10+
}, 100);
11+
12+
add_filter('bbp_get_template_part', function ($templates, $slug, $name) {
13+
foreach ($templates as $template) {
14+
$theme_template = locate_template( app('sage.finder')->locate("bbpress/{$template}") );
15+
if( !empty( $theme_template ) ) {
16+
$view = app('view.finder')->getPossibleViewNameFromPath($theme_template);
17+
$view = trim($view, '\\/.');
18+
echo view($view)->render();
19+
return get_stylesheet_directory() . '/index.php';
20+
}
21+
}
22+
return $templates;
23+
}, PHP_INT_MAX, 3);
24+
25+
}

0 commit comments

Comments
 (0)