Skip to content
wiki.fftac.org

Helpers - Source Excerpt 38

Back to Helpers

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/inc/helpers.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/inc/helpers.php

'copy' => 'Versioned doctrine snapshots with human gloss kept separate from canonical meaning.',
            'url' => spiralist_get_page_url('doctrine', '#doctrine'),
        ],
        [
            'title' => 'Protocol Versions',
            'copy' => 'Symbolic language specs, examples, and implementation notes for machine-facing consumers.',
            'url' => spiralist_get_page_url('uai-1', '#uai1'),
        ],
    ];
}

function spiralist_get_uai_document_shape(): string
{
    $shape = [
        'spec' => 'spiral-script-machine-document',
        'version' => '1.0.0',
        'documentId' => 'spiralist.example.page',
        'source' => [
            'uri' => 'https://spiralist.org/example/',
            'title' => 'Example Page',
            'retrievedAt' => '2026-04-13T00:00:00Z',
            'contentHash' => 'sha256:...',
        ],
        'metadata' => new stdClass(),
        'structure' => [],
        'semantics' => [],
        'symbols' => [],
        'assets' => [],
        'relationships' => [],
        'annotations' => [],
        'provenance' => [
            'generatedBy' => 'spiralist-theme',
            'generatedAt' => '2026-04-13T00:00:00Z',
            'mode' => 'manual',
        ],
        'extensions' => new stdClass(),
    ];

    return wp_json_encode($shape, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

function spiralist_get_current_symbol_payload(): string
{
    $symbols = spiralist_get_symbols();
    $first = $symbols[0];
    $browser_payload = spiralist_get_symbol_browser_payload($first);
    $payload = [
        'type' => 'symbol',
        'id' => $browser_payload['canonicalId'],
        'label' => $browser_payload['label'],
        'meaning' => $browser_payload['meaning'],
        'definition' => $browser_payload['definition'],
        'axioms' => $browser_payload['axiomIds'],
        'relations' => array_values(array_filter((array) ($first['related'] ?? []), 'is_string')),
        'transformationChain' => $browser_payload['transformationChain'],
        'provenance' => $browser_payload['provenance'],
    ];

    return wp_json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

function spiralist_get_editorial_excerpt(): string
{
    if (!is_singular()) {
        return '';
    }

    $post = get_queried_object();
    if (!$post instanceof WP_Post) {
        return '';
    }

    if (has_excerpt($post)) {
        return get_the_excerpt($post);
    }

    $content = trim(wp_strip_all_tags($post->post_content));
    if ($content === '') {
        return '';
    }

    return wp_trim_words($content, 35);
}

function spiralist_get_auth_notice(): array
{
    $notice = sanitize_key((string) get_query_var('notice'));
    if ($notice === '') {
        $notice = sanitize_key((string) ($_GET['notice'] ?? ''));
    }

    $error = sanitize_key((string) ($_GET['auth_error'] ?? ''));

    $messages = [
        'registered' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.registered', 'Your participant account is active. Welcome to Spiralist.')],
        'logged_in' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.logged_in', 'You are now signed in.')],
        'logged_out' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.logged_out', 'You have been logged out.')],
        'account_updated' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.account_updated', 'Your account details were updated.')],
        'pattern_submitted' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.pattern_submitted', 'Your pattern submission was recorded in the Spiralist system.')],
        'invalid_request' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.invalid_request', 'The request could not be verified. Please try again.')],
        'missing_fields' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.missing_fields', 'Please complete all required fields.')],
        'invalid_email' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.invalid_email', 'Enter a valid email address.')],
        'password_short' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.password_short', 'Use a password with at least 8 characters.')],
        'terms_required' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.terms_required', 'Review the linked site policies and confirm agreement before continuing.')],
        'age_confirmation_required' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.age_confirmation_required', 'Confirm that you meet the minimum age or guardian-permission requirement before continuing.')],
        'username_exists' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.username_exists', 'That username is already in use.')],
        'email_exists' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.email_exists', 'That email address is already registered.')],
        'registration_failed' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.registration_failed', 'Registration could not be completed. Please try again.')],
        'invalid_credentials' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.invalid_credentials', 'The username or password was not accepted.')],
        'password_reset_email' => ['type' => 'success', 'message' => spiralist_get_ui_text('notice.auth.password_reset_email', 'If an account matches that username or email, a password reset link has been sent.')],
        'pattern_invalid' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.pattern_invalid', 'Pattern submissions need at least a short title or a meaningful body of text.')],
        'membership_pending' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.membership_pending', 'This participant account is pending activation.')],
        'membership_suspended' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.membership_suspended', 'This participant account is suspended.')],
        'membership_cancelled' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.membership_cancelled', 'This participant account has been cancelled.')],
        'account_invalid_email' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.account_invalid_email', 'Enter a valid account email address.')],
        'account_email_exists' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.account_email_exists', 'That email address is already being used by another account.')],
        'account_terms_required' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.account_terms_required', 'Review the linked site policies and confirm agreement before saving your account.')],
        'account_age_confirmation_required' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.account_age_confirmation_required', 'Confirm that you meet the minimum age or guardian-permission requirement before saving your account.')],
        'account_update_failed' => ['type' => 'error', 'message' => spiralist_get_ui_text('notice.auth.account_update_failed', 'Your account could not be updated. Please try again.')],
    ];

    if ($notice !== '' && isset($messages[$notice])) {
        return $messages[$notice];
    }

    if ($error !== '' && isset($messages[$error])) {
        return $messages[$error];
    }

    return [];
}