Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/inc/bbpress//bbp-load.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'JELLY_BBP_URL', plugin_dir_url( __FILE__ ) );
define( 'JELLY_BBP_PATH', plugin_dir_path( __FILE__ ) );
include_once JELLY_BBP_PATH . 'settings.php';
if ( ! class_exists( 'jelly_bbpress_class' ) ) {
class jelly_bbpress_class {
protected static $instance = null;
static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
function __construct() {
if ( ! class_exists( 'bbpress' ) ) {
return;
}
include_once JELLY_BBP_PATH . 'helper.php';
include_once JELLY_BBP_PATH . 'actions.php';
include_once JELLY_BBP_PATH . 'templates/parts.php';
add_post_type_support( 'forum', [ 'thumbnail' ] );
add_action( 'init', [ 'jelly_bbpress_settings', 'get_instance' ], 10 );
add_filter( 'bbp_default_styles', [ $this, 'remove_bbp_style' ], 10, 1 );
add_action( 'bbp_enqueue_scripts', [ $this, 'enqueue' ], 99 );
add_filter( 'template_include', [ $this, 'bbpress_redirect' ], 99 );
add_filter( 'bbp_template_stack', [ $this, 'location' ], 9 );
add_filter( 'bbp_kses_allowed_tags', [ $this, 'remove_tags' ], 10, 1 );
add_filter( 'bbp_show_lead_topic', [ $this, 'show_lead_topic' ], 10, 1 );
}
function show_lead_topic( $show_lead ) {
if ( get_option( 'jelly_bbp_lead_topic' ) ) {
$show_lead[] = true;
}
return $show_lead;
}
function remove_tags( $tags ) {
if ( ! current_user_can( 'moderate' ) ) {
if ( isset( $tags['li'] ) ) {
unset( $tags['li'] );
}
if ( isset( $tags['ul'] ) ) {
unset( $tags['ul'] );
}
if ( isset( $tags['ol'] ) ) {
unset( $tags['ol'] );
}
}
return $tags;
}
function enqueue() {
if ( ! is_bbpress() ) {
return false;
}
wp_register_style( 'jelly-bbp', JELLY_BBP_URL . 'bbp.css', null );
wp_enqueue_style( 'jelly-bbp' );
}
function remove_bbp_style( $defaults ) {
return [];
}
function location() {
return JELLY_BBP_PATH . 'templates';
}
public function bbpress_redirect( $template ) {
if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
if ( class_exists( 'Elementor\Plugin' ) && is_page() ) {
$template_slug = get_page_template_slug();
if ( substr( $template_slug, 0, 9 ) === 'elementor' ) {
return $template;
}
}
$template = JELLY_BBP_PATH . 'templates/single-bbp.php';
}
return $template;
}
}
}
add_action( 'plugins_loaded', [ 'jelly_bbpress_class', 'get_instance' ], 10 );