Skip to content
wiki.fftac.org

Admin Pages - Source Excerpt 01

Back to Admin Pages

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/ns12-manuscript/includes/admin-pages.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/ns12-manuscript/includes/admin-pages.php

<?php

if (!defined('ABSPATH')) {
    exit;
}

function spiralist_book_pages_admin_render_notice(): void
{
    $notice = spiralist_book_pages_admin_get_notice();
    if (empty($notice['message'])) {
        return;
    }

    $type = (string) ($notice['type'] ?? 'success');
    $class = $type === 'error' ? 'notice notice-error' : ($type === 'warning' ? 'notice notice-warning' : 'notice notice-success');
    ?>
    <div class="<?php echo esc_attr($class); ?>">
        <p><?php echo esc_html((string) $notice['message']); ?></p>
        <?php if (!empty($notice['details'])) : ?>
            <ul style="margin-top: 0;">
                <?php foreach ((array) $notice['details'] as $detail) : ?>
                    <li><?php echo esc_html((string) $detail); ?></li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
    </div>
    <?php
}

function spiralist_book_pages_admin_header(string $title, string $copy, array $actions = []): void
{
    spiralist_book_pages_admin_render_styles();
    ?>
    <div class="wrap spiralist-book-admin">
        <?php spiralist_book_pages_admin_render_notice(); ?>
        <section class="hero">
            <div>
                <p class="kicker"><?php echo esc_html(spiralist_book_pages_get_public_name()); ?></p>
                <h1><?php echo esc_html($title); ?></h1>
                <p><?php echo esc_html($copy); ?></p>
            </div>
            <?php if (!empty($actions)) : ?>
                <div class="actions">
                    <?php foreach ($actions as $action) : ?>
                        <?php
                        $label = (string) ($action['label'] ?? '');
                        $url = (string) ($action['url'] ?? '');
                        $class = (string) ($action['class'] ?? 'button');
                        if ($label === '' || $url === '') {
                            continue;
                        }
                        ?>
                        <a class="<?php echo esc_attr($class); ?>" href="<?php echo esc_url($url); ?>"><?php echo esc_html($label); ?></a>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </section>
    <?php
}

function spiralist_book_pages_admin_footer(): void
{
    echo '</div>';
}

