user = wp_get_current_user(); $this->user_id = $this->user->ID; $this->config = JVB_CONTENT[$content]; $this->singular = $this->config['singular']; $this->plural = $this->config['plural']; $this->content = $content; $this->fields = jvbGetFields($this->content, 'post'); $this->maybeSetupTimeline(); $this->sections = jvbGetSections($this->content, 'post'); $this->stuck = [ 'post_title', 'term_name' ]; $this->init(); if ($this->isTimeline) { $this->stuck[] = 'post_thumbnail'; } add_filter('jvbAdditionalActions', [$this, 'createItem']); } protected function init():void { $this->initStatuses(); $this->initBulkActions(); $this->initTaxonomies(); $this->initFilters(); $this->meta = new MetaManager(null, 'post', $this->content); $this->form = new MetaForm(); $plural = strtolower($this->config['plural']??$this->content.'s'); $this->userCanPublish = (jvbUserIsVerified()) ? user_can($this->user_id, "publish_{$plural}") : false; } protected function maybeSetupTimeline():void { $this->isTimeline = Features::forContent($this->content)->has('is_timeline'); if (!$this->isTimeline) { return; } $this->timelineSharedFields = array_keys(array_filter($this->fields, function ($field) { if (!array_key_exists('for_all', $field) || $field['for_all'] === false){ return true; } return false; })); array_unshift($this->timelineSharedFields, 'post_thumbnail'); array_unshift($this->timelineSharedFields, 'post_title'); array_unshift($this->timelineSharedFields, 'post_status'); $this->timelineUniqueFields = array_keys(array_filter($this->fields, function ($field) { if (array_key_exists('for_all', $field) && $field['for_all'] === true) { return true; } return false; })); $all = array_merge($this->timelineUniqueFields, $this->timelineSharedFields); $this->nonTimelineFields = array_filter($this->fields, function ($field) use ($all) { return !in_array($field, $all); }, ARRAY_FILTER_USE_KEY); } protected function initTaxonomies():void { $this->taxonomies = array_filter(JVB_TAXONOMY, function ($config) { return in_array($this->content, $config['for_content']); }); } protected function initStatuses():void { $this->statuses = (array_key_exists('is_calendar', $this->config)) ? [ 'all' => [ 'icon' => 'calendar', 'label' => 'Everything', ], 'future'=> [ 'label' => 'Upcoming', 'icon' => 'clock-clockwise', ], 'past' => [ 'label' => 'Past', 'icon' => 'clock-counter-clockwise', ], 'repeat'=> [ 'label' => 'Recurring', 'icon' => 'repeat', ], 'draft' => [ 'icon' => 'eye-closed', 'label' => 'Hidden', ], 'trash' => [ 'label' => 'Scrapped', 'icon' => 'trash', ], ] : [ 'all' => [ 'icon' => 'infinity', 'label' => 'Everything', ], 'publish'=> [ 'icon' => 'eye', 'label' => 'Live', ], 'draft' => [ 'icon' => 'eye-closed', 'label' => 'Hidden', ], 'trash' => [ 'label' => 'Scrapped', 'icon' => 'trash', ], ]; } protected function initBulkActions():void { $this->bulkActions = [ 'edit' => 'Edit', 'publish' => 'Show', 'draft' => 'Hide', // 'copy' => 'Duplicate', 'trash' => 'Scrap' ]; } protected function initFilters():void { $this->filters = [ 'status' => $this->statuses, 'date' => [ 'label' => 'Date', 'icon' => 'calendar' ] ]; foreach ($this->taxonomies as $taxonomy=> $config) { $this->filters['taxonomy'][$taxonomy] = [ 'label' => $config['singular'], 'icon' => $config['icon']??'folder' ]; } } public function render():void { ob_start(); ?>
=$this->config['page_description']?>
renderHeaderActions(); } protected function renderHeaderActions():void { $uploadConfig = [ 'type' => 'upload', 'subtype' => 'image', 'mode' => (jvbCheck('single_image', $this->config)) ? 'direct' : 'selection', 'create_new' => true, 'label' => (array_key_exists('image_title', $this->config)) ? $this->config['image_title'] : 'Upload More '.$this->config['plural'], 'content' => $this->content, 'singular' => $this->singular, 'plural' => $this->plural, 'multiple' => true, 'destination' => 'post' ]; if (!array_key_exists('single_image', $this->config) || $this->config['single_image'] === false) { $uploadConfig['destination'] = 'post_group'; } $uploadConfig['destination'] = 'post_group'; if (!jvbCheck('single_image', $this->config)) { $uploadConfig['label'] = 'Create '.$this->config['plural']; $uploadConfig['upload_text'] = 'Drag images into groups. Each group becomes its own '.$this->singular.'.
You can also select multiple images and click the "Add to Group" button.
If a '.$this->singular.' has multiple images, you can select the '.jvbIcon('star').' to set an image as the main one.
Images left ungrouped will become individual '.$this->plural.'
Once finished, click the \'Save Changes\' button to send to server for processing.
'; } else { $uploadConfig['description'] = 'Each image will become its own '.$this->singular.'.'; } ?>It doesn't look like you have any =$this->config['plural'] ?> yet.
Add many by uploading images above., or click the "=jvbIcon('plus-square')?>" button to add one at a time.
', '', $field));
}
echo $field;
}
return ob_get_clean();
}
protected function renderGridView():void
{
?>
= $this->renderItemSelect() ?>
= $this->renderStatusRadios() ?>
fields as $name => $config):
if (array_key_exists('hidden', $config)){
continue;
}
$makeThisDetailed = (in_array($config['type'], $makeDetails));
?>
stuck)) ? ' data-stuck':''?>>
= $makeThisDetailed ? '
See Value
' : '' ?>
meta->render('form', $name, $config); ?>
= $makeThisDetailed ? '
= $this->renderItemSelect() ?>
= $this->renderStatusRadios() ?>
fields as $name => $config) {
if(array_key_exists('hidden', $config) || $name === 'post_status') {
continue;
}
if (!in_array($name, $this->timelineSharedFields)) {
echo '';
continue;
}
$makeThisDetailed = (in_array($config['type'], $makeDetails));
?>
stuck)) ? ' data-stuck':''?>>
= $makeThisDetailed ? '
See Value
' : '' ?>
meta->render('form', $name, $config); ?>
= $makeThisDetailed ? '
= $this->renderStatusRadios() ?>
fields as $name => $config) {
if(array_key_exists('hidden', $config) || $name === 'post_status') {
continue;
}
if (!in_array($name, $this->timelineUniqueFields)) {
echo '';
continue;
}
$makeThisDetailed = (in_array($config['type'], $makeDetails));
?>
stuck)) ? ' data-stuck':''?>>
= $makeThisDetailed ? '
See Value
' : '' ?>
meta->render('form', $name, $config); ?>
= $makeThisDetailed ? '