cptui_taxonomy_tabs

Register our tabs for the Taxonomy screen.

Description

(array) cptui_taxonomy_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_taxonomy_tabs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/taxonomies.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_taxonomy_tabs($tabs, $current_page); 
  12.  

Defined (1)

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

/inc/taxonomies.php  
  1. function cptui_taxonomy_tabs( $tabs = array(), $current_page = '' ) { 
  2.  
  3. if ( 'taxonomies' === $current_page ) { 
  4. $taxonomies = cptui_get_taxonomy_data(); 
  5. $classes = array( 'nav-tab' ); 
  6.  
  7. $tabs['page_title'] = get_admin_page_title(); 
  8. $tabs['tabs'] = array(); 
  9. // Start out with our basic "Add new" tab. 
  10. $tabs['tabs']['add'] = array( 
  11. 'text' => esc_html__( 'Add New Taxonomy', 'custom-post-type-ui' ),  
  12. 'classes' => $classes,  
  13. 'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),  
  14. 'aria-selected' => 'false',  
  15. ); 
  16.  
  17. $action = cptui_get_current_action(); 
  18. if ( empty( $action ) ) { 
  19. $tabs['tabs']['add']['classes'][] = 'nav-tab-active'; 
  20. $tabs['tabs']['add']['aria-selected'] = 'true'; 
  21.  
  22. if ( ! empty( $taxonomies ) ) { 
  23.  
  24. if ( ! empty( $action ) ) { 
  25. $classes[] = 'nav-tab-active'; 
  26. $tabs['tabs']['edit'] = array( 
  27. 'text' => esc_html__( 'Edit Taxonomies', 'custom-post-type-ui' ),  
  28. 'classes' => $classes,  
  29. 'url' => esc_url( add_query_arg( array( 'action' => 'edit' ), cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),  
  30. 'aria-selected' => ( ! empty( $action ) ) ? 'true' : 'false',  
  31. ); 
  32.  
  33. $tabs['tabs']['view'] = array( 
  34. 'text' => esc_html__( 'View Taxonomies', 'custom-post-type-ui' ),  
  35. 'classes' => array( 'nav-tab' ), // Prevent notices. 
  36. 'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#taxonomies' ) ),  
  37. 'aria-selected' => 'false',  
  38. ); 
  39.  
  40. $tabs['tabs']['export'] = array( 
  41. 'text' => esc_html__( 'Import/Export Taxonomies', 'custom-post-type-ui' ),  
  42. 'classes' => array( 'nav-tab' ), // Prevent notices. 
  43. 'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools&action=taxonomies' ) ),  
  44. 'aria-selected' => 'false',  
  45. ); 
  46.  
  47. return $tabs;