bboss_global_search_label_search_type_cpts

Change the display text of custom post type search tabs.

Description

(string) bboss_global_search_label_search_type_cpts( (string) $search_type_label ); 

Change it from cpt-movie to Movies for example.

Returns (string)

Parameters (1)

0. $search_type_label (string)
The search type label.

Usage

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

Defined (1)

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

/includes/plugins/search-cpt/index.php  
  1. function bboss_global_search_label_search_type_cpts( $search_type_label ) { 
  2. /** 
  3. * search type is 'cpt-movie', 'cpt-book' etc. 
  4. * so removing 'cpt-' gives us the custom post type name 
  5. */ 
  6.  
  7. //Return label from admin search items options 
  8. if ( isset( $items[$search_type_label] ) ) { 
  9. return $items[$search_type_label]; 
  10.  
  11. $pos = strpos( $search_type_label, 'cpt-' ); 
  12. if( $pos === 0 ) { 
  13. $cpt_name = str_replace( 'cpt-', '', $search_type_label ); 
  14.  
  15. $cpt_obj = get_post_type_object( $cpt_name ); 
  16. if( $cpt_obj && !is_wp_error( $cpt_obj ) ) { 
  17. $search_type_label = $cpt_obj->label; 
  18.  
  19. $pos = strpos( $search_type_label, 'Cpt-' ); 
  20. if( $pos === 0 ) { 
  21. $cpt_name = str_replace( 'Cpt-', '', $search_type_label ); 
  22.  
  23. $cpt_obj = get_post_type_object( $cpt_name ); 
  24. if( $cpt_obj && !is_wp_error( $cpt_obj ) ) { 
  25. $search_type_label = $cpt_obj->label; 
  26. return $search_type_label;