Skip to content

Commit

Permalink
Create bbpress-compat.php
Browse files Browse the repository at this point in the history
  • Loading branch information
joanrodas authored Apr 26, 2022
1 parent cd74459 commit d81d19c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/bbpress-compat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

if( class_exists( 'bbpress' ) ) {

add_filter('bbp_template_include', function ($template) {
if(is_bbpress()) {
return get_page_template();
}
return $template;
}, 100);

add_filter('bbp_get_template_part', function ($templates, $slug, $name) {
foreach ($templates as $template) {
$theme_template = locate_template( app('sage.finder')->locate("bbpress/{$template}") );
if( !empty( $theme_template ) ) {
$view = app('view.finder')->getPossibleViewNameFromPath($theme_template);
$view = trim($view, '\\/.');
echo view($view)->render();
return get_stylesheet_directory() . '/index.php';
}
}
return $templates;
}, PHP_INT_MAX, 3);

}

0 comments on commit d81d19c

Please sign in to comment.