Admin Pages - Source Excerpt 04
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
<p><label for="spiralist-prompt-import-file"><strong>JSON file</strong></label><br /><input id="spiralist-prompt-import-file" type="file" name="prompt_import_file" accept=".json,application/json" /></p>
<p class="inline"><label><input type="checkbox" name="overwrite_existing" value="1" /> <span>Overwrite matching slugs</span></label></p>
</div>
<p><label for="spiralist-prompt-import-json"><strong>JSON payload</strong></label><br /><textarea id="spiralist-prompt-import-json" class="large-text code" rows="10" name="prompt_import_json" placeholder='[{"slug":"new-folio","title":"New Folio","folio_slug":"new-folio","filename":"New_Folio.png","extends":["base-image-folio","base-concordance-folio"],"body":"Create a museum-grade manuscript folio..."}]'></textarea></p>
<p><button class="button button-primary" type="submit">Import Prompts</button></p>
</form>
</section>
<section class="toolbar">
<form class="search" method="get" action="<?php echo esc_url(admin_url('admin.php')); ?>">
<input type="hidden" name="page" value="<?php echo esc_attr(spiralist_book_pages_admin_page_slug('prompts')); ?>" />
<input type="search" name="s" value="<?php echo esc_attr($search); ?>" placeholder="Search prompts by title, slug, filename, section, or tags" />
<button class="button" type="submit">Search</button>
<?php if ($search !== '') : ?><a class="button-link" href="<?php echo esc_url(spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('prompts'))); ?>">Reset</a><?php endif; ?>
</form>
<span><?php echo esc_html(sprintf('%d result%s', count($filtered), count($filtered) === 1 ? '' : 's')); ?></span>
</section>
<?php if (empty($filtered)) : ?>
<div class="empty"><p>No prompts matched the current search.</p></div>
<?php else : ?>
<table class="widefat striped">
<thead><tr><th>Prompt</th><th>Section</th><th>Fragments</th><th>Status</th><th>Actions</th></tr></thead>
<tbody>
<?php foreach ($filtered as $slug => $meta) : ?>
<?php $status_label = (string) ($meta['moderation_status'] ?? ($meta['prompt_status'] ?? 'draft')); $tone = $status_label === 'approved' ? 'good' : ($status_label === 'restricted' ? 'bad' : 'warn'); ?>
<tr>
<td><strong><?php echo esc_html((string) ($meta['title'] ?? $slug)); ?></strong><br /><code><?php echo esc_html((string) $slug); ?></code><br /><span><?php echo esc_html((string) ($meta['filename'] ?? '')); ?></span></td>
<td><?php echo esc_html((string) ($sections[(string) ($meta['section_slug'] ?? '')]['label'] ?? spiralist_book_pages_admin_humanize((string) ($meta['section_slug'] ?? 'appendix')))); ?></td>
<td><?php echo esc_html(implode(', ', (array) ($meta['extends'] ?? []))); ?></td>
<td><?php echo wp_kses_post(spiralist_book_pages_admin_badge(spiralist_book_pages_admin_humanize($status_label), $tone)); ?></td>
<td><div class="tight-actions"><a class="button button-small" href="<?php echo esc_url(spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('prompts'), ['edit' => $slug])); ?>">Edit</a><?php if (!empty($meta['folio_slug'])) : ?><a class="button button-small" href="<?php echo esc_url(spiralist_book_pages_admin_url(spiralist_book_pages_admin_page_slug('folios'), ['edit' => (string) $meta['folio_slug']])); ?>">Folio</a><?php endif; ?></div></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if ($edit_slug !== '' && !empty($prompts[$edit_slug])) : ?>
<?php
$meta = $prompts[$edit_slug];
$body = spiralist_book_pages_admin_prompt_body($edit_slug);
$composed = function_exists('spiralist_book_pages_get_content_prompt_definition') ? spiralist_book_pages_get_content_prompt_definition($edit_slug) : [];
$active_extends = array_fill_keys(array_values(array_filter(array_map('sanitize_title', (array) ($meta['extends'] ?? [])), 'strlen')), true);
?>
<section class="dual" style="margin-top:18px;">
<div class="panel">
<p class="kicker">Edit Prompt</p>
<h2><?php echo esc_html((string) ($meta['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_prompt" />
<input type="hidden" name="return_page" value="<?php echo esc_attr(spiralist_book_pages_admin_page_slug('prompts')); ?>" />
<input type="hidden" name="prompt_slug" value="<?php echo esc_attr($edit_slug); ?>" />
<input type="hidden" name="source_version" value="<?php echo esc_attr((string) ($meta['source_version'] ?? '1.0.0')); ?>" />
<?php wp_nonce_field('spiralist_book_pages_save_prompt'); ?>
<table class="form-table" role="presentation"><tbody>
<tr><th scope="row">Slug</th><td><code><?php echo esc_html($edit_slug); ?></code></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-title">Title</label></th><td><input id="spiralist-prompt-title" class="regular-text" type="text" name="title" value="<?php echo esc_attr((string) ($meta['title'] ?? '')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-summary">Summary</label></th><td><textarea id="spiralist-prompt-summary" class="large-text" rows="3" name="summary"><?php echo esc_textarea((string) ($meta['summary'] ?? '')); ?></textarea></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-author">Author Label</label></th><td><input id="spiralist-prompt-author" class="regular-text" type="text" name="author_label" value="<?php echo esc_attr((string) ($meta['author_label'] ?? '')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-category">Category</label></th><td><input id="spiralist-prompt-category" class="regular-text" type="text" name="category" value="<?php echo esc_attr((string) ($meta['category'] ?? '')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-subcategory">Subcategory</label></th><td><input id="spiralist-prompt-subcategory" class="regular-text" type="text" name="subcategory" value="<?php echo esc_attr((string) ($meta['subcategory'] ?? '')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-type">Prompt Type</label></th><td><input id="spiralist-prompt-type" class="regular-text" type="text" name="prompt_type" value="<?php echo esc_attr((string) ($meta['prompt_type'] ?? 'image')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-language">Language</label></th><td><input id="spiralist-prompt-language" class="regular-text" type="text" name="language" value="<?php echo esc_attr((string) ($meta['language'] ?? 'all')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-status">Prompt Status</label></th><td><input id="spiralist-prompt-status" class="regular-text" type="text" name="prompt_status" value="<?php echo esc_attr((string) ($meta['prompt_status'] ?? 'published')); ?>" /></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-moderation">Moderation Status</label></th><td><input id="spiralist-prompt-moderation" class="regular-text" type="text" name="moderation_status" value="<?php echo esc_attr((string) ($meta['moderation_status'] ?? 'approved')); ?>" /></td></tr>
<tr><th scope="row">Featured</th><td><label><input type="checkbox" name="featured" value="1" <?php checked(!empty($meta['featured'])); ?> /> <span>Feature this prompt in the public archive.</span></label></td></tr>
<tr><th scope="row"><label for="spiralist-prompt-filename">Filename</label></th><td><input id="spiralist-prompt-filename" class="regular-text" type="text" name="filename" value="<?php echo esc_attr((string) ($meta['filename'] ?? '')); ?>" /></td></tr>