bp_nouveau_current_object()

Get the current component or action.


Description Description

If on single group screens we need to switch from component to bp_current_action() to add the correct IDs/labels for group/activity & similar screens.


Source Source

File: bp-templates/bp-nouveau/includes/template-tags.php

function bp_nouveau_current_object() {
	/*
	 * If we're looking at groups single screens we need to factor in current action
	 * to avoid the component check adding the wrong id for the main dir e.g 'groups' instead of 'activity'.
	 * We also need to check for group screens to adjust the id's for prefixes.
	 */
	$component = array();

	if ( bp_is_group() ) {
		$component['members_select']   = 'groups_members-order-select';
		$component['members_order_by'] = 'groups_members-order-by';
		$component['object']           = bp_current_action();
		$component['data_filter']      = bp_current_action();

		if ( 'activity' !== bp_current_action() ) {
			/**
			 * If the Group's front page is not used, Activities are displayed on Group's home page.
			 * To make sure filters are behaving the right way, we need to override the component object
			 * and data filter to `activity`.
			 */
			if ( bp_is_group_activity() ) {
				$activity_id              = buddypress()->activity->id;
				$component['object']      = $activity_id;
				$component['data_filter'] = $activity_id;
			} else {
				$component['data_filter'] = 'group_' . bp_current_action();
			}
		}

	} else {
		$component_id = bp_current_component();
		if ( ! bp_is_directory() ) {
			$component_id = bp_core_get_active_components( array( 'slug' => $component_id ) );
			$component_id = reset( $component_id );
		}

		$data_filter  = $component_id;

		if ( 'friends' === $data_filter && bp_is_user_friend_requests() ) {
			$data_filter = 'friend_requests';
		}

		$component['members_select']   = 'members-order-select';
		$component['members_order_by'] = 'members-order-by';
		$component['object']           = $component_id;
		$component['data_filter']      = $data_filter;
	}

	return $component;
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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