bp_detect_theme_compat_with_current_theme()

Set our flag to determine whether theme compat should be enabled.

Description

Theme compat is disabled when a theme meets one of the following criteria: 1) It declares BP support with add_theme_support( ‘buddypress’ ) 2) It is bp-default, or a child theme of bp-default 3) A legacy template is found at members/members-loop.php. This is a fallback check for themes that were derived from bp-default, and have not been updated for BP 1.7+; we make the assumption that any theme in this category will have the members-loop.php template, and so use its presence as an indicator that theme compatibility is not required

Return

(bool) True if the current theme needs theme compatibility.

Source

File: bp-core/bp-core-theme-compatibility.php

function bp_detect_theme_compat_with_current_theme() {
	if ( isset( buddypress()->theme_compat->use_with_current_theme ) ) {
		return buddypress()->theme_compat->use_with_current_theme;
	}

	// Theme compat enabled by default.
	$theme_compat = true;

	// If the theme supports 'buddypress', bail.
	if ( current_theme_supports( 'buddypress' ) ) {
		$theme_compat = false;

	// If the theme doesn't support BP, do some additional checks.
	} else {
		// Bail if theme is a derivative of bp-default.
		if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
			$theme_compat = false;

		// Brute-force check for a BP template.
		// Examples are clones of bp-default.
		} elseif ( locate_template( 'members/members-loop.php', false, false ) ) {
			$theme_compat = false;
		}
	}

	// Set a flag in the buddypress() singleton so we don't have to run this again.
	buddypress()->theme_compat->use_with_current_theme = $theme_compat;

	return $theme_compat;
}

Changelog

Changelog
Version Description
BuddyPress 1.9.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.