bp_get_activity_filter_links( array|bool $args = false )

Return the activity filter links.

Description

Parameters

$args

(Optional)

  • 'style'
    (string) The type of markup to use for the links. 'list', 'paragraph', or 'span'. Default: 'list'.

Default value: false

Return

(string|bool) $component_links The activity filter links. False on failure.

Source

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

2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
function bp_get_activity_filter_links( $args = false ) {
 
    $r = wp_parse_args( $args, array(
        'style' => 'list'
    ) );
 
    // Define local variable.
    $component_links = array();
 
    // Fetch the names of components that have activity recorded in the DB.
    $components = BP_Activity_Activity::get_recorded_components();
 
    if ( empty( $components ) ) {
        return false;
    }
 
    foreach ( (array) $components as $component ) {
 
        // Skip the activity comment filter.
        if ( 'activity' == $component ) {
            continue;
        }
 
        if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) {
            $selected = ' class="selected"';
        } else {
            $selected = '';
        }
 
        $component = esc_attr( $component );
 
        switch ( $r['style'] ) {
            case 'list':
                $tag = 'li';
                $before = '<li id="afilter-' . $component . '"' . $selected . '>';
                $after = '</li>';
            break;
            case 'paragraph':
                $tag = 'p';
                $before = '<p id="afilter-' . $component . '"' . $selected . '>';
                $after = '</p>';
            break;
            case 'span':
                $tag = 'span';
                $before = '<span id="afilter-' . $component . '"' . $selected . '>';
                $after = '</span>';
            break;
        }
 
        $link = add_query_arg( 'afilter', $component );
        $link = remove_query_arg( 'acpage' , $link );
 
        /**
         * Filters the activity filter link URL for the current activity component.
         *
         * @since BuddyPress 1.1.0
         *
         * @param string $link      The URL for the current component.
         * @param string $component The current component getting links constructed for.
         */
        $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
 
        $component_links[] = $before . '<a href="' . esc_url( $link ) . '">' . ucwords( $component ) . '</a>' . $after;
    }
 
    $link = remove_query_arg( 'afilter' , $link );
 
    if ( isset( $_GET['afilter'] ) ) {
        $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddyboss' ) . '</a></' . $tag . '>';
    }
 
    /**
     * Filters all of the constructed filter links.
     *
     * @since BuddyPress 1.1.0
     * @since BuddyPress 2.6.0 Added the `$r` parameter.
     *
     * @param string $value All of the links to be displayed to the user.
     * @param array  $r     Array of parsed arguments.
     */
    return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ), $r );
}

Changelog

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