| | |
| | | protected string $dataType = ''; |
| | | protected string $singular = ''; |
| | | protected string $plural = ''; |
| | | protected string $icon = 'triangle'; |
| | | protected string $icon; |
| | | |
| | | // Capabilities |
| | | protected array $caps = []; |
| | |
| | | protected array $additionalClasses = []; |
| | | |
| | | public function __construct() { |
| | | $this->icon = jvbDefaultIcon(); |
| | | $this->user = wp_get_current_user(); |
| | | $this->user_id = $this->user->ID; |
| | | } |
| | |
| | | return $this; |
| | | } |
| | | |
| | | protected function taxConfig(string $taxonomy, string $label = ''):array |
| | | { |
| | | $isVerified = jvbUserIsVerified(); |
| | | $label = ($label === '') ? JVB_TAXONOMY[$taxonomy]['plural'] : $label; |
| | | return [ |
| | | 'type' => 'taxonomy', |
| | | 'label' => $label, |
| | | 'taxonomy' => $taxonomy, |
| | | 'createNew' => $isVerified, |
| | | 'multiple' => true, |
| | | 'mode' => 'append', |
| | | ]; |
| | | } |
| | | |
| | | public function addSearch():self |
| | | { |
| | | $this->hasSearch = true; |
| | |
| | | /** |
| | | * Add a view type (grid, table, list, timeline) |
| | | */ |
| | | public function addViews(?array $views):self |
| | | public function addViews(?array $views = null):self |
| | | { |
| | | if (!$views) { |
| | | $views = $this->defaultViews; |
| | |
| | | return; |
| | | } |
| | | ?> |
| | | <div class="all-filters col start" data-ignore> |
| | | <details class="all-filters col start" data-ignore> |
| | | <summary>Filters</summary> |
| | | <?php |
| | | |
| | | $this->renderSearch(); |
| | |
| | | $this->renderColumnSelector(); |
| | | } |
| | | ?> |
| | | </div> |
| | | </details> |
| | | <?php |
| | | } |
| | | |
| | |
| | | } |
| | | ob_start(); |
| | | ?> |
| | | <div class="item-actions"> |
| | | <div class="item-actions row btw abs"> |
| | | <?php |
| | | foreach ($this->itemActions as $action) { |
| | | $config = $this->defaultItemActions[$action]; |
| | |
| | | $temp = array_filter($fields, function ($field) { |
| | | return in_array($field, $this->timelineUniqueFields); |
| | | }, ARRAY_FILTER_USE_KEY); |
| | | |
| | | $config = [ |
| | | 'type' => 'gallery', |
| | | 'subtype' => 'timeline', |
| | |
| | | $content = ''; |
| | | foreach ($fields as $slug=> $field) { |
| | | if (in_array($slug, $this->timelineSharedFields)) { |
| | | if (in_array($field['type'], ['taxonomy', 'selector'])) { |
| | | $field = array_merge($field, $this->taxConfig($field['taxonomy'], $field['label'])); |
| | | } |
| | | $content .= $this->form->render($slug, null, $field, false, true); |
| | | } |
| | | } |
| | |
| | | $section = (array_key_exists('section', $config)) ? $config['section'] : 'basic'; |
| | | $tabs[$section]['content'] .= $this->meta->render('form', $n, $config, false, true); |
| | | } else { |
| | | if (in_array($config['type'], ['taxonomy', 'selector'])) { |
| | | $config = array_merge($config, $this->taxConfig($config['taxonomy'], $config['label'])); |
| | | } |
| | | $this->meta->render('form', $n, $config); |
| | | } |
| | | } |
| | |
| | | <div class="taxonomies"> |
| | | <?php |
| | | foreach ($this->taxonomies as $taxonomy => $config) { |
| | | $this->meta->render( |
| | | 'form', |
| | | $this->form->renderSelectorField( |
| | | 'bulk-edit-'.$taxonomy, |
| | | [ |
| | | 'type' => 'taxonomy', |
| | | 'label' => $config['label'], |
| | | 'taxonomy' => $taxonomy, |
| | | 'createNew' => jvbUserIsVerified(), |
| | | 'multiple' => true, |
| | | 'mode' => 'append' |
| | | ] |
| | | '', |
| | | $this->taxConfig($taxonomy, $config['label']), |
| | | 'taxonomy' |
| | | ); |
| | | } |
| | | ?> |
| | |
| | | |
| | | protected function getApplicableStatuses(string $prefix) { |
| | | foreach ($this->statuses as $status) { |
| | | if ($status === 'all' || !in_array($status, $this->allowedStatuses)) { |
| | | if ($status === 'all' || !array_key_exists($status, $this->allowedStatuses)) { |
| | | continue; |
| | | } |
| | | $config = $this->allowedStatuses[$status]; |
| | |
| | | value="<?= esc_attr($status)?>" |
| | | id="<?=$prefix?>set-<?= esc_attr($status) ?>" |
| | | <?= $disabled?>> |
| | | <label for="<?=$prefix?>set-<?=esc_attr($status)?>"> |
| | | <?= jvbDashIcon($config['icon'], ['title' => $config['label']]) ?> |
| | | <span><?= esc_html($config['label'])?></span> |
| | | <label for="<?=$prefix?>set-<?=esc_attr($status)?>" title="<?=esc_html($config['label'])?>"> |
| | | <?= jvbDashIcon($config['icon']) ?> |
| | | </label> |
| | | <?php |
| | | } |