class-vamtam-customize-image-select-control.php 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class Vamtam_Customize_Image_Select_Control extends Vamtam_Customize_Control {
  3. public $type = 'vamtam-image-select';
  4. /**
  5. * Render the control's content.
  6. */
  7. protected function render_content() {
  8. $setting_value = $this->value();
  9. $name = '_customize-radio-' . $this->id;
  10. if ( ! empty( $this->label ) ) : ?>
  11. <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
  12. <?php endif;
  13. if ( ! empty( $this->description ) ) : ?>
  14. <span class="description customize-control-description"><?php echo wp_kses_post( $this->description ); ?></span>
  15. <?php endif;
  16. foreach ( $this->choices as $value => $image ) :
  17. ?>
  18. <label>
  19. <input type="radio" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link();
  20. checked( $setting_value, $value ); ?> />
  21. <img src="<?php echo esc_url( $image['img'] ); ?>" alt="<?php echo esc_attr( $image['alt'] ) ?>" title="<?php echo esc_attr( $image['alt'] ) ?>" />
  22. </label>
  23. <?php
  24. endforeach;
  25. }
  26. }