SelectBox.php
977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace YahnisElsts\AdminMenuEditor\Customizable\Controls;
use YahnisElsts\AdminMenuEditor\Customizable\Rendering\Renderer;
class SelectBox extends ChoiceControl {
protected $type = 'select';
protected $koComponentName = 'ame-select-box';
public function renderContent(Renderer $renderer) {
$currentValue = $this->mainSetting->getValue();
$classes = array_merge(['ame-select-box-control'], $this->classes);
list($optionHtml, $optionBindings) = ChoiceControlOption::generateSelectOptions(
$this->options,
$currentValue,
$this->mainSetting
);
//phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->buildInputElement(
[
'class' => $classes,
'style' => $this->styles,
'data-bind' => $this->makeKoDataBind(array_merge(
$optionBindings,
['value' => $this->getKoObservableExpression($currentValue)]
)),
],
'select'
);
echo $optionHtml;
//phpcs:enable
echo '</select>';
}
}