-
-
Save imath/f36855ca5d000206696a0204e7cbb6ea to your computer and use it in GitHub Desktop.
See https://buddypress.org/support/topic/buddypress-7-0-0-filippi/ for context..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Needs https://fr.wordpress.org/plugins/bp-create-group-type/ to be active. | |
function alersn_set_group_type_tabs( $tabs = array() ) { | |
$group_types = bp_groups_get_group_types( array( 'has_directory' => true ), 'objects' ); | |
$terms_count = get_terms( | |
array( | |
'taxonomy' => bp_get_group_type_tax_name(), | |
'include' => wp_list_pluck( $group_types, 'db_id' ), | |
'hide_empty' => false, | |
'count' => true, | |
) | |
); | |
$group_types_count = wp_list_pluck( $terms_count, 'count', 'term_id' ); | |
foreach ( $group_types as $type_id => $type ) { | |
$count = 0; | |
if ( isset( $group_types_count[ $type->db_id ] ) ) { | |
$count = $group_types_count[ $type->db_id ]; | |
} | |
$tabs[ $type_id ] = array( | |
'component' => 'groups', | |
'slug' => esc_attr( $type->directory_slug ), | |
'li_class' => array( 'bpgt-type-tab' ), | |
'link' => bp_get_groups_directory_permalink(), | |
'text' => esc_attr( $type->name ), | |
'count' => bp_core_number_format( $count ), | |
); | |
} | |
return $tabs; | |
} | |
add_action( 'bp_nouveau_get_groups_directory_nav_items', 'alersn_set_group_type_tabs' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment