bp_get_activity_show_filters( string $context = '' )

Get available filters depending on the scope.

Description

Parameters

$context

(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

3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
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.