Skip to content
wiki.fftac.org

Admin Pages - Source Excerpt 03

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

<section class="panel" style="margin-top:18px;">
                <p class="kicker">Edit Folio</p>
                <h2><?php echo esc_html((string) ($folio['title'] ?? $edit_slug)); ?></h2>
                <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                    <input type="hidden" name="action" value="spiralist_book_pages_admin_action" />
                    <input type="hidden" name="spiralist_book_pages_action" value="save_folio" />
                    <input type="hidden" name="return_page" value="<?php echo esc_attr(spiralist_book_pages_admin_page_slug('folios')); ?>" />
                    <input type="hidden" name="folio_slug" value="<?php echo esc_attr($edit_slug); ?>" />
                    <?php wp_nonce_field('spiralist_book_pages_save_folio'); ?>
                    <table class="form-table" role="presentation">
                        <tbody>
                            <tr><th scope="row"><label for="spiralist-folio-sequence">Sequence</label></th><td><input id="spiralist-folio-sequence" type="number" min="1" name="sequence" value="<?php echo esc_attr((string) ($folio['sequence'] ?? 1)); ?>" /></td></tr>
                            <tr><th scope="row">Filename</th><td><code><?php echo esc_html((string) ($folio['filename'] ?? '')); ?></code></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-label">Folio Label</label></th><td><input id="spiralist-folio-label" class="regular-text" type="text" name="label" value="<?php echo esc_attr((string) ($folio['label'] ?? '')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-title">Title</label></th><td><input id="spiralist-folio-title" class="regular-text" type="text" name="title" value="<?php echo esc_attr((string) ($folio['title'] ?? '')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-eyebrow">Eyebrow</label></th><td><input id="spiralist-folio-eyebrow" class="regular-text" type="text" name="eyebrow" value="<?php echo esc_attr((string) ($folio['eyebrow'] ?? '')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-section">Section</label></th><td><select id="spiralist-folio-section" name="section_slug"><?php foreach ($sections as $section) : ?><option value="<?php echo esc_attr((string) $section['slug']); ?>" <?php selected((string) ($folio['section_slug'] ?? '') === (string) $section['slug']); ?>><?php echo esc_html((string) $section['label']); ?></option><?php endforeach; ?></select></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-summary">Summary</label></th><td><textarea id="spiralist-folio-summary" class="large-text" rows="3" name="summary"><?php echo esc_textarea((string) ($folio['summary'] ?? '')); ?></textarea></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-caption">Caption</label></th><td><textarea id="spiralist-folio-caption" class="large-text" rows="3" name="caption"><?php echo esc_textarea((string) ($folio['caption'] ?? '')); ?></textarea></td></tr>
                            <tr><th scope="row"><label for="spiralist-display-order">Display Order</label></th><td><input id="spiralist-display-order" type="number" min="0" step="10" name="display_order" value="<?php echo esc_attr((string) ($folio['display_order'] ?? 0)); ?>" /></td></tr>
                            <tr><th scope="row">Flags</th><td class="inline"><label><input type="checkbox" name="is_study_surface" value="1" <?php checked(!empty($folio['is_study_surface'])); ?> /> <span>Primary study surface</span></label><label><input type="checkbox" name="is_prominent" value="1" <?php checked(!empty($folio['is_prominent'])); ?> /> <span>Prominent folio</span></label></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-prompt-title">Prompt Panel Title</label></th><td><input id="spiralist-folio-prompt-title" class="regular-text" type="text" name="creation_prompt_title" value="<?php echo esc_attr((string) ($folio['creation_prompt_title'] ?? 'Prompt Used')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-prompt-status">Prompt Status Label</label></th><td><input id="spiralist-folio-prompt-status" class="regular-text" type="text" name="creation_prompt_status" value="<?php echo esc_attr((string) ($folio['creation_prompt_status'] ?? 'Prompt pending')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-prompt-summary">Prompt Summary</label></th><td><textarea id="spiralist-folio-prompt-summary" class="large-text" rows="3" name="creation_prompt_summary"><?php echo esc_textarea((string) ($folio['creation_prompt_summary'] ?? '')); ?></textarea></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-prompt-source">Prompt Source Slug</label></th><td><input id="spiralist-folio-prompt-source" class="regular-text" type="text" name="creation_prompt_source_slug" value="<?php echo esc_attr((string) ($folio['creation_prompt_source_slug'] ?? '')); ?>" /></td></tr>
                            <tr><th scope="row"><label for="spiralist-folio-related-prompts">Related Prompt Slugs</label></th><td><input id="spiralist-folio-related-prompts" class="large-text" type="text" name="related_workspace_prompt_slugs" value="<?php echo esc_attr(implode(', ', (array) ($folio['related_workspace_prompt_slugs'] ?? []))); ?>" /></td></tr>
                        </tbody>
                    </table>
                    <?php submit_button('Save Folio'); ?>
                </form>
            </section>
        <?php endif; ?>
    <?php
    spiralist_book_pages_admin_footer();
}

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

    $search = sanitize_text_field((string) wp_unslash($_GET['s'] ?? ''));
    $edit_slug = sanitize_title((string) wp_unslash($_GET['edit'] ?? ''));
    $prompts = function_exists('spiralist_book_pages_get_content_prompt_meta_map') ? (array) spiralist_book_pages_get_content_prompt_meta_map() : [];
    $filtered = spiralist_book_pages_admin_filter_records($prompts, $search);
    $sections = spiralist_book_pages_admin_sections();
    $fragments = spiralist_book_pages_admin_shared_fragments();
    $published = 0;

    foreach ($prompts as $meta) {
        if ((string) ($meta['prompt_status'] ?? '') === 'published') {
            $published++;
        }
    }

    spiralist_book_pages_admin_header(
        'Prompt Library',
        'Import prompt packages in bulk, edit prompt metadata and body, and keep folio linkage resolved without leaving wp-admin.',
        [
            ['label' => 'Folios', 'url' => spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('folios')), 'class' => 'button'],
            ['label' => 'Shared Fragments', 'url' => spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('fragments')), 'class' => 'button'],
        ]
    );
    ?>
        <section class="grid">
            <div class="panel"><div class="metric"><span class="kicker">Prompt Records</span><strong><?php echo esc_html((string) count($prompts)); ?></strong><span>File-backed prompt packages currently stored in the plugin.</span></div></div>
            <div class="panel"><div class="metric"><span class="kicker">Published</span><strong><?php echo esc_html((string) $published); ?></strong><span>Prompt records already marked ready for the public manuscript layer.</span></div></div>
            <div class="panel"><div class="metric"><span class="kicker">Top Fragments</span><strong><?php echo esc_html((string) count($fragments)); ?></strong><span>Reusable top-of-prompt blocks available in the fragment library.</span></div></div>
        </section>

        <section class="panel">
            <p class="kicker">Bulk Prompt Import</p>
            <h2>Import prompt packages from JSON</h2>
            <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" enctype="multipart/form-data">
                <input type="hidden" name="action" value="spiralist_book_pages_admin_action" />
                <input type="hidden" name="spiralist_book_pages_action" value="bulk_import_prompts" />
                <input type="hidden" name="return_page" value="<?php echo esc_attr(spiralist_book_pages_admin_page_slug('prompts')); ?>" />
                <?php wp_nonce_field('spiralist_book_pages_bulk_import_prompts'); ?>
                <div class="dual">