bp_is_active( string $component = '', string $feature = '' )
Check whether a given component (or feature of a component) is active.
Description Description
Parameters Parameters
- $component
-
(Optional) The component name.
Default value: ''
- $feature
-
(Optional) The feature name.
Default value: ''
Return Return
(bool)
Source Source
File: bp-core/bp-core-template.php
function bp_is_active( $component = '', $feature = '' ) {
$retval = false;
// Default to the current component if none is passed.
if ( empty( $component ) ) {
$component = bp_current_component();
}
// Is component in either the active or required components arrays.
if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
$retval = true;
// Is feature active?
if ( ! empty( $feature ) ) {
// The xProfile component is specific.
if ( 'xprofile' === $component ) {
$component = 'profile';
}
$component_features = isset( buddypress()->{$component}->features ) ? buddypress()->{$component}->features : array();
if ( empty( $component_features ) || false === in_array( $feature, $component_features, true ) ) {
$retval = false;
}
/**
* Filters whether or not a given feature for a component is active.
*
* This is a variable filter that is based on the component and feature
* that you are checking of active status of.
*
* @since 2.3.0
*
* @param bool $retval
*/
$retval = apply_filters( "bp_is_{$component}_{$feature}_active", $retval );
}
}
/**
* Filters whether or not a given component has been activated by the admin.
*
* @since 2.1.0
*
* @param bool $retval Whether or not a given component has been activated by the admin.
* @param string $component Current component being checked.
*/
return apply_filters( 'bp_is_active', $retval, $component );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.3.0 | Added $feature as a parameter. |
| 1.2.0 | Introduced. |