bp_get_activity_show_filters

Get available filters depending on the scope.

Description

(string) bp_get_activity_show_filters( (string) $context = '' ); 

Returns (string)

HTML for

Parameters (1)

0. $context — Optional. (string) => ''
The current context. activity,, member., member_groups, group.

Usage

  1. if ( !function_exists( 'bp_get_activity_show_filters' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
  3.  
  4. // The current context. 'activity', 'member', 
  5. // 'member_groups', 'group'. 
  6. $context = ''; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_get_activity_show_filters($context); 
  10.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-template.php  
  1. function bp_get_activity_show_filters( $context = '' ) { 
  2. $filters = array(); 
  3. $actions = bp_activity_get_actions_for_context( $context ); 
  4. foreach ( $actions as $action ) { 
  5. // Friends activity collapses two filters into one. 
  6. if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) { 
  7. $action['key'] = 'friendship_accepted, friendship_created'; 
  8.  
  9. $filters[ $action['key'] ] = $action['label']; 
  10.  
  11. /** 
  12. * Filters the options available in the activity filter dropdown. 
  13. * @since 2.2.0 
  14. * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name. 
  15. * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'. 
  16. */ 
  17. $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context ); 
  18.  
  19. // Build the options output. 
  20. $output = ''; 
  21.  
  22. if ( ! empty( $filters ) ) { 
  23. foreach ( $filters as $value => $filter ) { 
  24. $output .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $filter ) . '</option>' . "\n"; 
  25.  
  26. /** 
  27. * Filters the HTML markup result for the activity filter dropdown. 
  28. * @since 2.1.0 
  29. * @param string $output HTML output for the activity filter dropdown. 
  30. * @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name. 
  31. * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'. 
  32. */ 
  33. return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );