BBoss_Global_Search_bbPress

BuddyPress Global Search - search bbPress **************************************.

Defined (1)

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

/includes/abstracts/class.BBoss_Global_Search_bbPress.php  
  1. abstract class BBoss_Global_Search_bbPress extends BBoss_Global_Search_Type { 
  2. public $type; 
  3.  
  4. function sql( $search_term, $only_totalrow_count=false ) { 
  5. global $wpdb; 
  6. $query_placeholder = array(); 
  7.  
  8. $sql = " SELECT "; 
  9.  
  10. if( $only_totalrow_count ) { 
  11. $sql .= " COUNT( DISTINCT id ) "; 
  12. } else { 
  13. $sql .= " DISTINCT id , '{$this->type}' as type, post_title LIKE '%%%s%%' AS relevance, post_date as entry_date "; 
  14. $query_placeholder[] = $search_term; 
  15.  
  16. $sql .= " FROM  
  17. {$wpdb->prefix}posts  
  18. WHERE  
  19. 1=1  
  20. AND ( 
  21. (post_title LIKE '%%%s%%') 
  22. OR (post_content LIKE '%%%s%%') 
  23. )  
  24. AND post_type = '{$this->type}' 
  25. AND post_status = 'publish'  
  26. "; 
  27. $query_placeholder[] = $search_term; 
  28. $query_placeholder[] = $search_term; 
  29. $sql = $wpdb->prepare( $sql, $query_placeholder ); 
  30.  
  31. return apply_filters(  
  32. 'BBoss_Global_Search_Forums_sql',  
  33. $sql,  
  34. array(  
  35. 'search_term' => $search_term,  
  36. 'only_totalrow_count' => $only_totalrow_count,  
  37. )  
  38. ); 
  39.  
  40. protected function generate_html( $template_type='' ) { 
  41. $post_ids = array(); 
  42. foreach( $this->search_results['items'] as $item_id=>$item_html ) { 
  43. $post_ids[] = $item_id; 
  44.  
  45. //now we have all the posts 
  46. //lets do a wp_query and generate html for all posts 
  47. $qry = new WP_Query( array( 'post_type' =>array( 'forum', 'topic', 'reply' ), 'post__in'=>$post_ids ) ); 
  48. if( $qry->have_posts() ) { 
  49. while( $qry->have_posts() ) { 
  50. $qry->the_post(); 
  51.  
  52. /** 
  53. * The following will try to load loop/forum.php, loop/topic.php loop/reply.php(if reply is included). 
  54. *  
  55. */ 
  56. $result_item = array( 
  57. 'id' => get_the_ID(),  
  58. 'type' => $this->type,  
  59. 'title' => get_the_title(),  
  60. 'html' => buddyboss_global_search_buffer_template_part( 'loop/' . $this->type, $template_type, false ),  
  61. ); 
  62.  
  63. $this->search_results['items'][get_the_ID()] = $result_item; 
  64. wp_reset_postdata(); 
  65.