Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.112.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : bbpress.php
<?php

class Brizy_Compatibilities_Bbpress {

	public function __construct() {
		add_action( 'bbp_template_include', [ $this, 'bbp_template_include' ], 3 );
		add_action( 'bbp_get_forum_content', [ $this, 'bbp_get_forum_content' ], 10, 2 );
		add_action( 'brizy_settings_post_types', [ $this, 'settings_post_types' ] );
	}

	public function bbp_template_include( $template ) {

		if ( ! bbp_is_single_forum() && ! bbp_is_single_topic() && ! bbp_is_single_reply() ) {
			return $template;
		}

		$pid = Brizy_Editor::get()->currentPostId();
		$rmTpl = false;

		try {
			if (
				$pid &&
				in_array( get_post_type( $pid ), Brizy_Editor::get()->supported_post_types() ) &&
				Brizy_Editor_Entity::isBrizyEnabled( $pid )
			) {
				$rmTpl = true;
			}
		} catch ( Exception $e ) {}

		try {
			if ( Brizy_Admin_Templates::instance()->getTemplateForCurrentPage() ) {
				$rmTpl = true;
			}
		} catch ( Exception $e ) {}

		if ( $rmTpl ) {
			remove_filter( 'bbp_template_include', 'bbp_template_include_theme_compat', 4 );
		}

		return $template;
	}

	/*
	 * Do not return html in the forums list admin panel if forum is edited with brizy.
	 */
	public function bbp_get_forum_content( $content, $forumId ) {

		global $pagenow;

		if ( ! is_admin() || 'edit.php' != $pagenow || ! isset( $_GET['post_type'] ) || bbp_get_forum_post_type() != $_GET['post_type'] || ! Brizy_Editor_Entity::isBrizyEnabled( $forumId ) ) {
			return $content;
		}

		return '';
	}

	/*
	 * Do not allow to edit replies with brizy, only creating templates for them is allowed.
	 */
	public function settings_post_types( $types ) {

		$reply = bbp_get_reply_post_type();

		if ( isset( $types[ $reply ] ) ) {
			unset( $types[ $reply ] );
		}

		return $types;
	}
}
© 2025 XylotrechusZ