Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/16/2014 01:05:35 PM (12 years ago)
Author:
boonebgorges
Message:

Introduce bp_activity_show_filters(), and use it for generating dynamic activity filter dropdowns

Activity filter dropdowns were previously hardcoded into templates, with
template-specific hooks for plugins to add their own filter values. This
resulted in an inconsistent and awkward process of maintaining filter lists
between components. The new method introduces new parameters to bp_activity_set_action():
$context (an array of the contexts in which the filter should appear) and
$label (the text that should be used when generating the <option> markup). The
new function bp_activity_show_filter() is then used in the templates to
generate a dynamic list of <option> markup, based on the values registered by
the activity types.

Fixes #5637

Props imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r8237 r8428  
    276276 * @param string $description The action description.
    277277 * @param callable $format_callback Callback for formatting the action string.
     278 * @param string $label String to describe this action in the activity stream
     279 *        filter dropdown.
     280 * @param array $context Activity stream contexts where the filter should appear.
     281 *        'activity', 'member', 'member_groups', 'group'
    278282 * @return bool False if any param is empty, otherwise true.
    279283 */
    280 function bp_activity_set_action( $component_id, $type, $description, $format_callback = false ) {
     284function bp_activity_set_action( $component_id, $type, $description, $format_callback = false, $label = false, $context = array() ) {
    281285    $bp = buddypress();
    282286
     
    304308        'value'           => $description,
    305309        'format_callback' => $format_callback,
    306     ), $component_id, $type, $description, $format_callback );
     310        'label'           => $label,
     311        'context'         => $context,
     312    ), $component_id, $type, $description, $format_callback, $label, $context );
    307313
    308314    return true;
     
    836842        'activity_update',
    837843        __( 'Posted a status update', 'buddypress' ),
    838         'bp_activity_format_activity_action_activity_update'
     844        'bp_activity_format_activity_action_activity_update',
     845        __( 'Updates', 'buddypress' ),
     846        array( 'activity', 'group', 'member', 'member_groups' )
    839847    );
    840848
     
    843851        'activity_comment',
    844852        __( 'Replied to a status update', 'buddypress' ),
    845         'bp_activity_format_activity_action_activity_comment'
     853        'bp_activity_format_activity_action_activity_comment',
     854        __( 'Activity Comments', 'buddypress' )
    846855    );
    847856
Note: See TracChangeset for help on using the changeset viewer.