BP_Search::print_tabs()
Description
Source
File: bp-search/classes/class-bp-search.php
public function print_tabs() {
// No tabs if 0 results
if ( $this->search_results['all']['total_match_count'] < 1 ) {
//return;
}
$search_url = $this->search_page_search_url();
//first print the 'all results' tab
$class = 'all' == $this->search_args['search_subset'] ? 'active current selected' : '';
//this filter can be used to change display of 'all' to 'Everything' etc..
$all_label = __( 'All Results', 'buddyboss' );
$label = apply_filters( 'bp_search_label_search_type', $all_label );
if ( $this->search_args['count_total'] && isset( $this->search_results['all'] ) ) {
$label .= "<span class='count'>" . $this->search_results['all']['total_match_count'] . "</span>";
}
$tab_url = $search_url;
echo "<li class='{$class}'><a href='" . esc_url( $tab_url ) . "'>{$label}</a></li>";
//then other tabs
$search_items = bp_search_items();
foreach ( $this->searchable_items as $item ) {
$class = $item == $this->search_args['search_subset'] ? 'active current' : '';
//this filter can be used to change display of 'posts' to 'Blog Posts' etc..
$label = isset ( $search_items[ $item ] ) ? $search_items[ $item ] : $item;
$label = apply_filters( 'bp_search_label_search_type', $label );
if ( empty( $this->search_results[ $item ]['total_match_count'] ) ) {
continue; //skip tab
}
if ( $this->search_args['count_total'] ) {
$label .= "<span class='count'>" . (int) $this->search_results[ $item ]['total_match_count'] . "</span>";
}
$tab_url = esc_url( add_query_arg( 'subset', $item, $search_url ) );
echo "<li class='{$class} {$item}' data-item='{$item}'><a href='" . esc_url( $tab_url ) . "'>{$label}</a></li>";
}
}
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.