bboss_global_search_option_cpt_search

Print all custom post types on settings screen.

Description

bboss_global_search_option_cpt_search( (array) $items_to_search ); 

Parameters (1)

0. $items_to_search (array)
The items to search.

Usage

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

Defined (1)

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

/includes/plugins/search-cpt/index.php  
  1. function bboss_global_search_option_cpt_search( $items_to_search ) { 
  2. //all the cpts registered 
  3. $cpts = get_post_types( array( 'public'=>true, 'publicly_queryable'=>true, 'exclude_from_search'=>false ), 'objects' ); 
  4.  
  5. //remove posts 
  6. $cpts['post'] = null; 
  7. unset( $cpts['post'] ); 
  8.  
  9. //remove attachment 
  10. $cpts['attachment'] = null; 
  11. unset( $cpts['attachment'] ); 
  12.  
  13. $cpts = apply_filters( 'bboss_global_search_cpts_to_search', $cpts ); 
  14.  
  15. if( !empty( $cpts ) ) { 
  16. foreach( $cpts as $cpt=>$cpt_obj ) { 
  17. $checked = !empty( $items_to_search ) && in_array( 'cpt-' . $cpt, $items_to_search ) ? ' checked' : ''; 
  18. echo "<label><input type='checkbox' value='cpt-{$cpt}' name='buddyboss_global_search_plugin_options[items-to-search][]' {$checked}>{$cpt_obj->label}</label><br>";