| | |
| | | |
| | | use JVBase\managers\UserTermsManager; |
| | | use JVBase\meta\Form; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_User; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | |
| | | protected array $customDateRanges = []; |
| | | protected array $additionalClasses = []; |
| | | |
| | | protected Registrar $registrar; |
| | | public function __construct() { |
| | | $this->icon = jvbDefaultIcon(); |
| | | $this->user = wp_get_current_user(); |
| | |
| | | */ |
| | | public function content(string $type, string $singular, string $plural): self { |
| | | $this->dataType = $type; |
| | | $this->registrar = Registrar::getInstance($type); |
| | | $this->singular = $singular; |
| | | $this->plural = $plural; |
| | | return $this; |
| | |
| | | */ |
| | | public function addTaxonomyFilter(array $taxonomies, ?string $limit = null): self { |
| | | foreach($taxonomies as $taxonomy) { |
| | | $registrar = Registrar::getInstance($taxonomy); |
| | | $this->taxonomies[$taxonomy] = [ |
| | | 'type' => 'taxonomy', |
| | | 'taxonomy'=> $taxonomy, |
| | | 'limit' => $limit, |
| | | 'label' => JVB_TAXONOMY[$taxonomy]['plural']??'', |
| | | 'icon' => JVB_TAXONOMY[$taxonomy]['icon']??'' |
| | | 'label' => $registrar->getPlural(), |
| | | 'icon' => $registrar->getIcon() |
| | | ]; |
| | | } |
| | | |
| | |
| | | protected function taxConfig(string $taxonomy, string $label = ''):array |
| | | { |
| | | $isVerified = jvbUserIsVerified(); |
| | | $label = ($label === '') ? JVB_TAXONOMY[$taxonomy]['plural'] : $label; |
| | | $label = ($label === '') ? Registrar::getInstance($taxonomy)->getPlural() : $label; |
| | | return [ |
| | | 'type' => 'taxonomy', |
| | | 'label' => $label, |
| | |
| | | <option value="<?=$control?>"<?=$disabled?>><?=$label?></option> |
| | | <?php |
| | | } |
| | | foreach ($this->taxonomies as $taxonomy => $config) { |
| | | foreach ($this->taxonomies as $taxonomy) { |
| | | $registrar = Registrar::getInstance($taxonomy); |
| | | if (!$registrar) continue; |
| | | ?> |
| | | <option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=JVB_TAXONOMY[$taxonomy]['singular']?>" data-plural="<?=JVB_TAXONOMY[$taxonomy]['plural']?>" data-taxonomy="<?=$taxonomy?>">Add to <?= JVB_TAXONOMY[$taxonomy]['singular']??$config['label'] ?></option> |
| | | <option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=$registrar->getSingular()?>" data-plural="<?=$registrar->getPlural()?>" data-taxonomy="<?=$taxonomy?>">Add to <?= $registrar->getSingular() ?></option> |
| | | <?php |
| | | } |
| | | ?> |
| | |
| | | |
| | | if (!empty($this->sections)) { |
| | | $tabs = []; |
| | | foreach ($this->sections as $slug => $config) { |
| | | foreach ($this->sections as $config) { |
| | | $slug = $config['slug']; |
| | | $section = []; |
| | | if (array_key_exists('icon', $config)) { |
| | | $section = [ |
| | |
| | | 'content' => '', |
| | | 'description' => $config['description']??'', |
| | | ], $section); |
| | | $icon = jvbSectionIcon($slug); |
| | | if ($icon !== '') { |
| | | $tabs[$slug]['icon'] = $icon; |
| | | } |
| | | } |
| | | } else { |
| | | $tabs = false; |
| | |
| | | $section = (array_key_exists('section', $config)) ? $config['section'] : 'basic'; |
| | | $tabs[$section]['content'] .= Form::render($n, '', $config); |
| | | } else { |
| | | jvbDump($config, $n); |
| | | echo Form::render($n, '', $config); |
| | | } |
| | | } |