Last active
February 21, 2021 00:40
-
-
Save jasondevine/d0f945255ecfb0c94a5069ec000f41b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Multiple select customize control class. | |
*/ | |
class Jayj_Customize_Control_Multiple_Select extends WP_Customize_Control { | |
/** | |
* The type of customize control being rendered. | |
*/ | |
public $type = 'multiple-select'; | |
/** | |
* Displays the multiple select on the customize screen. | |
*/ | |
public function render_content() { | |
if ( empty( $this->choices ) ) | |
return; | |
?> | |
<label> | |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | |
<select <?php $this->link(); ?> multiple="multiple" style="height: 100%;"> | |
<?php | |
foreach ( $this->choices as $value => $label ) { | |
$selected = ( in_array( $value, $this->value() ) ) ? selected( 1, 1, false ) : ''; | |
echo '<option value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>'; | |
} | |
?> | |
</select> | |
</label> | |
<?php } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment