bboss_global_search_helpers_cpts

Load search helpers for each searchable custom post type.

Description

(array) bboss_global_search_helpers_cpts( (array) $helpers ); 

Returns (array)

Parameters (1)

0. $helpers (array)
The helpers.

Usage

  1. if ( !function_exists( 'bboss_global_search_helpers_cpts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-global-search/includes/plugins/search-cpt/index.php'; 
  3.  
  4. // The helpers. 
  5. $helpers = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bboss_global_search_helpers_cpts($helpers); 
  9.  

Defined (1)

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

/includes/plugins/search-cpt/index.php  
  1. function bboss_global_search_helpers_cpts( $helpers ) { 
  2. /** 
  3. * Check which cpts we need to search. 
  4. * And create one helper class object for each. 
  5. */ 
  6. $searchable_types = buddyboss_global_search()->option('items-to-search'); 
  7.  
  8. foreach( $searchable_types as $searchable_type ) { 
  9. //if name starts with cpt- 
  10.  
  11. $pos = strpos( $searchable_type, 'cpt-' ); 
  12. if( $pos === 0 ) { 
  13. $cpt_name = str_replace( 'cpt-', '', $searchable_type ); 
  14. $cpt_obj = get_post_type_object( $cpt_name ); 
  15. //is cpt still valid? 
  16. if( $cpt_obj && !is_wp_error( $cpt_obj ) ) { 
  17. require_once BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR . 'includes/plugins/search-cpt/class.BBoss_Global_Search_CPT.php'; 
  18. $helpers[$searchable_type] = new BBoss_Global_Search_CPT( $cpt_name, $searchable_type ); 
  19.  
  20. return $helpers;