bp_is_component_front_page

Check if the specified BuddyPress component directory is set to be the front page.

Description

bp_is_component_front_page( (string) $component = '' ); 

Corresponds to the setting in wp-admin's Settings > Reading screen.

Parameters (1)

0. $component — Optional. (string) => ''
Name of the component to check for. Default: current component.

Usage

  1. if ( !function_exists( 'bp_is_component_front_page' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-template.php'; 
  3.  
  4. // Optional. Name of the component to check for. 
  5. // Default: current component. 
  6. $component = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_is_component_front_page($component); 
  10.  

Defined (1)

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

/bp-core/bp-core-template.php  
  1. function bp_is_component_front_page( $component = '' ) { 
  2. global $current_blog; 
  3.  
  4. $bp =buddypress); 
  5.  
  6. // Default to the current component if none is passed. 
  7. if ( empty( $component ) ) { 
  8. $component = bp_current_component(); 
  9.  
  10. // Get the path for the current blog/site. 
  11. $path = is_main_site() 
  12. : $current_blog->path; 
  13.  
  14. // Get the front page variables. 
  15. $show_on_front = get_option( 'show_on_front' ); 
  16. $page_on_front = get_option( 'page_on_front' ); 
  17.  
  18. if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) { 
  19. return false; 
  20.  
  21. /** 
  22. * Filters whether or not the specified BuddyPress component directory is set to be the front page. 
  23. * @since 1.5.0 
  24. * @param bool $value Whether or not the specified component directory is set as front page. 
  25. * @param string $component Current component being checked. 
  26. */ 
  27. return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );