bp_is_root_component

Check to see if a component's URL should be in the root, not under a member page.

Description

bp_is_root_component( (string) $component_name = '' ); 

- 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 (1)

0. $component_name — Optional. (string) => ''
Component name to check.

Usage

  1. if ( !function_exists( 'bp_is_root_component' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-template.php'; 
  3.  
  4. // Component name to check. 
  5. $component_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_is_root_component($component_name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-template.php  
  1. function bp_is_root_component( $component_name = '' ) { 
  2. $bp =buddypress); 
  3. $retval = false; 
  4.  
  5. // Default to the current component if none is passed. 
  6. if ( empty( $component_name ) ) { 
  7. $component_name = bp_current_component(); 
  8.  
  9. // Loop through active components and check for key/slug matches. 
  10. if ( ! empty( $bp->active_components ) ) { 
  11. foreach ( (array) $bp->active_components as $key => $slug ) { 
  12. if ( ( $key === $component_name ) || ( $slug === $component_name ) ) { 
  13. $retval = true; 
  14. break; 
  15.  
  16. /** 
  17. * Filters whether or not a component's URL should be in the root, not under a member page. 
  18. * @since 2.1.0 
  19. * @param bool $retval Whether or not URL should be in the root. 
  20. */ 
  21. return (bool) apply_filters( 'bp_is_root_component', $retval );