1 <?php
2
3 4 5 6 7
8
9 namespace nk2580\wordsmith\Inputs\Fields;
10
11 use nk2580\wordsmith\Inputs\Input as Input;
12
13 14 15 16 17
18 class TextField extends Input {
19
20 public function printField() {
21 $class = $this->getClassString();
22 if (!$this->readonly) {
23 echo "<label for=\"" . $this->name . "\" >" . $this->label . " <input type=\"text\" name=\"" . $this->name . "\" class=\"" . $class . "\" id=\"" . $this->name . "\" value=\"" . $this->value . "\" /></label>";
24 } else {
25 echo "<label for=\"" . $this->name . "\" >" . $this->label . " <input type=\"text\" readonly name=\"" . $this->name . "\" class=\"" . $class . "\" id=\"" . $this->name . "\" value=\"" . $this->value . "\" /></label>";
26 }
27 echo '<br/>';
28 }
29
30 public function isFieldValid() {
31 if (strlen($this->value) > 0) {
32 return true;
33 } else {
34 return false;
35 }
36 }
37
38 public function sanitize() {
39 return sanitize_text_field($this->value);
40 }
41
42 }
43