IconPicker.php
5 years ago
Input.php
5 years ago
Select.php
5 years ago
Textarea.php
5 years ago
WPEditor.php
5 years ago
Input.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls; |
| 4 | |
| 5 | |
| 6 | class Input |
| 7 | { |
| 8 | public $args; |
| 9 | |
| 10 | public function __construct($args) |
| 11 | { |
| 12 | $this->args = wp_parse_args( |
| 13 | $args, |
| 14 | ['type' => 'text', 'name' => '', 'value' => sprintf('{{{data.%s}}}', $args['name'])] |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | public function render() |
| 19 | { |
| 20 | if ($this->args['type'] != 'checkbox') { |
| 21 | printf('<label for="%s" class="pp-label">%s</label>', $this->args['name'], $this->args['label']); |
| 22 | } |
| 23 | |
| 24 | if (isset($this->args['description']) && $this->args['type'] != 'checkbox') { |
| 25 | printf('<div class="pp-form-control-description">%s</div>', $this->args['description']); |
| 26 | } |
| 27 | |
| 28 | printf( |
| 29 | '<input class="pp-form-control" type="%1$s" placeholder="%2$s" id="%3$s" name="%3$s" value="%4$s" %5$s>', |
| 30 | $this->args['type'], |
| 31 | @$this->args['placeholder'], |
| 32 | $this->args['name'], |
| 33 | @$this->args['value'], |
| 34 | $this->args['type'] == 'checkbox' ? sprintf('<# if(data.%s === true) { #> checked <# } #>', $this->args['name']) : '' |
| 35 | ); |
| 36 | |
| 37 | if (isset($this->args['description']) && $this->args['type'] == 'checkbox') { |
| 38 | printf('<label style="display: inline-block;margin-left: 5px" for="%s" class="pp-label">%s</label>', $this->args['name'], $this->args['label']); |
| 39 | printf('<div class="pp-form-control-description">%s</div>', $this->args['description']); |
| 40 | } |
| 41 | } |
| 42 | } |