/includes/template.php

  1. <?php  
  2. // Exit if accessed directly 
  3. if ( ! defined( 'ABSPATH' ) ) exit; 
  4.  
  5. add_filter( 'the_content', 'buddyboss_global_search_search_page_content', 9 ); 
  6.  
  7. function buddyboss_global_search_search_page_content( $content ) { 
  8. /** 
  9. * Reportedly, on some installations, the remove_filter call below, doesn't work and this filter is called over and over again. 
  10. * Possibly due to some other plugin/theme. 
  11. *  
  12. * Lets add another precautionary measure, a global flag. 
  13. * @since 1.1.3 
  14. */ 
  15. global $bpgs_main_content_filter_has_run; 
  16.  
  17. if( !is_admin() && is_search() && 'yes' != $bpgs_main_content_filter_has_run ) { 
  18. remove_filter( 'the_content', 'buddyboss_global_search_search_page_content', 9 ); 
  19. $bpgs_main_content_filter_has_run = 'yes'; 
  20. //setup search resutls and all.. 
  21. buddyboss_global_search()->search->prepare_search_page(); 
  22. $content .= buddyboss_global_search_buffer_template_part( 'results-page', '', false ); 
  23.  
  24. return $content; 
  25.  
  26. function buddyboss_global_search_load_template( $template, $variation=false ) { 
  27. $file = $template; 
  28.  
  29. if( $variation ) { 
  30. $file .= '-' . $variation; 
  31. $file .= '.php'; 
  32.  
  33. $file_found = false; 
  34. //first try to load template-variation.php 
  35. if( file_exists(STYLESHEETPATH.'/buddypress-global-search/'.$file ) ) { 
  36. include (STYLESHEETPATH.'/buddypress-global-search/'.$file); 
  37. $file_found = true; 
  38. } else if(file_exists(TEMPLATEPATH.'/buddypress-global-search/'.$file)) { 
  39. include (TEMPLATEPATH.'/buddypress-global-search/'.$file); 
  40. $file_found = true; 
  41. } else if(file_exists(BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR.'templates/'.$file)) { 
  42. include (BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR.'templates/'.$file); 
  43. $file_found = true; 
  44.  
  45. if( !$file_found && $variation != '' ) { 
  46. //then try to load template.php 
  47. $file = $template . '.php'; 
  48. if( file_exists(STYLESHEETPATH.'/buddypress-global-search/'.$file ) ) { 
  49. include (STYLESHEETPATH.'/buddypress-global-search/'.$file); 
  50. } else if(file_exists(TEMPLATEPATH.'/buddypress-global-search/'.$file)) { 
  51. include (TEMPLATEPATH.'/buddypress-global-search/'.$file); 
  52. } else if(file_exists(BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR.'templates/'.$file)) { 
  53. include (BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR.'templates/'.$file); 
  54.  
  55. function buddyboss_global_search_buffer_template_part( $template, $variation='', $echo=true ) { 
  56. ob_start(); 
  57.  
  58. buddyboss_global_search_load_template( $template, $variation ); 
  59. // Get the output buffer contents 
  60. $output = ob_get_clean(); 
  61.  
  62. // Echo or return the output buffer contents 
  63. if ( true === $echo ) { 
  64. echo $output; 
  65. } else { 
  66. return $output; 
  67.  
  68. function buddyboss_global_search_filters() { 
  69. buddyboss_global_search()->search->print_tabs(); 
  70.  
  71. function buddyboss_global_search_results() { 
  72. buddyboss_global_search()->search->print_results(); 
.