| | |
| | | |
| | | protected array $properties = []; |
| | | protected array $referenceProperties = []; |
| | | protected array $extras = []; |
| | | protected array $defaultReference = [ |
| | | 'name' => '{{post_title}}', |
| | | 'url' => '{{post_permalink}}', |
| | |
| | | } |
| | | $this->defaultArchive['description'] = '{{registrar.'.$slug.'.description}}'; |
| | | } |
| | | |
| | | $this->extras = apply_filters(BASE.ucfirst($slug).'Extras', []); |
| | | $this->initFilters(); |
| | | $this->registerHooks(); |
| | | } |
| | |
| | | $class->setIsPartOf(get_home_url().'/#website'); |
| | | $itemList = new render\Thing\Intangible\ItemList\ItemList(); |
| | | $items = new WP_Query([ |
| | | 'post_type' => jvbCheckBase($this->slug), |
| | | 'post_type' => $registrar->getBased(), |
| | | 'posts_per_page'=> 25, |
| | | 'post_status' => 'publish', |
| | | 'fields' => 'ids' |
| | |
| | | $class->setMainEntity($itemList); |
| | | |
| | | $schema = $class->outputSchema(); |
| | | |
| | | if (JVB_TESTING) { |
| | | // error_log('Generated archive schema: '.print_r($schema, true)); |
| | | } |
| | |
| | | $cached = $this->referenceCache->remember( |
| | | $ID, |
| | | function () use ($ID, $type) { |
| | | |
| | | $postType = get_post_type($ID); |
| | | $function = BASE.'build_singular_'.jvbNoBase($postType).'_schema_reference'; |
| | | |
| | | if (function_exists($function)) { |
| | | return $function($ID); |
| | | } |
| | | switch ($type) { |
| | | case 'post': |
| | | $meta = Meta::forPost($ID); |
| | |
| | | } |
| | | $config = $this->getConfig(); |
| | | $class = JVB()->schemaHelper()::classFromConfig($config, $meta); |
| | | $class->delete('about'); |
| | | if ($class) { |
| | | $class->delete('about'); |
| | | } |
| | | |
| | | |
| | | switch ($type) { |
| | | case 'post': |
| | |
| | | $page->setMainEntity($termset); |
| | | return $page->outputSchema(); |
| | | } |
| | | |
| | | public function extra():array |
| | | { |
| | | if (empty($this->extras)) { |
| | | return []; |
| | | } |
| | | $out = []; |
| | | foreach ($this->extras as $config) { |
| | | $schema = SchemaHelper::classFromConfig($config); |
| | | $output = $schema->outputSchema(); |
| | | if (!empty($output)) { |
| | | $out[] = $output; |
| | | } |
| | | } |
| | | return $out; |
| | | } |
| | | } |