bp_get_name_from_root_slug( string $root_slug = '' )

Return the component name based on a root slug.


Description Description


Parameters Parameters

$root_slug

(Optional) Needle to our active component haystack.

Default value: ''


Top ↑

Return Return

(mixed) False if none found, component name if found.


Top ↑

Source Source

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

function bp_get_name_from_root_slug( $root_slug = '' ) {
	$bp = buddypress();

	// If no slug is passed, look at current_component.
	if ( empty( $root_slug ) ) {
		$root_slug = bp_current_component();
	}

	// No current component or root slug, so flee.
	if ( empty( $root_slug ) ) {
		return false;
	}

	// Loop through active components and look for a match.
	foreach ( array_keys( $bp->active_components ) as $component ) {
		if ( ( ! empty( $bp->{$component}->slug ) && ( $bp->{$component}->slug == $root_slug ) ) || ( ! empty( $bp->{$component}->root_slug ) && ( $bp->{$component}->root_slug === $root_slug ) ) ) {
			return $bp->{$component}->name;
		}
	}

	return false;
}

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.