Changeset 6502 for trunk/bp-activity/bp-activity-template.php
- Timestamp:
- 11/09/2012 03:42:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-template.php
r6501 r6502 2553 2553 2554 2554 2555 /** 2556 * Renders a list of all the registered activity types for use in a <select> element, or as <input type="checkbox">. 2557 * 2558 * @param string $output Optional. Either 'select' or 'checkbox'. Defaults to select. 2559 * @param string|array $args Optional extra arguments: 2560 * checkbox_name - Used when type=checkbox. Sets the item's name property. 2561 * selected - Array of strings of activity types to mark as selected/checked. 2562 * @since BuddyPress (1.7) 2563 */ 2564 function bp_activity_types_list( $output = 'select', $args = '' ) { 2565 $defaults = array( 2566 'checkbox_name' => 'bp_activity_types', 2567 'selected' => array(), 2568 ); 2569 $args = wp_parse_args( $args, $defaults ); 2570 2571 $activities = bp_activity_get_types(); 2572 natsort( $activities ); 2573 2574 // Loop through the activity types and output markup 2575 foreach ( $activities as $type => $description ) { 2576 2577 // See if we need to preselect the current type 2578 $checked = checked( true, in_array( $type, (array) $args['selected'] ), false ); 2579 $selected = selected( true, in_array( $type, (array) $args['selected'] ), false ); 2580 2581 if ( 'select' == $output ) 2582 printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $type ), $selected, esc_html( $description ) ); 2583 2584 elseif ( 'checkbox' == $output ) 2585 printf( '<label style="">%1$s<input type="checkbox" name="%2$s[]" value="%3$s" %4$s/></label>', esc_html( $description ), esc_attr( $args['checkbox_name'] ), esc_attr( $type ), $checked ); 2586 2587 // Allow custom markup 2588 do_action( 'bp_activity_types_list_' . $output, $args, $type, $description ); 2589 } 2590 2591 // Backpat with BP-Default for dropdown boxes only 2592 if ( 'select' == $output ) 2593 do_action( 'bp_activity_filter_options' ); 2594 } 2595 2596 2555 2597 /* RSS Feed Template Tags ****************************************************/ 2556 2598
Note: See TracChangeset
for help on using the changeset viewer.