| | |
| | | <?php |
| | | namespace JVBase\forms; |
| | | |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Term; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | |
| | | protected string $base; |
| | | protected string $title; |
| | | protected array $config; |
| | | protected Registrar $registrar; |
| | | |
| | | public function __construct(string $id, string $taxonomy, array $config = []) { |
| | | $this->id = sanitize_key($id); |
| | | $this->taxonomy = jvbCheckBase($taxonomy); |
| | | $this->name = jvbNoBase($taxonomy); |
| | | |
| | | $this->title = JVB_TAXONOMY[$this->name]['plural']; |
| | | $registrar = Registrar::getInstance($this->name); |
| | | if ($registrar) { |
| | | $this->registrar = $registrar; |
| | | } |
| | | |
| | | $this->title = $registrar->getPlural(); |
| | | $this->base = $config['base']??''; |
| | | $this->config = wp_parse_args($config, [ |
| | | 'types' => false, // for feed block implementation |
| | |
| | | 'update' => true, // Whether to update on close |
| | | ]); |
| | | |
| | | $this->plural = JVB_TAXONOMY[$taxonomy]['plural']; |
| | | $this->singular = JVB_TAXONOMY[$taxonomy]['singular']; |
| | | $this->plural = $registrar->getPlural(); |
| | | $this->singular = $registrar->getSingular(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | return sprintf( |
| | | '<button type="button" data-icon="%s" data-filter="taxonomy" data-taxonomy="%s" data-type="selector" data-single="%s" data-plural="%s" title="Filter by %s">%s<span class="label">%s</span></button>', |
| | | JVB_TAXONOMY[$this->name]['icon'], |
| | | $this->registrar->getIcon(), |
| | | $this->name, |
| | | $this->singular, |
| | | $this->plural, |
| | | $this->singular, |
| | | jvbIcon($this->config['icon']), |
| | | jvbIcon($this->registrar->getIcon()), |
| | | $this->singular |
| | | ); |
| | | } |