bb_global_search_default_items_to_search

Get the default items to search though, if nothing has been selected in settings.

Description

bb_global_search_default_items_to_search( (mixed) $value ); 

Parameters (1)

0. $value (mixed)
The value.

Usage

  1. if ( !function_exists( 'bb_global_search_default_items_to_search' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-global-search/includes/filters.php'; 
  3.  
  4. // The value. 
  5. $value = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_global_search_default_items_to_search($value); 
  9.  

Defined (1)

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

/includes/filters.php  
  1. function bb_global_search_default_items_to_search( $value ) { 
  2. if( empty( $value ) ) { 
  3. /** 
  4. * Setting > what to search? 
  5. * If admin has not selected anything yet( right after activating the plugin maybe),  
  6. * lets make sure search results do return someting at least. 
  7. * So, by default, we'll search though blog posts and members. 
  8. */ 
  9. $value = array( 'posts', 'members' ); 
  10.  
  11. /** 
  12. * If member search is turned on, but none ofwp_usertable fields or xprofile fields are selected,  
  13. * we'll force username and nicename fields 
  14. */ 
  15. if( in_array( 'members', $value ) ) { 
  16. // Is anywp_usertable colum or xprofile field selected? 
  17. $field_selected = false; 
  18. foreach( $value as $item_to_search ) { 
  19. if( strpos( $item_to_search, 'member_field_' )===0 || strpos( $item_to_search, 'xprofile_field_' )===0 ) { 
  20. $field_selected = true; 
  21. break; 
  22.  
  23. //if not, lets add username and nicename to default items to search 
  24. if( !$field_selected ) { 
  25. $value[] = 'member_field_user_login'; 
  26. $value[] = 'member_field_user_nicename'; 
  27.  
  28. return $value;