bp_is_root_component( string $component_name = '' )
Check to see if a component’s URL should be in the root, not under a member page.
Description
- Yes (‘groups’ is root) : http://example.com/groups/the-group
- No (‘groups’ is not-root): http://example.com/members/andy/groups/the-group
This function is on the chopping block. It’s currently only used by a few already deprecated functions.
Parameters
- $component_name
-
(Optional) Component name to check.
Default value: ''
Return
(bool) True if root component, else false.
Source
File: bp-core/bp-core-template.php
function bp_is_root_component( $component_name = '' ) { $bp = buddypress(); $retval = false; // Default to the current component if none is passed. if ( empty( $component_name ) ) { $component_name = bp_current_component(); } // Loop through active components and check for key/slug matches. if ( ! empty( $bp->active_components ) ) { foreach ( (array) $bp->active_components as $key => $slug ) { if ( ( $key === $component_name ) || ( $slug === $component_name ) ) { $retval = true; break; } } } /** * Filters whether or not a component's URL should be in the root, not under a member page. * * @since BuddyPress 2.1.0 * * @param bool $retval Whether or not URL should be in the root. */ return (bool) apply_filters( 'bp_is_root_component', $retval ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.5.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.