cptui_post_types_dropdown

Construct a dropdown of our post types so users can select which to edit.

Description

cptui_post_types_dropdown( (array) $post_types = array() ); 

Parameters (1)

0. $post_types — Optional. (array) => array()
Array of post types that are registered. Optional.

Usage

  1. if ( !function_exists( 'cptui_post_types_dropdown' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-post-type-ui/inc/post-types.php'; 
  3.  
  4. // Array of post types that are registered. Optional. 
  5. $post_types = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = cptui_post_types_dropdown($post_types); 
  9.  

Defined (1)

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

/inc/post-types.php  
  1. function cptui_post_types_dropdown( $post_types = array() ) { 
  2.  
  3. $ui = new cptui_admin_ui(); 
  4.  
  5. if ( ! empty( $post_types ) ) { 
  6. $select = array(); 
  7. $select['options'] = array(); 
  8.  
  9. foreach ( $post_types as $type ) { 
  10. $text = ( ! empty( $type['label'] ) ) ? $type['label'] : $type['name']; 
  11. $select['options'][] = array( 'attr' => $type['name'], 'text' => $text ); 
  12.  
  13.  
  14. $select['selected'] = $current; 
  15. echo $ui->get_select_input( array( 
  16. 'namearray' => 'cptui_selected_post_type',  
  17. 'name' => 'post_type',  
  18. 'selections' => $select,  
  19. 'wrap' => false,  
  20. ) );