bp_get_activity_show_filters( string $context = '' )

Get available filters depending on the scope.

Description

Parameters

$context

(string) (Optional) The current context. 'activity', 'member', 'member_groups', 'group'.

Default value: ''

Return

(string) HTML for <option> values.

Source

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

	function bp_get_activity_show_filters( $context = '' ) {
		$filters = array();
		$actions = bp_activity_get_actions_for_context( $context );
		foreach ( $actions as $action ) {
			// Connections activity collapses two filters into one.
			if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
				$action['key'] = 'friendship_accepted,friendship_created';
			}

			$filters[ $action['key'] ] = $action['label'];
		}

		/**
		 * Filters the options available in the activity filter dropdown.
		 *
		 * @since BuddyPress 2.2.0
		 *
		 * @param array  $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
		 * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
		 */
		$filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );

		// Build the options output.
		$output = '';

		if ( ! empty( $filters ) ) {
			foreach ( $filters as $value => $filter ) {
				$output .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $filter ) . '</option>' . "\n";
			}
		}

		/**
		 * Filters the HTML markup result for the activity filter dropdown.
		 *
		 * @since BuddyPress 2.1.0
		 *
		 * @param string $output  HTML output for the activity filter dropdown.
		 * @param array  $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
		 * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
		 */
		return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );
	}

Changelog

Changelog
Version Description
BuddyPress 2.1.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.