function spiralist_book_pages_admin_render_overview(): void
{
    if (!spiralist_book_pages_admin_can_manage()) {
        wp_die('You are not allowed to manage ' . spiralist_book_pages_get_public_name() . '.');
    }

    $folios = spiralist_book_pages_admin_folios();
    $prompts = function_exists('spiralist_book_pages_get_content_prompt_meta_map') ? (array) spiralist_book_pages_get_content_prompt_meta_map() : [];
    $fragments = spiralist_book_pages_admin_shared_fragments();
    $book = spiralist_book_pages_admin_book_definition();
    $manuscript_url = function_exists('spiralist_book_pages_get_manuscript_page_url') ? spiralist_book_pages_get_manuscript_page_url() : '';
    $symbols_url = function_exists('spiralist_book_pages_get_symbols_page_url') ? spiralist_book_pages_get_symbols_page_url() : '';
    $prompts_url = function_exists('spiralist_book_pages_get_prompts_page_url') ? spiralist_book_pages_get_prompts_page_url() : '';
    $attention = 0;

    foreach ($folios as $folio) {
        $payload = function_exists('spiralist_book_pages_get_book_page_creation_prompt_payload') ? spiralist_book_pages_get_book_page_creation_prompt_payload($folio) : [];
        if (!empty($payload['needs_attention'])) {
            $attention++;
        }
    }

    spiralist_book_pages_admin_header(
        'Manuscript Overview',
        'Launch, import, edit, and maintain the full folio reading experience from one WordPress admin surface.',
        [
            ['label' => 'Open Manuscript', 'url' => $manuscript_url !== '' ? $manuscript_url : home_url('/manuscript/'), 'class' => 'button button-primary'],
            ['label' => 'Import Folios', 'url' => spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('folios')) . '#bulk-import', 'class' => 'button'],
            ['label' => 'Manage Prompts', 'url' => spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('prompts')), 'class' => 'button'],
        ]
    );
    ?>
        <section class="grid">
            <div class="panel"><div class="metric"><span class="kicker">Folio Inventory</span><strong><?php echo esc_html((string) count($folios)); ?></strong><span>File-backed manuscript folios inside the canonical reading sequence.</span></div></div>
            <div class="panel"><div class="metric"><span class="kicker">Prompt Library</span><strong><?php echo esc_html((string) count($prompts)); ?></strong><span>Prompt packages currently stored in the persistent folio registry.</span></div></div>
            <div class="panel"><div class="metric"><span class="kicker">Shared Fragments</span><strong><?php echo esc_html((string) count($fragments)); ?></strong><span>Reusable top-of-prompt blocks that keep the corpus consistent.</span></div></div>
            <div class="panel"><div class="metric"><span class="kicker">Prompt Attention</span><strong><?php echo esc_html((string) $attention); ?></strong><span>Folio dossiers that still need a resolved public prompt record.</span></div></div>
        </section>

        <section class="dual">
            <div class="stack">
                <div class="panel">
                    <p class="kicker">Quick Start</p>
                    <h2>Set up a polished manuscript surface in minutes</h2>
                    <ol style="margin:0;padding-left:18px;">
                        <li>Open the public manuscript and confirm the reading surface is live.</li>
                        <li>Import folios in bulk, then tune order, titles, and the study surface.</li>
                        <li>Link prompt records so each folio keeps a complete dossier.</li>
                        <li>Rebuild cache after file-backed edits to refresh the live reader.</li>
                    </ol>
                </div>
                <div class="panel">
                    <p class="kicker">What Publishers Like</p>
                    <h2>Patterns that make folio plugins feel premium</h2>
                    <ul>
                        <li>Fast import workflows for image or PDF sources, with minimal manual setup.</li>
                        <li>Responsive reading surfaces that work cleanly on desktop and mobile.</li>
                        <li>Clear page navigation through thumbnails, sequence controls, and direct links.</li>
                        <li>Flexible viewer controls like zoom, fullscreen, or alternate reading modes.</li>
                        <li>Easy editorial control over metadata, prompt linkage, and reusable templates.</li>
                    </ul>
                </div>
                <div class="panel">
                    <p class="kicker">Why This Shines</p>
                    <h2>Operational improvements now built in</h2>
                    <ul>
                        <li>Bulk folio import writes the asset file, the folio JSON record, and the manuscript order entry together.</li>
                        <li>Prompt imports can link back to folios automatically so the dossier stays resolved.</li>
                        <li>Shared fragments let you edit the common top section of many prompts in one place.</li>
                        <li>Cache rebuilds are available directly in admin, so file-backed changes surface immediately.</li>
                    </ul>
                </div>
            </div>
            <div class="stack">
                <div class="panel">
                    <p class="kicker">Manuscript Surface</p>
                    <h2>Publishing snapshot</h2>
                    <p><strong>Study surface:</strong> <?php echo esc_html((string) ($book['study_surface_slug'] ?? '')); ?></p>
                    <p><strong>Public manuscript:</strong> <?php if ($manuscript_url !== '') : ?><a href="<?php echo esc_url($manuscript_url); ?>">Open manuscript surface</a><?php else : ?>Unavailable<?php endif; ?></p>
                    <p><strong>Symbols:</strong> <?php if ($symbols_url !== '') : ?><a href="<?php echo esc_url($symbols_url); ?>">Open symbols surface</a><?php else : ?>Unavailable<?php endif; ?></p>
                    <p><strong>Prompts:</strong> <?php if ($prompts_url !== '') : ?><a href="<?php echo esc_url($prompts_url); ?>">Open prompts surface</a><?php else : ?>Unavailable<?php endif; ?></p>
                    <p><strong>Asset folder:</strong> <code><?php echo esc_html((string) (spiralist_book_pages_admin_asset_directory(true)['path'] ?? 'Unavailable')); ?></code></p>