| | |
| | | $this->id = sanitize_key($id); |
| | | $this->taxonomy = jvbCheckBase($taxonomy); |
| | | $this->name = jvbNoBase($taxonomy); |
| | | |
| | | $this->title = JVB_TAXONOMY[$this->name]['plural']; |
| | | $this->base = $config['base']??''; |
| | | |
| | |
| | | * @return string The rendered HTML |
| | | */ |
| | | public function render(array $selected = [], string $extra = ''): string { |
| | | |
| | | if (array_key_exists('output', $this->config) && $this->config['output'] === 'minimal') { |
| | | return $this->renderTaxonomyToggle($selected, $extra); |
| | | } |
| | | // Build data attributes |
| | | $dataAttrs = $this->buildDataAttributes($selected); |
| | | |
| | |
| | | <?= $hasAutocomplete ?> |
| | | title="Open <?= $this->singular ?> Selector" |
| | | aria-label="Select <?= esc_attr($this->plural) ?>"> |
| | | <?= jvbIcon('plus-square', ['title' => 'Add ' . $this->title]) ?> |
| | | <?= jvbIcon('plus-square') ?> |
| | | </button> |
| | | <input type="text" id="<?= $this->base ?><?= esc_attr($this->config['name']) ?>-autocomplete" autocomplete="off" data-ignore data-autocomplete> |
| | | <ul class="autocomplete-dropdown" hidden> |
| | | |
| | | </ul> |
| | | <?php if ($hasAutocomplete !== '') { ?> |
| | | <input type="text" id="<?= $this->base ?><?= esc_attr($this->config['name']) ?>-autocomplete" autocomplete="off" data-ignore data-autocomplete> |
| | | <ul class="autocomplete-dropdown" hidden> |
| | | </ul> |
| | | <?php } ?> |
| | | </div> |
| | | |
| | | <div class="selected-items row" role="region" aria-label="Selected <?= esc_attr($this->plural) ?>"> |
| | |
| | | return ob_get_clean(); |
| | | } |
| | | |
| | | protected function renderTaxonomyToggle(array $selected = [], string $extra = ''): string |
| | | { |
| | | return '<button type="button" data-filter="taxonomy" data-taxonomy="'.$this->name.'" title="Filter by '.$this->singular.'">'.jvbIcon($this->config['icon']).'<span class="label">'.$this->singular.'</span></button>'; |
| | | } |
| | | |
| | | /** |
| | | * Build data attributes string for the toggle button |
| | | */ |