Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROD-7320 Update condition to check if the third party plugins has been loaded #4390

Merged
merged 5 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/bp-core/compatibility/bp-incompatible-plugins-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support for LearnDash & bbPress Integration
*/
if ( in_array( 'learndash-bbpress/learndash-bbpress.php', $bp_plugins ) ) {
if ( class_exists( 'Learndash_BBPress' ) ) {

/**
* Remove bbPress Integration admin init hook action
Expand All @@ -26,7 +26,7 @@ function bp_helper_plugins_loaded_callback() {
*/
remove_action( 'admin_init', 'wdm_activation_dependency_check' );

if ( empty( bp_is_active( 'forums' ) ) || empty( in_array( 'sfwd-lms/sfwd_lms.php', $bp_plugins ) ) ) {
if ( empty( bp_is_active( 'forums' ) ) || ! class_exists( 'SFWD_LMS' ) ) {
deactivate_plugins( 'learndash-bbpress/learndash-bbpress.php' );

add_action( 'admin_notices', 'bp_core_learndash_bbpress_notices' );
Expand All @@ -39,7 +39,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support Rank Math SEO
*/
if ( in_array( 'seo-by-rank-math/rank-math.php', $bp_plugins ) && ! is_admin() ) {
if ( class_exists( 'RankMath' ) && interface_exists( 'RankMath\Paper\IPaper' ) && ! is_admin() ) {
require buddypress()->compatibility_dir . '/bp-rankmath-plugin-helpers.php';
}

Expand All @@ -48,7 +48,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support Elementor
*/
if ( in_array( 'elementor/elementor.php', $bp_plugins ) ) {
if ( class_exists( '\Elementor\Plugin' ) ) {
require buddypress()->compatibility_dir . '/bp-elementor-plugin-helpers.php';
}

Expand All @@ -57,7 +57,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support Co-Authors Plus
*/
if ( in_array( 'co-authors-plus/co-authors-plus.php', $bp_plugins ) ) {
if ( class_exists( 'CoAuthors_Plus' ) ) {
add_filter( 'bp_search_settings_post_type_taxonomies', 'bp_core_remove_authors_taxonomy_for_co_authors_plus', 100, 2 );
}

Expand All @@ -66,7 +66,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support MemberPress + BuddyPress Integration
*/
if ( in_array( 'memberpress-buddypress/main.php', $bp_plugins ) ) {
if ( class_exists( 'MpBuddyPress' ) ) {
/**
* This action is use when admin bar is Enable
*/
Expand All @@ -83,7 +83,7 @@ function bp_helper_plugins_loaded_callback() {
*
* Support WPML Multilingual CMS
*/
if ( in_array( 'sitepress-multilingual-cms/sitepress.php', $bp_plugins ) ) {
if ( class_exists( 'SitePress' ) && class_exists( 'WPML_Fix_Links_In_Display_As_Translated_Content' ) ) {
require buddypress()->compatibility_dir . '/class-bb-wpml-helpers.php';
}

Expand All @@ -92,14 +92,14 @@ function bp_helper_plugins_loaded_callback() {
*
* @since BuddyBoss 1.5.4
*/
if ( in_array( 'wishlist-member/wpm.php', $bp_plugins ) ) {
if ( class_exists( 'WishListMember' ) ) {
global $WishListMemberInstance;
remove_filter( 'user_request_action_email_content', array( &$WishListMemberInstance, 'privacy_user_request_email' ), 10 );
remove_filter( 'user_request_action_email_subject', array( &$WishListMemberInstance, 'privacy_user_request_email_subject' ), 10 );
remove_filter( 'wp_privacy_personal_data_email_content', array( &$WishListMemberInstance, 'privacy_personal_data_email' ), 10 );
}

if ( in_array( 'instructor-role/instructor.php', $bp_plugins, true ) ) {
if ( class_exists( '\InstructorRole\Includes\Instructor_Role' ) ) {

/**
* Function to exclude group type post to prevent group role overriding.
Expand All @@ -121,7 +121,7 @@ function bp_core_instructor_role_post_exclude( $exclude_posts ) {
add_filter( 'wdmir_exclude_post_types', 'bp_core_instructor_role_post_exclude', 10, 1 );
}

if ( in_array( 'geodirectory/geodirectory.php', $bp_plugins, true ) ) {
if ( class_exists( 'GeoDirectory' ) ) {

/**
* Function to deregister some scripts and styles from bp component pages
Expand Down Expand Up @@ -183,7 +183,7 @@ function bp_deregister_geodirectory_styles() {
*
* Support The Events Calendar.
*/
if ( in_array( 'the-events-calendar/the-events-calendar.php', $bp_plugins, true ) ) {
if ( class_exists( 'Tribe__Events__Main' ) ) {
require buddypress()->compatibility_dir . '/class-bb-the-events-calendar-helpers.php';
}

Expand Down Expand Up @@ -226,7 +226,7 @@ function( $builder_load_requests ) {
*
* Support Memberpress
*/
if ( in_array( 'memberpress/memberpress.php', $bp_plugins ) ) {
if ( class_exists( 'MeprAppCtrl' ) ) {
add_filter( 'mepr_design_style_handle_prefixes', function ( $allowed_handle_prefixes ) {
$allowed_handle_prefixes[] = 'admin-bar';
$allowed_handle_prefixes[] = 'bp-';
Expand All @@ -242,7 +242,7 @@ function( $builder_load_requests ) {
*
* @since BuddyBoss 2.5.60
*/
if ( in_array( 'instructor-role/instructor.php', $bp_plugins ) ) {
if ( class_exists( '\InstructorRole\Includes\Instructor_Role' ) ) {
add_filter( 'ir_filter_remove_private_protected_from_titles', function ( $is_prepend, $prepend, $post ) {
$post_types = array();

Expand Down Expand Up @@ -556,7 +556,7 @@ function bb_core_add_support_mepr_signup_map_user_fields( $txn ) {
function bp_core_learndash_bbpress_notices() {
global $bp_plugins;

if ( empty( bp_is_active( 'forums' ) ) || empty( in_array( 'sfwd-lms/sfwd_lms.php', $bp_plugins ) ) ) {
if ( empty( bp_is_active( 'forums' ) ) || ! class_exists( 'SFWD_LMS' ) ) {
$links = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) );

$text = sprintf( '<a href="%s">%s</a>', $links, __( 'Forum Discussions', 'buddyboss' ) );
Expand Down