bp_is_component_front_page( string $component = '' )

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


Description Description

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


Parameters Parameters

$component

(Optional) Name of the component to check for. Default: current component.

Default value: ''


Top ↑

Return Return

(bool) True if the specified component is set to be the site's front page, otherwise false.


Top ↑

Source 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 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 );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.