| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Pix_Customize_Radio_Image_Control |
| 5 |
* A simple Select2 Control |
| 6 |
*/ |
| 7 |
class Pix_Customize_Radio_Image_Control extends Pix_Customize_Control { |
| 8 |
public $type = 'radio_image'; |
| 9 |
public $choices_type = 'radio'; |
| 10 |
public $description = null; |
| 11 |
|
| 12 |
/** |
| 13 |
* Render the control's content. |
| 14 |
* |
| 15 |
* @since 3.4.0 |
| 16 |
*/ |
| 17 |
public function render_content() { |
| 18 |
|
| 19 |
switch ( $this->choices_type ) { |
| 20 |
|
| 21 |
case 'radio' : { ?> |
| 22 |
<label> |
| 23 |
<?php if ( ! empty( $this->label ) ) { ?> |
| 24 |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 25 |
<?php } ?> |
| 26 |
|
| 27 |
<div class="customify_radio_image"> |
| 28 |
<?php |
| 29 |
foreach ( $this->choices as $value => $image_url ){ |
| 30 |
|
| 31 |
if ( empty( $image_url ) ) { |
| 32 |
$image_url = plugins_url() . '/customify/images/default_radio_image.png'; |
| 33 |
} ?> |
| 34 |
<label> |
| 35 |
<input <?php $this->link(); echo 'name="' . $this->setting->id . '" type="radio" value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) .' ></input>';?> |
| 36 |
<img src="<?php echo $image_url; ?>" style="width: 50px; display: block; height: auto;"></span> |
| 37 |
</label> |
| 38 |
<?php } ?> |
| 39 |
</div> |
| 40 |
|
| 41 |
<?php if ( ! empty( $this->description ) ) { ?> |
| 42 |
<span class="description customize-control-description"><?php echo $this->description; ?></span> |
| 43 |
<?php } ?> |
| 44 |
</label> |
| 45 |
<?php break; |
| 46 |
} |
| 47 |
|
| 48 |
case 'buttons' : { ?> |
| 49 |
<label> |
| 50 |
<?php if ( ! empty( $this->label ) ) { ?> |
| 51 |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 52 |
<?php } ?> |
| 53 |
|
| 54 |
<div class="customify_radio_image radio_buttons"> |
| 55 |
<?php |
| 56 |
foreach ( $this->choices as $value => $setts ){ |
| 57 |
if ( ! isset( $setts['options']) || ! isset( $setts['label'] ) ) { |
| 58 |
continue; |
| 59 |
} |
| 60 |
$color = ''; |
| 61 |
if ( isset( $setts['color'] ) ) { |
| 62 |
$color .= ' style="border-left-color: ' . $setts['color'] . '; color: ' . $setts['color'] . ';"'; |
| 63 |
} |
| 64 |
|
| 65 |
$label = $setts['label']; |
| 66 |
$options = $setts['options']; |
| 67 |
$data = ' data-options=\'' . json_encode($options) . '\'';?> |
| 68 |
|
| 69 |
<fieldset class="customify_radio_button"> |
| 70 |
<input <?php $this->link(); echo 'name="' . $this->setting->id . '" type="radio" value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . $data .' />'; ?> |
| 71 |
<label class="button" for="<?php echo $this->setting->id; ?>" <?php echo $color; ?>> |
| 72 |
<?php echo $label; ?> |
| 73 |
</label> |
| 74 |
</fieldset> |
| 75 |
<?php } ?> |
| 76 |
</div> |
| 77 |
|
| 78 |
<?php if ( ! empty( $this->description ) ) { ?> |
| 79 |
<span class="description customize-control-description"><?php echo $this->description; ?></span> |
| 80 |
<?php } ?> |
| 81 |
</label> |
| 82 |
<?php break; |
| 83 |
} |
| 84 |
|
| 85 |
default: |
| 86 |
break; |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|