cptui_get_single_taxonomy_registery

Create output for single taxonomy to be ready for copy/paste from Get Code.

Description

cptui_get_single_taxonomy_registery( (array) $taxonomy = array() ); 

Parameters (1)

0. $taxonomy — Optional. (array) => array()
Taxonomy data to output. Optional.

Usage

  1. if ( !function_exists( 'cptui_get_single_taxonomy_registery' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/tools.php'; 
  3.  
  4. // Taxonomy data to output. Optional. 
  5. $taxonomy = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = cptui_get_single_taxonomy_registery($taxonomy); 
  9.  

Defined (1)

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

/inc/tools.php  
  1. function cptui_get_single_taxonomy_registery( $taxonomy = array() ) { 
  2.  
  3. $post_types = "''"; 
  4. if ( is_array( $taxonomy['object_types'] ) ) { 
  5. $post_types = 'array( "' . implode( '", "', $taxonomy['object_types'] ) . '" )'; 
  6.  
  7. if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) { 
  8. $rewrite = disp_boolean( $taxonomy['rewrite'] ); 
  9.  
  10. $rewrite_slug = ' \'slug\' => \'' . $taxonomy['name'] . '\', '; 
  11. if ( ! empty( $taxonomy['rewrite_slug'] ) ) { 
  12. $rewrite_slug = ' \'slug\' => \'' . $taxonomy['rewrite_slug'] . '\', '; 
  13.  
  14. $rewrite_withfront = ''; 
  15. $withfront = disp_boolean( $taxonomy['rewrite_withfront'] ); 
  16. if ( ! empty( $withfront ) ) { 
  17. $rewrite_withfront = ' \'with_front\' => ' . $withfront . ', '; 
  18.  
  19. $hierarchical = ( ! empty( $taxonomy['rewrite_hierarchical'] ) ) ? disp_boolean( $taxonomy['rewrite_hierarchical'] ) : ''; 
  20. $rewrite_hierarchcial = ''; 
  21. if ( ! empty( $hierarchical ) ) { 
  22. $rewrite_hierarchcial = ' \'hierarchical\' => ' . $hierarchical . ', '; 
  23.  
  24. if ( ! empty( $taxonomy['rewrite_slug'] ) || false !== disp_boolean( $taxonomy['rewrite_withfront'] ) ) { 
  25. $rewrite_start = 'array('; 
  26. $rewrite_end = ')'; 
  27.  
  28. $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_hierarchcial . $rewrite_end; 
  29. } else { 
  30. $rewrite = disp_boolean( $taxonomy['rewrite'] ); 
  31. $public = ( isset( $taxonomy['public'] ) ) ? disp_boolean( $taxonomy['public'] ) : 'true'; 
  32. $show_in_quick_edit = ( isset( $taxonomy['show_in_quick_edit'] ) ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] ); 
  33.  
  34. $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false'; 
  35. if ( empty( $taxonomy['show_in_menu'] ) ) { 
  36. $show_in_menu = disp_boolean( $taxonomy['show_ui'] ); 
  37.  
  38. $show_in_nav_menus = ( ! empty( $taxonomy['show_in_nav_menus'] ) && false !== get_disp_boolean( $taxonomy['show_in_nav_menus'] ) ) ? 'true' : 'false'; 
  39. if ( empty( $taxonomy['show_in_nav_menus'] ) ) { 
  40. $show_in_nav_menus = $public; 
  41.  
  42. $my_theme = wp_get_theme(); 
  43. $textdomain = $my_theme->get( 'TextDomain' ); 
  44. ?> 
  45.  
  46. /** 
  47. * Taxonomy: <?php echo $taxonomy['label']; ?>. 
  48. */ 
  49.  
  50. $labels = array( 
  51. "name" => __( '<?php echo $taxonomy['label']; ?>', '<?php echo $textdomain; ?>' ),  
  52. "singular_name" => __( '<?php echo $taxonomy['singular_label']; ?>', '<?php echo $textdomain; ?>' ),  
  53. <?php 
  54. foreach ( $taxonomy['labels'] as $key => $label ) { 
  55. if ( ! empty( $label ) ) { 
  56. echo "\t\t" . '"' . $key . '" => __( \'' . $label . '\', \'' . $textdomain . '\' ), ' . "\n"; 
  57. ?> 
  58. ); 
  59.  
  60. $args = array( 
  61. "label" => __( '<?php echo $taxonomy['label']; ?>', '<?php echo $textdomain; ?>' ),  
  62. "labels" => $labels,  
  63. "public" => <?php echo $public; ?>,  
  64. "hierarchical" => <?php echo $taxonomy['hierarchical']; ?>,  
  65. "label" => "<?php echo $taxonomy['label']; ?>",  
  66. "show_ui" => <?php echo disp_boolean( $taxonomy['show_ui'] ); ?>,  
  67. "show_in_menu" => <?php echo $show_in_menu; ?>,  
  68. "show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,  
  69. "query_var" => <?php echo disp_boolean( $taxonomy['query_var'] );?>,  
  70. "rewrite" => <?php echo $rewrite; ?>,  
  71. "show_admin_column" => <?php echo $taxonomy['show_admin_column']; ?>,  
  72. "show_in_rest" => <?php echo disp_boolean( $taxonomy['show_in_rest'] ); ?>,  
  73. "rest_base" => "<?php echo $taxonomy['rest_base']; ?>",  
  74. "show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,  
  75. ); 
  76. register_taxonomy( "<?php echo $taxonomy['name']; ?>", <?php echo $post_types; ?>, $args ); 
  77. <?php