Upload folder via GUI - inc
This commit is contained in:
23
inc/fields/class-field-checkbox.php
Normal file
23
inc/fields/class-field-checkbox.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class WMF_Field_Checkbox extends WMF_Field_Base {
|
||||
public $type='checkbox'; public $label='Kontrollkästchen'; public $icon='dashicons-yes-alt'; public $category='auswahl';
|
||||
public function defaults() { return array_merge(parent::defaults(),array('options'=>array(array('label'=>'Option 1','value'=>'option_1')),'layout'=>'vertical')); }
|
||||
public function render($field,$value='') {
|
||||
$checked=is_array($value)?$value:($value?array($value):array()); ?>
|
||||
<div class="<?php echo esc_attr($this->wrapper_classes($field)); ?>"<?php echo $this->conditional_attrs($field); ?> data-field-id="<?php echo esc_attr($field['id']); ?>">
|
||||
<?php $this->render_label($field); ?>
|
||||
<div class="wmf-checkbox-group wmf-layout-<?php echo esc_attr($field['layout']??'vertical'); ?>">
|
||||
<?php foreach($field['options']??array() as $opt): ?>
|
||||
<label class="wmf-checkbox-label">
|
||||
<input type="checkbox" name="wmf_fields[<?php echo esc_attr($field['id']); ?>][]" value="<?php echo esc_attr($opt['value']); ?>" <?php echo in_array($opt['value'],$checked)?'checked':''; ?>>
|
||||
<span><?php echo esc_html($opt['label']); ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php $this->render_description($field); ?>
|
||||
<span class="wmf-field-error-msg"></span>
|
||||
</div><?php
|
||||
}
|
||||
public function sanitize($v,$f) { return is_array($v)?array_map('sanitize_text_field',$v):array(); }
|
||||
}
|
||||
Reference in New Issue
Block a user