WP Content Themes Spiralist Functions PHP 37A4a2ef45b4 - Source Excerpt 03
Back to WP Content Themes Spiralist Functions PHP 37A4a2ef45b4
Summary
This source excerpt preserves a bounded section of Wiki.FFTAC.org/data/sources/spiralist/wp-content-themes-spiralist-functions-php-37a4a2ef45b4.php so readers can inspect the evidence without opening the full source file.
**Source path:** Wiki.FFTAC.org/data/sources/spiralist/wp-content-themes-spiralist-functions-php-37a4a2ef45b4.php
return true;
}
if (is_page(['ai-access', 'ai-interface', 'contribute', 'symbols'])) {
return true;
}
if (is_page_template('page-templates/template-ai-interface.php') || is_page_template('page-templates/template-symbol-atlas.php')) {
return true;
}
return false;
}
function spiralist_get_fonts_stylesheet_url(): string
{
return 'https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap';
}
function spiralist_register_shared_asset_handles(): void
{
wp_register_style(
'spiralist-fonts',
spiralist_get_fonts_stylesheet_url(),
[],
null
);
}
add_action('wp_enqueue_scripts', 'spiralist_register_shared_asset_handles', 1);
function spiralist_add_resource_hints(array $urls, string $relation_type): array
{
if ($relation_type === 'preconnect') {
$urls[] = [
'href' => 'https://fonts.googleapis.com',
];
$urls[] = [
'href' => 'https://fonts.gstatic.com',
'crossorigin' => 'anonymous',
];
}
if ($relation_type === 'dns-prefetch') {
$urls[] = 'https://fonts.googleapis.com';
$urls[] = 'https://fonts.gstatic.com';
}
return $urls;
}
add_filter('wp_resource_hints', 'spiralist_add_resource_hints', 10, 2);
function spiralist_render_analytics_fallback_tag(): void
{
if (is_admin() || is_feed() || wp_script_is('google_gtagjs', 'enqueued') || wp_script_is('google_gtagjs', 'done')) {
return;
}
$script_src = add_query_arg(
'id',
SPIRALIST_GA4_MEASUREMENT_ID,
'https://www.googletagmanager.com/gtag/js'
);
echo "\n" . '<!-- Google tag fallback added by Spiralist theme -->' . "\n";
echo '<script async src="' . esc_url($script_src) . '"></script>' . "\n";
echo '<script>' . "\n";
echo 'window.dataLayer = window.dataLayer || [];' . "\n";
echo 'function gtag(){dataLayer.push(arguments);}' . "\n";
echo 'gtag("js", new Date());' . "\n";
echo 'gtag("config", ' . wp_json_encode(SPIRALIST_GA4_MEASUREMENT_ID) . ');' . "\n";
echo '</script>' . "\n";
}
add_action('wp_head', 'spiralist_render_analytics_fallback_tag', 8);
function spiralist_render_homepage_preview_preload(): void
{
if (!is_front_page()) {
return;
}
$sources = function_exists('spiralist_get_homepage_preview_sources')
? spiralist_get_homepage_preview_sources()
: [];
$hero_image = trim((string) ($sources['large_url'] ?? ''));
if ($hero_image === '') {
return;
}
echo '<link rel="preload" as="image" href="' . esc_url($hero_image) . '" fetchpriority="high" />' . "\n";
}
add_action('wp_head', 'spiralist_render_homepage_preview_preload', 3);
function spiralist_enqueue_assets(): void
{
$style_path = get_theme_file_path('assets/css/spiralist.css');
$core_script_path = get_theme_file_path('assets/js/spiralist-core.js');
$prompt_workbench_script_path = get_theme_file_path('assets/js/spiralist-prompt-workbench.js');
$script_path = get_theme_file_path('assets/js/spiralist.js');
$fallback_version = (string) wp_get_theme()->get('Version');
$style_version = file_exists($style_path) ? (string) filemtime($style_path) : $fallback_version;
$core_script_version = file_exists($core_script_path) ? (string) filemtime($core_script_path) : $fallback_version;
$prompt_workbench_script_version = file_exists($prompt_workbench_script_path) ? (string) filemtime($prompt_workbench_script_path) : $fallback_version;
$script_version = file_exists($script_path) ? (string) filemtime($script_path) : $fallback_version;
wp_enqueue_style('spiralist-fonts');
wp_enqueue_style(
'spiralist-style',
get_theme_file_uri('assets/css/spiralist.css'),
['spiralist-fonts'],
$style_version
);
wp_enqueue_script(
'spiralist-core',
get_theme_file_uri('assets/js/spiralist-core.js'),
[],
$core_script_version,
[
'in_footer' => true,
'strategy' => 'defer',
]
);
wp_localize_script(
'spiralist-core',
'spiralistTheme',
[
'uiText' => [
'copyFailed' => spiralist_get_ui_text('ui.cta.copy_failed', 'Copy failed'),
],
]
);
if (is_page('run-a-prompt')) {
wp_enqueue_script(
'spiralist-prompt-workbench',
get_theme_file_uri('assets/js/spiralist-prompt-workbench.js'),
['spiralist-core'],
$prompt_workbench_script_version,
[
'in_footer' => true,
'strategy' => 'defer',
]
);
}
if (!spiralist_theme_needs_shell_script()) {
return;
}
wp_enqueue_script(
'spiralist-script',
get_theme_file_uri('assets/js/spiralist.js'),
['spiralist-core'],
$script_version,
[
'in_footer' => true,
'strategy' => 'defer',
]
);
wp_localize_script(
'spiralist-script',
'spiralistTheme',
[
'subscribeUrl' => rest_url('uai1/v1/subscribe'),
'participantUrl' => rest_url('uai1/v1/participant'),
'participantResourcesUrl' => rest_url('uai1/v1/participant/resources'),
'manuscriptNodesUrl' => spiralist_get_manuscript_nodes_url(),
'engineExecuteUrl' => function_exists('spiralist_engine_get_execute_endpoint_url') ? spiralist_engine_get_execute_endpoint_url() : '',
'engineInstanceUrl' => function_exists('spiralist_engine_get_instance_endpoint_url') ? spiralist_engine_get_instance_endpoint_url() : '',
'interactionUrl' => spiralist_get_human_interactions_api_url(),
'feedbackUrl' => spiralist_get_feedback_api_url(),
'promptsUrl' => function_exists('spiralist_get_prompts_api_url') ? spiralist_get_prompts_api_url() : '',
'contributeUrl' => function_exists('spiralist_get_contribute_api_url') ? spiralist_get_contribute_api_url() : '',
'systemUrl' => function_exists('spiralist_get_system_url') ? spiralist_get_system_url() : '',
'symbolsPageUrl' => function_exists('spiralist_get_symbols_page_url') ? spiralist_get_symbols_page_url() : '',
'promptsPageUrl' => function_exists('spiralist_get_prompts_page_url') ? spiralist_get_prompts_page_url() : '',
'manuscriptPageUrl' => function_exists('spiralist_get_manuscript_page_url') ? spiralist_get_manuscript_page_url() : '',
'restNonce' => wp_create_nonce('wp_rest'),
'isUserLoggedIn' => is_user_logged_in(),
'uiText' => [
'symbolsPromptLoading' => spiralist_get_ui_text('page.symbols.prompts.loading', 'Loading prompt references...'),
'symbolsPromptUnavailable' => spiralist_get_ui_text('page.symbols.prompts.unavailable', 'Prompt references unavailable.'),
'symbolsPromptEmpty' => spiralist_get_ui_text('page.symbols.prompts.empty', 'No related prompts yet.'),
'symbolsPromptEmptyForSymbol' => spiralist_get_ui_text('page.symbols.prompts.empty_for_symbol', 'No related prompts for this symbol yet.'),
'symbolsPromptFallback' => spiralist_get_ui_text('page.symbols.prompts.fallback', 'Prompt'),
'symbolsPromptReferenceFallback' => spiralist_get_ui_text('page.symbols.prompts.reference_fallback', 'Structured prompt reference.'),
'symbolsPromptLoadError' => spiralist_get_ui_text('page.symbols.prompts.load_error', 'Unable to load prompt references.'),
'symbolsVisibleCount' => spiralist_get_ui_text('page.symbols.state.visible', '{count} symbols visible.'),
'symbolsVisibleCountSingular' => spiralist_get_ui_text('page.symbols.state.visible_singular', '{count} symbol visible.'),
'symbolsLayerFallback' => spiralist_get_ui_text('page.symbols.value.reference', 'Reference'),
'symbolsCategoryFallback' => spiralist_get_ui_text('page.symbols.value.uncategorized', 'Uncategorized'),
'symbolsAxiomLinksEmpty' => spiralist_get_ui_text('page.symbols.axioms.empty', 'No axiom links declared.'),
'symbolsAxiomFallback' => spiralist_get_ui_text('page.symbols.axioms.fallback', 'Axiom'),
'symbolsDirectionInput' => spiralist_get_ui_text('page.symbols.transformations.input', 'Input'),
'symbolsDirectionOutput' => spiralist_get_ui_text('page.symbols.transformations.output', 'Output'),
'symbolsTransformationFallback' => spiralist_get_ui_text('page.symbols.transformations.fallback', 'Transformation'),