bp_get_activity_filter_links

Return the activity filter links.

Description

(string|bool) bp_get_activity_filter_links( (bool) $args = false ); 

Returns (string|bool)

$component_links The activity filter links. False on failure.

Parameters (1)

0. $args — Optional. (bool) => false
The args.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_get_activity_filter_links' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
    3.  
    4. // The args. 
    5. $args = false; 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_get_activity_filter_links($args); 
    9.  

    Defined (1)

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

    /bp-activity/bp-activity-template.php  
    1. function bp_get_activity_filter_links( $args = false ) { 
    2.  
    3. $r = wp_parse_args( $args, array( 
    4. 'style' => 'list' 
    5. ) ); 
    6.  
    7. // Define local variable. 
    8. $component_links = array(); 
    9.  
    10. // Fetch the names of components that have activity recorded in the DB. 
    11. $components = BP_Activity_Activity::get_recorded_components(); 
    12.  
    13. if ( empty( $components ) ) { 
    14. return false; 
    15.  
    16. foreach ( (array) $components as $component ) { 
    17.  
    18. // Skip the activity comment filter. 
    19. if ( 'activity' == $component ) { 
    20. continue; 
    21.  
    22. if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) { 
    23. $selected = ' class="selected"'; 
    24. } else { 
    25. $selected = ''; 
    26.  
    27. $component = esc_attr( $component ); 
    28.  
    29. switch ( $r['style'] ) { 
    30. case 'list': 
    31. $tag = 'li'; 
    32. $before = '<li id="afilter-' . $component . '"' . $selected . '>'; 
    33. $after = '</li>'; 
    34. break; 
    35. case 'paragraph': 
    36. $tag = 'p'; 
    37. $before = '<p id="afilter-' . $component . '"' . $selected . '>'; 
    38. $after = '</p>'; 
    39. break; 
    40. case 'span': 
    41. $tag = 'span'; 
    42. $before = '<span id="afilter-' . $component . '"' . $selected . '>'; 
    43. $after = '</span>'; 
    44. break; 
    45.  
    46. $link = add_query_arg( 'afilter', $component ); 
    47. $link = remove_query_arg( 'acpage' , $link ); 
    48.  
    49. /** 
    50. * Filters the activity filter link URL for the current activity component. 
    51. * @since 1.1.0 
    52. * @param string $link The URL for the current component. 
    53. * @param string $component The current component getting links constructed for. 
    54. */ 
    55. $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component ); 
    56.  
    57. $component_links[] = $before . '<a href="' . esc_url( $link ) . '">' . ucwords( $component ) . '</a>' . $after; 
    58.  
    59. $link = remove_query_arg( 'afilter' , $link ); 
    60.  
    61. if ( isset( $_GET['afilter'] ) ) { 
    62. $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', buddypress ) . '</a></' . $tag . '>'; 
    63.  
    64. /** 
    65. * Filters all of the constructed filter links. 
    66. * @since 1.1.0 
    67. * @since 2.6.0 Added the `$r` parameter. 
    68. * @param string $value All of the links to be displayed to the user. 
    69. * @param array $r Array of parsed arguments. 
    70. */ 
    71. return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ), $r );