| | |
| | | <?php |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\ui\CRUDSkeleton; |
| | | |
| | |
| | | // Fields and sections |
| | | $this->skeleton->setFields($this->registrar->getFields()); |
| | | |
| | | foreach ($this->registrar->getSections() as $config) { |
| | | $this->skeleton->addSection($config['id'], $config); |
| | | } |
| | | jvbDump($this->registrar->getSections()); |
| | | $sections = $this->registrar->getSections(); |
| | | if (count($sections) > 1) { |
| | | foreach ($sections as $config) { |
| | | jvbDump($config); |
| | | $this->skeleton->addSection($config['id'], $config); |
| | | } |
| | | } |
| | | |
| | | // Taxonomies |
| | | $this->initTaxonomies(); |
| | | |
| | | // Statuses |
| | | if ($this->registrar && $this->registrar->hasFeature('is_calendar')) { |
| | | if ($this->registrar->hasFeature('is_calendar')) { |
| | | $this->skeleton->setCalendar(); |
| | | } |
| | | |
| | | $this->skeleton->setDefaultStatus(); |
| | | if ($this->registrar->getType() === 'post') { |
| | | $this->skeleton->setDefaultStatus(); |
| | | } else { |
| | | $this->skeleton->setStatuses([]); |
| | | } |
| | | |
| | | |
| | | // Views |
| | | $this->skeleton |
| | |
| | | $this->skeleton->addCapabilities(['view', 'edit', 'create', 'delete']); |
| | | |
| | | $plural = strtolower($this->registrar->getPlural() ?? $this->content . 's'); |
| | | $canPublish = jvbUserIsVerified() && user_can($this->user_id, "publish_{$plural}"); |
| | | $canPublish = $this->userIsVerified() && user_can($this->user_id, "publish_{$plural}"); |
| | | $this->skeleton->userCanPublish($canPublish); |
| | | |
| | | // Bulk actions |
| | |
| | | add_filter('jvbAdditionalActions', [$this, 'createItem']); |
| | | } |
| | | |
| | | protected function userIsVerified():bool { |
| | | $membership = Site::membership(); |
| | | |
| | | return !($membership && $membership->has('member_verified')) || current_user_can('skip_moderation'); |
| | | } |
| | | /** |
| | | * Setup uploader configuration |
| | | */ |
| | |
| | | * Initialize taxonomies from WordPress config |
| | | */ |
| | | protected function initTaxonomies(): void { |
| | | $this->taxonomies = $this->registrar->registrar->taxonomies; |
| | | $this->taxonomies = ($this->registrar->getType() === 'post') ? $this->registrar->registrar->taxonomies : []; |
| | | } |
| | | |
| | | /** |