| | |
| | | <?php |
| | | namespace JVBase\registrar; |
| | | |
| | | use JVBase\forms\TaxonomySelector; |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\inc\registrar\helpers\HideSingle; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\CRUD; |
| | |
| | | use JVBase\registrar\helpers\MakeTimelineType; |
| | | use JVBase\registrar\helpers\MakeTrackChanges; |
| | | use JVBase\registrar\helpers\MakeVerification; |
| | | use JVBase\utility\Features; |
| | | use WP_Post; |
| | | use WP_Query; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | |
| | | protected string $type; |
| | | protected string $singular; |
| | | protected string $plural; |
| | | protected string $profile; |
| | | protected string $description =''; |
| | | protected Fields $fields; |
| | | protected array $sections = []; |
| | |
| | | * @var array slugs of other user roles this role can manage |
| | | */ |
| | | protected array $manage_others = []; |
| | | /** |
| | | * @var string The slug of the taxonomy that defines different access points |
| | | * Example, for edmonton.ink, we have artist_type, and $this->>can_create would be: |
| | | * [ |
| | | * 'piercer' => ['piercings', 'artwork', 'events'], |
| | | * 'tattoo_artist'=> ['tattoos', 'artwork', 'events'], |
| | | * 'artist' => ['artwork'] |
| | | * ] |
| | | */ |
| | | protected string $user_subtype; |
| | | |
| | | /** Configs **/ |
| | | protected Breadcrumbs $breadcrumbs; |
| | |
| | | // $this->initClasses(); |
| | | $this->setFields(); |
| | | |
| | | add_action('init', [$this, 'register'], 0); |
| | | add_action('init', [$this, 'register'], 2); |
| | | add_filter('jvbDashboardPage', [$this, 'renderDashPage'], 10, 3); |
| | | } |
| | | |
| | |
| | | } |
| | | public function setIntegration(string $integration):self |
| | | { |
| | | if (!Features::forSite()->has($integration)){ |
| | | |
| | | if (!Site::hasIntegration($integration)){ |
| | | error_log('Integration not available for '.$this->slug.': '.$integration); |
| | | return $this; |
| | | } |
| | |
| | | public function getIntegrationFields(string $integration):AddIntegrationFields|false |
| | | { |
| | | |
| | | if (!Features::forSite()->has($integration)){ |
| | | if (!Site::has($integration)){ |
| | | error_log('Integration not available for '.$this->slug.': '.$integration); |
| | | return false; |
| | | } |
| | |
| | | public function hasIntegration(string $integration) { |
| | | return in_array($integration, $this->integrationConfigs); |
| | | } |
| | | public function hasAnyIntegrations(array $integrations = []):bool |
| | | { |
| | | if (empty($integrations)) { |
| | | $integrations = array_keys($this->integrationConfigs); |
| | | return !empty($integrations); |
| | | } |
| | | return !empty(array_intersect($integrations, array_keys($this->integrationConfigs))); |
| | | } |
| | | public function setUploadTitle(string $title):self |
| | | { |
| | | $this->upload_title = $title; |
| | |
| | | } |
| | | |
| | | if ($this->karma) { |
| | | $this->karmaManager = KarmaManager::for($this->slug); |
| | | $this->karmaManager = KarmaManager::for($this->slug, $this->type); |
| | | } |
| | | } |
| | | public static function getInstance(string $slug):Registrar|false |
| | |
| | | * FLAGGED FEATURES |
| | | *****************************************************************/ |
| | | |
| | | public function profile(?string $slug = null, ?string $singular = null, ?string $plural = null):self |
| | | { |
| | | if (!$slug) { |
| | | $slug = $this->slug.'_profile'; |
| | | } |
| | | if (!$singular) { |
| | | $singular = $this->singular; |
| | | } |
| | | if (!$plural) { |
| | | $plural = $this->plural; |
| | | } |
| | | $this->profile_link = true; |
| | | |
| | | $this->profile = $slug; |
| | | |
| | | return Registrar::forPost($slug, $singular, $plural); |
| | | } |
| | | public function getProfile():self|false |
| | | { |
| | | if (!$this->profile_link) { |
| | | return false; |
| | | } |
| | | return self::getInstance($this->profile); |
| | | } |
| | | |
| | | public function setUserSubtype(string $type):self |
| | | { |
| | | $this->user_subtype = sanitize_text_field($type); |
| | | return $this; |
| | | } |
| | | public function getUserSubtype():string|false |
| | | { |
| | | return $this->user_subtype?:false; |
| | | } |
| | | } |