Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //checkboxes
- $comment = sanitize_text_field( $comment ); // cleans input
- $comment = str_replace(", ", ",", $comment); // cleans useless white spaces after puntuaction if present
- $choices = explode(",", $comment);
- $css_classes = str_replace(array(' ' . $coltype . ' ', ' pods_coltype_' . $coltype . ' '), array(' pick ', ' pods_coltype_pick '), $css_classes);
- ?>
- <div class="<?php echo esc_attr($css_classes); ?>" id="<?php echo esc_attr($css_id); ?>" style="border: none; height: auto">
- <?php
- $values = explode(",", $value); // retrieves set value and explodes it to array of set values
- foreach($choices as $key => $val) {
- $selected = '';
- $active = '';
- if (in_array($key, $values) && $value !== '') {
- $selected = ' CHECKED';
- $active = ' active';
- }
- if( $val !== "[]"){
- ?>
- <input type="checkbox" id="checkbox_<?php echo $name . '_' . $key; ?>" name="<?php echo $name . '[]'; ?>" class="checkbox-option<?php echo $active; ?>" value="<?php echo $key; ?>" data-value="<?php echo $key; ?>" <?php echo $selected; ?> />
- <label for="checkbox<?php echo $name . '_' . $key; ?>"><?php echo $val; ?></label><br />
- <?php
- }
- else{
- ?>
- <label for="text_<?php echo $name . '_' . $key; ?>">Altro: </label>
- <input type="text" id="text_<?php echo $name . '_' . $key; ?>" name="<?php echo $name . '_other'; ?>" class="textfield-option<?php echo $active; ?>" value="<?php echo ($val === '[]'? '': $val); ?>"/>
- <?php
- }
- }
- ?>
- </div>
- <script type="text/javascript">
- jQuery('#<?php echo $css_id; ?> input.checkbox-option').on('change', function(){
- jQuery('#<?php echo $css_id; ?> input.checkbox-option').removeClass('active');
- jQuery('#<?php echo $css_id; ?> input.checkbox-option:checked').addClass('active');
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement