bp_get_group_type_list( int $group_id, array|string $r = array() )
Return a comma-delimited list of group types.
Description
Parameters
- $group_id
-
(int) (Required) Group ID. Defaults to current group ID if on a group page.
- $r
-
(array|string) (Optional) Array of parameters. All items are optional.
- 'parent_element'
(string) Element to wrap around the list. Defaults to 'p'. - 'parent_attr'
(array) Element attributes for parent element. Defaults to array( 'class' => 'bp-group-type-list' ). - 'label'
(string) Label to add before the list. Defaults to 'Group Types:'. - 'label_element'
(string) Element to wrap around the label. Defaults to 'strong'. - 'label_attr'
(array) Element attributes for label element. Defaults to array(). - 'show_all'
(bool) Whether to show all registered group types. Defaults to 'false'. If 'false', only shows group types with the 'show_in_list' parameter set to true. See bp_groups_register_group_type() for more info.
Default value: array()
- 'parent_element'
Return
(string)
Source
File: bp-groups/bp-groups-template.php
function bp_get_group_type_list( $group_id = 0, $r = array() ) { if ( empty( $group_id ) ) { $group_id = bp_get_current_group_id(); } $r = bp_parse_args( $r, array( 'parent_element' => 'p', 'parent_attr' => array( 'class' => 'bp-group-type-list', ), 'label' => __( 'Group Types:', 'buddyboss' ), 'label_element' => 'strong', 'label_attr' => array(), 'show_all' => false, ), 'group_type_list' ); $retval = ''; if ( $types = bp_groups_get_group_type( $group_id, false ) ) { // Make sure we can show the type in the list. if ( false === $r['show_all'] ) { $types = array_intersect( bp_groups_get_group_types( array( 'show_in_list' => true ) ), $types ); if ( empty( $types ) ) { return $retval; } } $before = $after = $label = ''; // Render parent element. if ( ! empty( $r['parent_element'] ) ) { $parent_elem = new BP_Core_HTML_Element( array( 'element' => $r['parent_element'], 'attr' => $r['parent_attr'] ) ); // Set before and after. $before = $parent_elem->get( 'open_tag' ); $after = $parent_elem->get( 'close_tag' ); } // Render label element. if ( ! empty( $r['label_element'] ) ) { $label = new BP_Core_HTML_Element( array( 'element' => $r['label_element'], 'attr' => $r['label_attr'], 'inner_html' => esc_html( $r['label'] ) ) ); $label = $label->contents() . ' '; // No element, just the label. } else { $label = esc_html( $r['label'] ); } // Comma-delimit each type into the group type directory link. $label .= implode( ', ', array_map( 'bp_get_group_type_directory_link', $types ) ); // Retval time! $retval = $before . $label . $after; } return $retval; }
Changelog
Version | Description |
---|---|
BuddyPress 2.7.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.