SimpleCalendarAdminFieldsCheckbox

Checkbox input field.

Defined (1)

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

/includes/admin/fields/checkbox.php  
  1. class Checkbox extends Field { 
  2.  
  3. /** 
  4. * Construct. 
  5. * @since 3.0.0 
  6. * @param array $field 
  7. */ 
  8. public function __construct( $field ) { 
  9. $this->type_class = 'simcal-field-checkboxes'; 
  10. parent::__construct( $field ); 
  11.  
  12. /** 
  13. * Outputs the field markup. 
  14. * @since 3.0.0 
  15. */ 
  16. public function html() { 
  17.  
  18. if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { 
  19.  
  20. if ( ! empty( $this->description ) ) { 
  21. echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; 
  22.  
  23. ?> 
  24. <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> 
  25. <?php 
  26.  
  27. if ( ! empty( $this->title ) ) { 
  28. echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; 
  29.  
  30. ?> 
  31. <ul> 
  32. <?php foreach ( $this->options as $option => $name ) : ?> 
  33. <li> 
  34. <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> 
  35. <input name="<?php echo $this->name; ?>" 
  36. id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" 
  37. class="simcal-field simcal-field-checkbox" 
  38. type="checkbox" 
  39. value="<?php echo trim( strval( $option ) ); ?>" 
  40. <?php checked( $this->value, 'yes', true ); ?> 
  41. <?php echo $this->attributes; ?> 
  42. /><?php echo esc_attr( $name ); ?> 
  43. </label> 
  44. </li> 
  45. <?php endforeach; ?> 
  46. </ul> 
  47. </fieldset> 
  48. <?php 
  49.  
  50. } else { 
  51.  
  52. ?> 
  53. <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> 
  54. <?php if ( ! empty( $this->title ) ) : ?> 
  55. <span class="screen-reader-text"><?php echo $this->title; ?></span> 
  56. <?php endif; ?> 
  57. <input name="<?php echo $this->name; ?>" 
  58. type="checkbox" 
  59. id="<?php echo $this->id; ?>" 
  60. class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" 
  61. value="yes" 
  62. <?php checked( $this->value, 'yes', true ); ?> 
  63. <?php echo $this->attributes; ?>/><?php echo ( ! empty( $this->text ) ? $this->text : __( 'Yes', 'google-calendar-events' ) ); ?> 
  64. </span> 
  65. <?php 
  66.  
  67. echo $this->tooltip; 
  68.  
  69. if ( ! empty( $this->description ) ) { 
  70. echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; 
  71.  
  72.  
  73.