bp_get_activity_show_filters( string $context = '' )

Get available filters depending on the scope.


Parameters Parameters

$context

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

Default value: ''


Top ↑

Return Return

(string) HTML for <option> values.


Source 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 ) {
			// Friends activity collapses two filters into one.
			if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
				$action['key'] = 'friendship_accepted,friendship_created';
			}

			// The 'activity_update' filter is already used by the Activity component.
			if ( 'bp_groups_format_activity_action_group_activity_update' === $action['format_callback'] ) {
				continue;
			}

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

		/**
		 * Filters the options available in the activity filter dropdown.
		 *
		 * @since 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 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 );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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