SimpleCalendarAdminFieldsDate_Picker

Date Picker input field.

Defined (1)

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

/includes/admin/fields/date-picker.php  
  1. class Date_Picker extends Field { 
  2.  
  3. /** 
  4. * Select a date range. 
  5. * @access public 
  6. * @var bool 
  7. */ 
  8. public $range = false; 
  9.  
  10. /** 
  11. * Use an inline picker. 
  12. * @access public 
  13. * @var bool 
  14. */ 
  15. public $inline = true; 
  16.  
  17. /** 
  18. * Construct. 
  19. * @since 3.0.0 
  20. * @param array $field 
  21. */ 
  22. public function __construct( $field ) { 
  23.  
  24. $this->range = isset( $field['range'] ) ? ( $field['range'] === true ? true : false ) : false; 
  25. $this->inline = isset( $field['inline'] ) ? ( $field['inline'] === true ? true : false ) : true; 
  26.  
  27. $subtype = $this->range === true ? 'simcal-field-date-picker-range ' : ''; 
  28. $this->type_class = 'simcal-field-date-picker ' . $subtype; 
  29.  
  30. $data = array( 
  31. 'data-inline' => $this->inline === true ? 'true' : 'false',  
  32. ); 
  33. $field['attributes'] = isset( $field['attributes'] ) ? array_merge( $field['attributes'], $data ) : $data; 
  34.  
  35. parent::__construct( $field ); 
  36.  
  37. /** 
  38. * Output the field markup 
  39. * @since 3.0.0 
  40. */ 
  41. public function html() { 
  42.  
  43. if ( ! empty( $this->description ) ) { 
  44. echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; 
  45.  
  46. ?> 
  47. <div id="<?php echo $this->id; ?>" 
  48. class="<?php echo $this->class; ?>" 
  49. <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?> 
  50. <?php echo $this->attributes ?>> 
  51. <?php 
  52.  
  53. if ( false === $this->range ) { 
  54.  
  55. ?> 
  56. <i class="simcal-icon-calendar"></i> 
  57. <input type="<?php echo $this->inline === true ? 'text' : 'hidden'; ?>" 
  58. name="<?php echo $this->name; ?>" 
  59. value="<?php echo $this->value; ?>" 
  60. placeholder="..." 
  61. readonly="readonly" /> 
  62. <?php 
  63.  
  64. if ( true === $this->inline ) { 
  65. echo $this->tooltip; 
  66.  
  67. } else { 
  68. // @todo eventually if a date range picker is needed, this can be extended 
  69.  
  70. ?> 
  71. </div> 
  72. <?php 
  73.  
  74.