bb_tag_search

The BuddyPress bb tag search function.

Description

bb_tag_search( (string) $args = '' ); 

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Usage

  1. if ( !function_exists( 'bb_tag_search' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The args. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_tag_search($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_tag_search( $args = '' ) { 
  2. global $page, $wp_taxonomy_object; 
  3.  
  4. if ( $args && is_string($args) && false === strpos($args, '=') ) 
  5. $args = array( 'search' => $args ); 
  6.  
  7. $defaults = array( 'search' => '', 'number' => false ); 
  8.  
  9. $args = wp_parse_args( $args ); 
  10. if ( isset( $args['query'] ) ) 
  11. $args['search'] = $args['query']; 
  12. if ( isset( $args['tags_per_page'] ) ) 
  13. $args['number'] = $args['tags_per_page']; 
  14. unset($args['query'], $args['tags_per_page']); 
  15. $args = wp_parse_args( $args, $defaults ); 
  16.  
  17. extract( $args, EXTR_SKIP ); 
  18.  
  19. $number = (int) $number; 
  20. $search = trim( $search ); 
  21. if ( strlen( $search ) < 3 ) 
  22. return new WP_Error( 'invalid-query', __('Your search term was too short') ); 
  23.  
  24. $number = 0 < $number ? $number : bb_get_option( 'page_topics' ); 
  25. if ( 1 < $page ) 
  26. $offset = ( intval($page) - 1 ) * $number; 
  27.  
  28. $args = array_merge( $args, compact( 'number', 'offset', 'search' ) ); 
  29.  
  30. $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', $args ); 
  31. if ( is_wp_error( $terms ) ) 
  32. return false; 
  33.  
  34. for ( $i = 0; isset($terms[$i]); $i++ ) 
  35. _bb_make_tag_compat( $terms[$i] ); 
  36.  
  37. return $terms;