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 Description

This function is on the chopping block. It’s currently only used by a few already deprecated functions.


Parameters Parameters

$component_name

(Optional) Component name to check.

Default value: ''


Top ↑

Return Return

(bool) True if root component, else false.


Top ↑

Source Source

File: bp-core/bp-core-template.php

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 2.1.0
	 *
	 * @param bool $retval Whether or not URL should be in the root.
	 */
	return (bool) apply_filters( 'bp_is_root_component', $retval );
}

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.