bp_is_component_front_page( string $component = '' )
Check if the specified BuddyPress component directory is set to be the front page.
Description
Corresponds to the setting in wp-admin’s Settings > Reading screen.
Parameters
- $component
-
(Optional) Name of the component to check for. Default: current component.
Default value: ''
Return
(bool) True if the specified component is set to be the site's front page, otherwise false.
Source
File: bp-core/bp-core-template.php
function bp_is_component_front_page( $component = '' ) { global $current_blog; $bp = buddypress(); // Default to the current component if none is passed. if ( empty( $component ) ) { $component = bp_current_component(); } // Get the path for the current blog/site. $path = is_main_site() ? bp_core_get_site_path() : $current_blog->path; // Get the front page variables. $show_on_front = get_option( 'show_on_front' ); $page_on_front = get_option( 'page_on_front' ); if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) { return false; } /** * Filters whether or not the specified BuddyPress component directory is set to be the front page. * * @since BuddyPress 1.5.0 * * @param bool $value Whether or not the specified component directory is set as front page. * @param string $component Current component being checked. */ return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component ); }
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.