cptui_tools_tabs

Register our tabs for the Tools screen.

Description

(array) cptui_tools_tabs( (array) $tabs = array(), (string) $current_page = '' ); 

Returns (array)

Amended array of tabs to show.

Parameters (2)

0. $tabs — Optional. (array) => array()
Array of tabs to display. Optional.
1. $current_page — Optional. (string) => ''
Current page being shown. Optional. Default empty string.

Usage

  1. if ( !function_exists( 'cptui_tools_tabs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/tools.php'; 
  3.  
  4. // Array of tabs to display. Optional. 
  5. $tabs = array(); 
  6.  
  7. // Current page being shown. Optional. Default empty string. 
  8. $current_page = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = cptui_tools_tabs($tabs, $current_page); 
  12.  

Defined (1)

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

/inc/tools.php  
  1. function cptui_tools_tabs( $tabs = array(), $current_page = '' ) { 
  2.  
  3. if ( 'tools' === $current_page ) { 
  4. $classes = array( 'nav-tab' ); 
  5.  
  6. $tabs['page_title'] = get_admin_page_title(); 
  7. $tabs['tabs'] = array(); 
  8. $tabs['tabs']['post_types'] = array( 
  9. 'text' => __( 'Post Types', 'custom-post-type-ui' ),  
  10. 'classes' => $classes,  
  11. 'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),  
  12. 'aria-selected' => 'false',  
  13. ); 
  14.  
  15. $tabs['tabs']['taxonomies'] = array( 
  16. 'text' => __( 'Taxonomies', 'custom-post-type-ui' ),  
  17. 'classes' => $classes,  
  18. 'url' => esc_url( add_query_arg( array( 'action' => 'taxonomies' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),  
  19. 'aria-selected' => 'false',  
  20. ); 
  21.  
  22. $tabs['tabs']['get_code'] = array( 
  23. 'text' => __( 'Get Code', 'custom-post-type-ui' ),  
  24. 'classes' => $classes,  
  25. 'url' => esc_url( add_query_arg( array( 'action' => 'get_code' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),  
  26. 'aria-selected' => 'false',  
  27. ); 
  28.  
  29. $tabs['tabs']['debuginfo'] = array( 
  30. 'text' => __( 'Debug Info', 'custom-post-type-ui' ),  
  31. 'classes' => $classes,  
  32. 'url' => esc_url( add_query_arg( array( 'action' => 'debuginfo' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),  
  33. 'aria-selected' => 'false',  
  34. ); 
  35.  
  36. $active_class = 'nav-tab-active'; 
  37. $action = cptui_get_current_action(); 
  38. if ( ! empty( $action ) ) { 
  39. if ( 'taxonomies' === $action ) { 
  40. $tabs['tabs']['taxonomies']['classes'][] = $active_class; 
  41. $tabs['tabs']['taxonomies']['aria-selected'] = 'true'; 
  42. } elseif ( 'get_code' === $action ) { 
  43. $tabs['tabs']['get_code']['classes'][] = $active_class; 
  44. $tabs['tabs']['get_code']['aria-selected'] = 'true'; 
  45. } elseif ( 'debuginfo' === $action ) { 
  46. $tabs['tabs']['debuginfo']['classes'][] = $active_class; 
  47. $tabs['tabs']['debuginfo']['aria-selected'] = 'true'; 
  48. } else { 
  49. $tabs['tabs']['post_types']['classes'][] = $active_class; 
  50. $tabs['tabs']['post_types']['aria-selected'] = 'true'; 
  51.  
  52. /** 
  53. * Filters the tabs being added for the tools area. 
  54. * @since 1.5.0 
  55. * @param array $tabs Array of tabs to show. 
  56. * @param string $action Current tab being shown. 
  57. * @param string $active_class Class to use to mark the tab active. 
  58. */ 
  59. $tabs = apply_filters( 'cptui_tools_tabs', $tabs, $action, $active_class ); 
  60.  
  61. return $tabs;