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
1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 | 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.