| | |
| | | $meta = Meta::forPost($ID); |
| | | $config = $this->getConfig(); |
| | | |
| | | $class = $this->classFromConfig($config, $meta); |
| | | $class = JVB()->schemaHelper()::classFromConfig($config, $meta); |
| | | |
| | | $class->setAuthor(JVB()->seo()->getCreator(true)); |
| | | return $class->outputSchema(); |
| | |
| | | $ID, |
| | | function() use ($ID) { |
| | | $action = BASE.ucfirst($this->slug).'Schema'; |
| | | $config = get_option($action, apply_filters($action, $this->defaultSchema)); |
| | | $config = JVB()->schemaHelper()::schema($action); |
| | | |
| | | if (!array_key_exists('type', $config)) { |
| | | $config['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage'; |
| | | } |
| | |
| | | error_log('No class found for archive schema output: '.$config['type']); |
| | | return []; |
| | | } |
| | | $class = $this->classFromConfig($config); |
| | | $class = JVB()->schemaHelper()::classFromConfig($config); |
| | | |
| | | $class->setIsPartOf(get_home_url().'/#website'); |
| | | $itemList = new render\Thing\Intangible\ItemList\ItemList(); |
| | |
| | | $this->slug, |
| | | function() { |
| | | $action = BASE.ucfirst($this->slug).'Archive'; |
| | | $config = get_option($action, apply_filters($action, $this->defaultArchive)); |
| | | $config = JVB()->schemaHelper()->archive($this->slug); |
| | | if (!array_key_exists('type', $config)) { |
| | | $config['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage'; |
| | | } |
| | |
| | | $obj = get_queried_object(); |
| | | $meta = (property_exists($obj, 'taxonomy')) ? Meta::forTerm($obj->term_id) : null; |
| | | |
| | | $class = $this->classFromConfig($config, $meta); |
| | | $class = JVB()->schemaHelper()::classFromConfig($config, $meta); |
| | | |
| | | $class->setIsPartOf(get_home_url().'/#website'); |
| | | $itemList = new render\Thing\Intangible\ItemList\ItemList(); |
| | |
| | | $meta = null; |
| | | } |
| | | $config = $this->getConfig('archive'); |
| | | $class = $this->classFromConfig($config, $meta); |
| | | $class = JVB()->schemaHelper()::classFromConfig($config, $meta); |
| | | $class->delete('about'); |
| | | |
| | | switch ($type) { |
| | |
| | | error_log('[SEO]Schema::getConfig Invalid type: '.$type); |
| | | return []; |
| | | } |
| | | $action = BASE.ucfirst($this->slug).ucfirst($type); |
| | | $default = 'default'.ucfirst($type); |
| | | return get_option($action, apply_filters($action, $this->$default)); |
| | | return JVB()->schemaHelper()::getConfig($this->slug, $type); |
| | | } |
| | | |
| | | public function define(string $property, string $value):void |
| | |
| | | $config = $this->getConfig('meta'); |
| | | $meta = Meta::forPost(get_the_ID()); |
| | | $title = Resolver::resolve($config['name'], $meta); |
| | | } elseif (is_post_type_archive($based) || is_tax($based)) { |
| | | } elseif (is_post_type_archive($based) ) { |
| | | $config = $this->getConfig('archive'); |
| | | $title = $config['name']; |
| | | } elseif (is_tax($based)) { |
| | | $config = $this->getConfig('archive'); |
| | | $meta = Meta::forTerm(get_queried_object_id()); |
| | | $title = Resolver::resolve($config['name'], $meta); |
| | | } else { |
| | | error_log('[Schema]::filterTSFOGTitle Unmatched condition: '.$this->slug); |
| | | } |
| | | return $title; |
| | | } |
| | | |
| | | protected function classFromConfig(array $config, ?Meta $meta = null):mixed |
| | | { |
| | | if (!array_key_exists('type', $config)) { |
| | | error_log('[Schema]::classFromConfig No class defined in config: '.print_r($config, true)); |
| | | return false; |
| | | } |
| | | $className = $config['type']; |
| | | unset($config['type']); |
| | | $class = new $className(); |
| | | |
| | | foreach ($config as $property=>$value) { |
| | | if (is_array ($value)) { |
| | | $value = $this->classFromConfig($value, $meta); |
| | | } |
| | | $method = 'set'.ucfirst($property); |
| | | if (!method_exists($class, $method)) { |
| | | error_log('[Schema]::classFromConfig - method: '.$method.' does not exist in class: '.$className); |
| | | continue; |
| | | } |
| | | if (is_string($value) && str_contains($value, '{{')) { |
| | | $value = Resolver::resolveForSchema($property, $value, $config, $meta); |
| | | } |
| | | if (!empty($value)) { |
| | | $class->$method($value); |
| | | } |
| | | } |
| | | return $class; |
| | | } |
| | | } |