Post_Type_Dropdown_Custom_Control

Class to create a custom post type control.

Defined (1)

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

/lib/customizer/includes/post-type-dropdown-custom-control.php  
  1. class Post_Type_Dropdown_Custom_Control extends WP_Customize_Control { 
  2. private $postTypes = false; 
  3.  
  4. public function __construct( $manager, $id, $args = array(), $options = array() ) { 
  5. $postargs = wp_parse_args( $options, array( 'public' => true ) ); 
  6. $this->postTypes = get_post_types( $postargs, 'object' ); 
  7.  
  8. parent::__construct( $manager, $id, $args ); 
  9.  
  10. /** 
  11. * Render the content on the theme customizer page 
  12. */ 
  13. public function render_content() { 
  14. if ( empty( $this->postTypes ) ) { 
  15. return false; 
  16. ?> 
  17. <label> 
  18. <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> 
  19. <span class="description customize-control-description"><?php echo esc_attr( $this->description ); ?></span> 
  20. <select name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>"> 
  21. <?php 
  22. foreach ( $this->postTypes as $k => $post_type ) { 
  23. printf('<option value="%s" %s>%s</option>', $k, selected( $this->value(), $k, false ), $post_type->labels->name ); 
  24. ?> 
  25. </select> 
  26. </label> 
  27. <?php