admin管理员组文章数量:1415653
I create a new tab in my Buddypress groups like so:
bp_core_new_subnav_item( array(
'name' => "new tab <span>$count</span>",
'slug' => 'namings',
'parent_url' => $group_link,
'parent_slug' => $bp->groups->current_group->slug,
'screen_function' => 'bp_group_namings',
'position' => 50,
'user_has_access' => $user_access,
'item_css_id' => 'namings'
));
The $count
variable has a value. But, the span is consistently removed from the tab title.
How to get a count in the tab title?
I create a new tab in my Buddypress groups like so:
bp_core_new_subnav_item( array(
'name' => "new tab <span>$count</span>",
'slug' => 'namings',
'parent_url' => $group_link,
'parent_slug' => $bp->groups->current_group->slug,
'screen_function' => 'bp_group_namings',
'position' => 50,
'user_has_access' => $user_access,
'item_css_id' => 'namings'
));
The $count
variable has a value. But, the span is consistently removed from the tab title.
How to get a count in the tab title?
Share Improve this question asked Aug 28, 2019 at 23:35 MastaBabaMastaBaba 3113 silver badges12 bronze badges1 Answer
Reset to default 2You are using the BP Nouveau templates, correct? Span tag works fine in the Legacy templates.
In Nouveau, all links are stripped of span tags.
See the calls to function _bp_strip_spans_from_title
and functions like bp_nouveau_get_nav_link_text
in buddypress\bp-templates\bp-nouveau\includes\template-tags.php
.
So remove your span tag from the create subnav item function.
Instead, in Nouveau, use 2 filters for adding a count item.
So something like:
function masta_add_namings_count( $count, $nav_item, $displayed_nav ) {
if ( $displayed_nav == 'groups' ) {
if ( $nav_item->slug == 'namings' ) {
$count = true;
}
}
return $count;
}
add_filter( 'bp_nouveau_nav_has_count', 'masta_add_namings_count', 99, 3 );
function masta_add_namings_count_int( $count, $nav_item, $displayed_nav ) {
if ( $displayed_nav == 'groups' ) {
if ( $nav_item->slug == 'namings' ) {
$group_id = bp_get_current_group_id();
$count = 666; // pass the group_id to a function that returns the proper count
}
}
return $count;
}
add_filter( 'bp_nouveau_get_nav_count', 'masta_add_namings_count_int', 99, 3 );
本文标签: How to add a count in a custom tab in a Buddypress group
版权声明:本文标题:How to add a count in a custom tab in a Buddypress group 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745188956a2646817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论