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

	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.