PluginProbe
Customify / 2.2.0
Customify v2.2.0
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
customify / core / views / form-partials / fields / switch.php

switch.php in Customify 2.2.0, at core/views/form-partials/fields/switch.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php defined('ABSPATH') or die;
2 /* @var PixCustomifyFormField $field */
3 /* @var PixCustomifyForm $form */
4 /* @var mixed $default */
5 /* @var string $name */
6 /* @var string $idname */
7 /* @var string $label */
8 /* @var string $desc */
9 /* @var string $rendering */
10
11 // [!!] a switch is a checkbox that is only ever either on or off; not to
12 // be confused with a fully functional checkbox which may be many values
13
14 $checked = $form->autovalue($name, $default);
15
16 $attrs = array
17 (
18 'name' => $name,
19 'type' => 'checkbox',
20 'id' => $idname,
21 'value' => 1,
22 );
23
24 // is the checkbox checked?
25 if ($checked) {
26 $attrs['checked'] = 'checked';
27 }
28
29 // Label Fillins
30 // -------------
31
32 if ($field->hasmeta('label-fillins')) {
33 $fillers = array();
34 foreach ($field->getmeta('label-fillins', array()) as $fieldname => $conf) {
35 $fillers[":$fieldname"] = $form->field($fieldname, $conf)->render();
36 }
37
38 $processed_label = strtr($label, $fillers);
39 }
40 else { // no fillins available
41 $processed_label = $label;
42 }
43
44 // group show
45
46 if ($field->hasmeta('show_group')) {
47 $attrs['data-show_group'] = $field->getmeta('show_group');
48 }
49 ?>
50
51 <?php if ($rendering == 'inline'): ?>
52 <input <?php echo $field->htmlattributes($attrs) ?> />
53
54 <?php elseif ($rendering == 'blocks'): ?>
55 <div class="switch">
56 <input <?php echo $field->htmlattributes($attrs) ?> />
57 <label for="<?php echo $idname ?>"><?php echo $processed_label ?></label>
58 </div>
59 <?php else: # rendering != 'inline' ?>
60 <label for="<?php echo $idname ?>">
61 <input <?php echo $field->htmlattributes($attrs) ?> />
62 <?php echo $processed_label ?>
63 </label>
64 <?php endif; ?>
65