PluginProbe
Simple Analytics / 1.27
Simple Analytics v1.27
1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.90 1.91 All 98 releases
simpleanalytics / src / Settings / Blocks / Fields / Checkbox.php

Checkbox.php in Simple Analytics 1.27, at src/Settings/Blocks/Fields/Checkbox.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SimpleAnalytics\Settings\Blocks\Fields;
4
5 use SimpleAnalytics\Setting;
6 use SimpleAnalytics\Settings\Concerns\HasDocs;
7 use SimpleAnalytics\UI\LabelComponent;
8
9 class Checkbox extends Field
10 {
11 use HasDocs;
12
13 public function getValueSanitizer(): callable
14 {
15 return 'absint';
16 }
17
18 public function getValueType(): string
19 {
20 return 'integer';
21 }
22
23 public function render(): void
24 {
25 ?>
26 <div class="relative flex gap-x-3">
27 <div class="flex h-6 items-center">
28 <input
29 id="<?php
30 echo esc_attr($this->getKey());
31 ?>"
32 name="<?php
33 echo esc_attr($this->getKey());
34 ?>"
35 type="checkbox"
36 value="1"
37 class="h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
38 <?php
39 if (Setting::get($this->getKey())) echo 'checked';
40 ?>
41 >
42 </div>
43 <div class="text-sm leading-6">
44 <?php
45 (new LabelComponent($this->getLabel(), $this->docs, $this->getKey()))();
46 ?>
47
48 <?php
49 if ($this->description): ?>
50 <p class="text-gray-500">
51 <?php echo esc_html($this->description); ?>
52 </p>
53 <?php endif;
54 ?>
55 </div>
56 </div>
57 <?php
58 }
59 }
60