slug = $slug; $action = ucFirst($slug); $this->config = [ 'schema' => get_option(BASE.$action.'Schema', apply_filters(BASE.$action.'Schema', [])), 'meta' => get_option(BASE.$action.'Meta', apply_filters(BASE.$action.'Meta', [])), 'archive' => get_option(BASE.$action.'Archive', apply_filters(BASE.$action.'Archive', [])), ]; } protected function initSchema():void { if (!array_key_exists('type', $this->config['schema'])) { $registrar = Registrar::getInstance($this->slug); if ($registrar) { switch ($registrar->getType()) { case 'term': $this->config['schema']['type'] = 'JVBase\inc\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage\CollectionPage'; break; case 'post': $this->config['schema']['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork'; break; case 'user': $this->config['schema']['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\ProfilePage'; break; } } } if (!array_key_exists('type', $this->config['schema'])) { error_log('Missing schema type'); return; } if (!class_exists($this->config['schema']['type'])) { error_log('Could not find class: '.$this->config['schema']['type']); return; } $this->schema = new Schema($this->slug, $this->config['schema']['type']); } public function schema():Schema|false { if (!isset($this->schema)) { $this->initSchema(); } return $this->schema??false; } public function meta():Meta { return $this->meta; } public function archive():Archive { return $this->archive; } public function getConfig():array { return $this->config; } }