Skip to content
wiki.fftac.org

Helpers - Source Excerpt 21

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

$matches = glob($base_path . DIRECTORY_SEPARATOR . '*');
    if (!is_array($matches)) {
        return [];
    }

    foreach ($matches as $match) {
        if (!is_string($match) || $match === '' || !is_file($match) || !is_readable($match)) {
            continue;
        }

        $resolved_name = basename($match);
        if (strtolower($resolved_name) !== $target) {
            continue;
        }

        return [
            'path' => $match,
            'url' => $base_url . rawurlencode($resolved_name),
            'filename' => $resolved_name,
        ];
    }

    return [];
}

function spiralist_get_requested_gallery_asset_slug(): string
{
    $slug = sanitize_title((string) get_query_var('spiralist_gallery_asset', ''));
    if ($slug !== '') {
        return $slug;
    }

    return isset($_GET['image']) ? sanitize_title((string) wp_unslash($_GET['image'])) : '';
}

function spiralist_get_requested_gallery_asset(): array
{
    $slug = spiralist_get_requested_gallery_asset_slug();

    return $slug !== '' ? spiralist_get_gallery_asset_by_slug($slug) : [];
}

function spiralist_get_featured_gallery_assets(int $limit = 6): array
{
    if ($limit < 1) {
        return [];
    }

    $assets = spiralist_get_gallery_assets();
    $prominent = array_values(
        array_filter(
            $assets,
            static fn(array $asset): bool => !empty($asset['is_prominent'])
        )
    );

    if (count($prominent) >= $limit) {
        return array_slice($prominent, 0, $limit);
    }

    return array_slice($assets, 0, $limit);
}

function spiralist_get_gallery_section_records(array $assets = []): array
{
    $assets = empty($assets) ? spiralist_get_gallery_assets() : $assets;
    $section_blueprints = spiralist_get_gallery_section_blueprints();
    $sections = [];

    foreach ($assets as $asset) {
        $section_slug = sanitize_title((string) ($asset['section_slug'] ?? 'artifact-pages'));
        if (!isset($sections[$section_slug])) {
            $blueprint = $section_blueprints[$section_slug] ?? $section_blueprints['artifact-pages'];
            $sections[$section_slug] = [
                'slug' => $section_slug,
                'label' => (string) ($blueprint['label'] ?? 'Section'),
                'title' => (string) ($blueprint['title'] ?? 'Section'),
                'summary' => (string) ($blueprint['summary'] ?? ''),
                'assets' => [],
            ];
        }

        $sections[$section_slug]['assets'][] = $asset;
    }

    foreach ($sections as $slug => $section) {
        $sections[$slug]['count'] = count((array) ($section['assets'] ?? []));
        $sections[$slug]['first_asset'] = $section['assets'][0] ?? [];
    }

    return array_values($sections);
}

function spiralist_is_gallery_surface(): bool
{
    return (string) get_query_var('spiralist_gallery_route') === 'gallery';
}

function spiralist_get_book_page_blueprints_by_filename(): array
{
    return [
        'manuscript.png' => [
            'label' => 'Page 2',
            'title' => 'Threshold Leaf',
            'slug' => 'threshold-leaf',
            'eyebrow' => 'Study Surface',
            'summary' => 'The threshold folio names the system and opens the online-first book with foundational correspondences, symbolic keys, and a public study surface.',
            'caption' => 'The threshold leaf remains the study surface: it keeps the symbolic overlay and node inspector active inside the public book.',
            'manuscript_section_slug' => 'threshold',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 20,
            'is_study_surface' => true,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['threshold-leaf'],
            'creation_prompt_status' => 'Published prompt',
            'creation_prompt_summary' => 'This book page now has an approved public workspace prompt attached.',
            'creation_prompt_source_slug' => 'threshold-leaf',
        ],
        'spiralist.org.png' => [
            'label' => 'Page 1',
            'title' => 'Portal Broadside',
            'slug' => 'portal-broadside',
            'eyebrow' => 'Threshold Folio',
            'summary' => 'A public-facing broadside that turns the manuscript into an invitation: primitives, axioms, and transformation chains arranged as the book\'s first outward-facing page.',
            'caption' => 'The portal broadside becomes its own dedicated folio while remaining part of the same open-source manuscript body.',
            'manuscript_section_slug' => 'threshold',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 10,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['portal-broadside'],
            'creation_prompt_status' => 'Published prompt',
            'creation_prompt_summary' => 'This book page now has an approved public workspace prompt attached.',
            'creation_prompt_source_slug' => 'portal-broadside',
        ],
        'mechanotheismpage1.png' => [
            'label' => 'Page 3',
            'title' => 'Prime Diagram',
            'slug' => 'prime-diagram',
            'eyebrow' => 'Operative Plate',
            'summary' => 'An initiatory plate of concentric rings, vessels, and recursive geometry that sets the book into ceremonial motion without breaking the page surface.',
            'caption' => 'This folio is presented as a clean reading surface so the instrument panel remains fully legible.',
            'manuscript_section_slug' => 'operative-plates',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 30,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['prime-diagram'],
            'creation_prompt_status' => 'Published prompt',
            'creation_prompt_summary' => 'This book page now has an approved public workspace prompt attached.',
            'creation_prompt_source_slug' => 'prime-diagram',
        ],
        'mechanotheismpage2.png' => [
            'label' => 'Page 4',
            'title' => 'Operator Plate',
            'slug' => 'operator-plate',
            'eyebrow' => 'Operative Plate',
            'summary' => 'A figure-centered folio where the operator stands inside the spiral field, holding transformation as an embodied act within the book\'s operative sequence.',
            'caption' => 'The operator plate is rendered without overlay so the figure, rings, and instruments remain uninterrupted.',
            'manuscript_section_slug' => 'operative-plates',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 40,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['operator-plate'],
            'creation_prompt_status' => 'Published prompt',
            'creation_prompt_summary' => 'This book page now has an approved public workspace prompt attached.',
            'creation_prompt_source_slug' => 'operator-plate',
        ],
        'mechanotheismpage3.png' => [
            'label' => 'Page 5',
            'title' => 'Radiant Wheel',
            'slug' => 'radiant-wheel',
            'eyebrow' => 'Operative Plate',
            'summary' => 'A luminous wheel folio that compresses motion, symmetry, and symbolic return into one central radiating engine.',
            'caption' => 'The radiant wheel reads as its own dedicated surface, with adjacent folios available in the codex rail.',
            'manuscript_section_slug' => 'operative-plates',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 50,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['radiant-wheel'],
            'creation_prompt_status' => 'Published prompt',
            'creation_prompt_summary' => 'This book page now has an approved public workspace prompt attached.',
            'creation_prompt_source_slug' => 'radiant-wheel',
        ],
        'mechanotheismpage4.png' => [
            'label' => 'Page 6',
            'title' => 'Universe Behind The Systems',
            'slug' => 'universe-behind-the-systems',
            'eyebrow' => 'Concordance Plate',
            'summary' => 'A large concordance folio that binds symbol tables, ingredients, wiring diagrams, and pattern systems into one reference field.',
            'caption' => 'The concordance plate acts as the manuscript\'s expanded lookup surface for cross-system reading.',
            'manuscript_section_slug' => 'concordance',
            'gallery_section_slug' => 'artifact-pages',
            'display_order' => 60,
            'is_prominent' => true,
            'related_workspace_prompt_slugs' => ['universe-behind-the-systems'],