| | |
| | | { |
| | | $schema = []; |
| | | |
| | | |
| | | $registrar = false; |
| | | if (is_front_page()) { |
| | | $schema[] = $this->buildWebsiteSchema(true); |
| | | $test = $this->buildOrganizationSchema(); |
| | |
| | | if (is_singular($this->types)) { |
| | | $type = get_post_type(); |
| | | $registrar = Registrar::getInstance($type); |
| | | if ($registrar) { |
| | | |
| | | $function = BASE.'build_singular_'.jvbNoBase($type).'_schema'; |
| | | if (function_exists($function)) { |
| | | $schema = $function(get_the_ID()); |
| | | } else if ($registrar) { |
| | | $seo = $registrar->getSEO(); |
| | | $schema[] = $seo->schema()->outputSingularSchema(); |
| | | } |
| | | }elseif (is_post_type_archive($this->types)) { |
| | | error_log('It is a post type archive'); |
| | | |
| | | $type = get_queried_object(); |
| | | $type = $type->name; |
| | | $registrar = Registrar::getInstance($type); |
| | |
| | | $registrar = Registrar::getInstance($type); |
| | | if ($registrar ) { |
| | | $seo = $registrar->getSEO(); |
| | | error_log('SEO: '.print_r($seo->schema(), true)); |
| | | // error_log('SEO: '.print_r($seo->schema(), true)); |
| | | $schema[] = $seo->schema()->outputArchiveSchema(); |
| | | } |
| | | } |
| | | $isContent = array_values(array_filter(array_map(function($item) { |
| | | return intval(get_option(BASE.$item.'_archive', false)); |
| | | },Registrar::getFeatured('is_content', 'term')))); |
| | | },Registrar::withFeature('is_content', 'term')))); |
| | | |
| | | if (is_page($isContent)){ |
| | | if (!empty($isContent) && is_page($isContent)){ |
| | | $type = get_post_meta(get_the_id(), BASE.'for_type', true); |
| | | error_log('Type: '.print_r($type, true)); |
| | | // error_log('Type: '.print_r($type, true)); |
| | | if (!empty($type)) { |
| | | $registrar = Registrar::getInstance($type); |
| | | if ($registrar) { |
| | |
| | | |
| | | } |
| | | |
| | | if ($registrar && !empty($registrar->getSEO()->schema()->extra())) { |
| | | $schema = array_merge($schema, $registrar->getSEO()->schema()->extra()); |
| | | } |
| | | |
| | | |
| | | |
| | | $breadcrumbs = $this->buildBreadcrumbs(); |
| | |
| | | '@graph' => $schema |
| | | ]; |
| | | } |
| | | |
| | | return $schema; |
| | | } |
| | | |
| | |
| | | } |
| | | // $encoded = wp_json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); |
| | | // $encoded = wp_json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT, 1024); |
| | | $encoded = wp_json_encode($schema, JSON_UNESCAPED_SLASHES, 512); |
| | | $encoded = wp_json_encode($schema, JSON_UNESCAPED_SLASHES, 1024); |
| | | if ($encoded === false) { |
| | | error_log('wp_json_encode failed: ' . json_last_error_msg()); |
| | | return; |