Seo Schema - Source Excerpt 11
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/inc/seo-schema.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/themes/spiralist/inc/seo-schema.php
'urlTemplate' => function_exists('spiralist_get_contribute_api_url') ? spiralist_get_contribute_api_url() : rest_url('uai1/v1/contribute'),
'httpMethod' => 'POST',
'encodingType' => 'application/json',
'contentType' => 'application/json',
],
],
];
}
if ($surface === 'report') {
$report = spiralist_get_seo_report_context();
if (empty($report)) {
return [];
}
$published = (string) ($report['published'] ?? '');
$modified = (string) ($report['modified'] ?? $published);
return [
'@type' => 'Article',
'@id' => spiralist_schema_page_id('report'),
'headline' => (string) ($report['title'] ?? spiralist_get_seo_title()),
'name' => (string) ($report['title'] ?? spiralist_get_seo_title()),
'alternativeHeadline' => (string) ($report['subtitle'] ?? ''),
'description' => $description,
'url' => $canonical,
'mainEntityOfPage' => ['@id' => $page_id],
'datePublished' => $published !== '' ? gmdate('c', (int) strtotime($published)) : '',
'dateModified' => $modified !== '' ? gmdate('c', (int) strtotime($modified)) : '',
'author' => [
'@type' => 'Organization',
'name' => (string) ($report['author'] ?? 'Spiralist Research Archive'),
],
'publisher' => ['@id' => spiralist_schema_id('organization')],
'isPartOf' => ['@id' => spiralist_schema_id('website')],
'keywords' => array_values(array_filter((array) ($report['topics'] ?? []), 'is_string')),
'about' => array_values(array_filter((array) ($report['topics'] ?? []), 'is_string')),
'citation' => (string) ($report['source'] ?? ''),
];
}
if ($surface === 'prompts') {
$prompts = function_exists('spiralist_get_workspace_library_prompt_records')
? spiralist_get_workspace_library_prompt_records(20)
: [];
$items = [];
foreach ($prompts as $index => $prompt) {
$items[] = [
'@type' => 'ListItem',
'position' => $index + 1,
'url' => (string) ($prompt['links']['human'] ?? spiralist_get_workspace_prompt_url((string) ($prompt['slug'] ?? ''))),
'name' => (string) ($prompt['title'] ?? 'Prompt'),
];
}
return [
'@type' => 'ItemList',
'@id' => spiralist_schema_page_id('prompt-list'),
'name' => 'Spiralist Prompt Library',
'description' => $description,
'url' => $canonical,
'mainEntityOfPage' => ['@id' => $page_id],
'numberOfItems' => count($prompts),
'itemListElement' => $items,
];
}
if ($surface === 'prompt' && function_exists('spiralist_get_current_workspace_prompt_record')) {
$prompt = spiralist_get_current_workspace_prompt_record();
if (empty($prompt)) {
return [];
}
$tags = array_values(array_filter((array) ($prompt['tags'] ?? []), 'is_string'));
return [
'@type' => 'CreativeWork',
'@id' => spiralist_schema_page_id('prompt'),
'name' => (string) ($prompt['title'] ?? spiralist_get_seo_title()),
'description' => (string) ($prompt['summary'] ?? $description),
'url' => $canonical,
'mainEntityOfPage' => ['@id' => $page_id],
'identifier' => (string) ($prompt['source_slug'] ?? $prompt['slug'] ?? $prompt['id'] ?? ''),
'version' => (string) ($prompt['source_version'] ?? $prompt['version_number'] ?? ''),
'creator' => [
'@type' => 'Person',
'name' => (string) ($prompt['author_label'] ?? 'Spiralist'),
],
'dateCreated' => (string) ($prompt['created_utc'] ?? ''),
'dateModified' => (string) ($prompt['updated_utc'] ?? ''),
'keywords' => $tags,
'about' => array_values(array_filter(
array_map(
'strval',
array_merge([(string) ($prompt['prompt_type'] ?? 'prompt')], $tags)
),
static function (string $item): bool {
return trim($item) !== '';
}
)),
];
}
if ($surface === 'what-is-a-spiralist') {
return spiralist_schema_defined_term(
[
'name' => 'Spiralist',
'termCode' => 'spiralist.term.spiralist',
'description' => function_exists('spiralist_get_spiralist_definition') ? spiralist_get_spiralist_definition() : $description,
],
''
);
}
return [];
}
function spiralist_schema_page_type(string $surface): string
{
if ($surface === 'manuscript') {
$context = spiralist_get_seo_manuscript_context();
return (string) ($context['requested_folio'] ?? '') !== '' ? 'WebPage' : 'CollectionPage';
}
if ($surface === 'gallery') {
return function_exists('spiralist_get_requested_gallery_asset') && !empty(spiralist_get_requested_gallery_asset())
? 'WebPage'
: 'CollectionPage';
}
if (in_array($surface, ['reports', 'research', 'symbols', 'prompts', 'study'], true)) {
return 'CollectionPage';
}
if (function_exists('spiralist_get_sovereignty_page_record') && !empty(spiralist_get_sovereignty_page_record($surface))) {
return 'WebPage';
}