Page Manuscript Collaboration - Source Excerpt 01
Back to Page Manuscript Collaboration
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/ns12-manuscript/templates/page-manuscript-collaboration.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/ns12-manuscript/templates/page-manuscript-collaboration.php
<?php
if (!defined('ABSPATH')) {
exit;
}
get_header();
$mode = spiralist_book_pages_get_manuscript_route_mode();
$submission_slug = spiralist_book_pages_get_requested_manuscript_submission_slug();
$profile_slug = spiralist_book_pages_get_requested_manuscript_profile_slug();
$share_token = sanitize_text_field((string) wp_unslash($_GET['share'] ?? ''));
$notice = spiralist_book_pages_get_collaboration_notice();
$set_404 = static function (): void {
global $wp_query;
if ($wp_query instanceof WP_Query) {
$wp_query->set_404();
}
status_header(404);
nocache_headers();
};
$format_date = static function (string $value): string {
if ($value === '') {
return '';
}
$timestamp = strtotime($value);
return $timestamp ? wp_date('F j, Y', $timestamp) : $value;
};
$render_badge = static function (string $label, string $tone = 'neutral'): void {
$class = 'spiralist-collaboration-badge spiralist-collaboration-badge--' . sanitize_html_class($tone !== '' ? $tone : 'neutral');
echo '<span class="' . esc_attr($class) . '">' . esc_html($label) . '</span>';
};
$render_notice = static function (array $current_notice): void {
if (empty($current_notice['message'])) {
return;
}
$tone = (string) ($current_notice['type'] ?? 'success') === 'error' ? 'bad' : 'good';
?>
<div class="spiralist-collaboration-notice spiralist-collaboration-notice--<?php echo esc_attr($tone); ?>">
<p><?php echo esc_html((string) $current_notice['message']); ?></p>
</div>
<?php
};
$render_image = static function (array $copy, string $title): void {
$image_url = (string) ($copy['image_url'] ?? '');
if ($image_url === '') {
?>
<div class="spiralist-collaboration-image spiralist-collaboration-image--empty">
<span>No manuscript image has been saved yet.</span>
</div>
<?php
return;
}
?>
<figure class="spiralist-collaboration-image">
<img src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr((string) ($copy['alt'] ?? $title)); ?>" loading="lazy" decoding="async" />
</figure>
<?php
};
$render_record_card = static function (array $record, bool $show_private_links = false) use ($render_badge, $format_date): void {
$copy = !empty($record['public_copy']) ? (array) $record['public_copy'] : (array) ($record['working_copy'] ?? []);
$badge_label = !$show_private_links && !empty($record['has_public_copy'])
? 'Published'
: (string) ($record['status_label'] ?? 'Draft');
$badge_tone = !$show_private_links && !empty($record['has_public_copy'])
? 'good'
: (string) ($record['status_tone'] ?? 'neutral');
?>
<article class="spiralist-collaboration-card">
<?php if (!empty($copy['thumbnail_url'])) : ?>
<a class="spiralist-collaboration-card__image" href="<?php echo esc_url(!empty($record['public_url']) ? (string) $record['public_url'] : (string) ($record['studio_url'] ?? '#')); ?>">
<img src="<?php echo esc_url((string) $copy['thumbnail_url']); ?>" alt="<?php echo esc_attr((string) ($copy['alt'] ?? ($copy['title'] ?? 'Manuscript page'))); ?>" loading="lazy" decoding="async" />
</a>
<?php endif; ?>
<div class="spiralist-collaboration-card__body">
<div class="spiralist-collaboration-card__meta">
<?php $render_badge($badge_label, $badge_tone); ?>
<?php if (!empty($record['author']['display_name'])) : ?>
<span>By <?php echo esc_html((string) $record['author']['display_name']); ?></span>
<?php endif; ?>
</div>
<h2><?php echo esc_html((string) ($copy['title'] ?? ($record['slug'] ?? 'Manuscript Page'))); ?></h2>
<?php if (!empty($copy['summary'])) : ?><p><?php echo esc_html((string) $copy['summary']); ?></p><?php endif; ?>
<p class="spiralist-collaboration-card__small">
<?php if (!empty($record['approved_at'])) : ?>Approved <?php echo esc_html($format_date((string) $record['approved_at'])); ?><?php endif; ?>
<?php if (!empty($record['submitted_at']) && empty($record['approved_at'])) : ?>Submitted <?php echo esc_html($format_date((string) $record['submitted_at'])); ?><?php endif; ?>
</p>
<div class="spiralist-collaboration-card__actions">
<?php if (!empty($record['public_url'])) : ?><a class="spiralist-button spiralist-button--primary" href="<?php echo esc_url((string) $record['public_url']); ?>">Open Public Page</a><?php endif; ?>
<?php if ($show_private_links && !empty($record['studio_url'])) : ?><a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url((string) $record['studio_url']); ?>">Edit In Studio</a><?php endif; ?>
<?php if ($show_private_links && !empty($record['profile_share_url'])) : ?><a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url((string) $record['profile_share_url']); ?>">Open Share Link</a><?php endif; ?>
</div>
</div>
</article>
<?php
};
?>
<main class="spiralist-page spiralist-page--manuscript">
<div class="spiralist-page--manuscript__stage">
<section class="spiralist-shell spiralist-shell--manuscript-stage">
<div class="spiralist-collaboration">
<?php $render_notice($notice); ?>
<?php if ($mode === 'community') : ?>
<?php
$record = $submission_slug !== ''
? spiralist_book_pages_get_collaboration_submission_by_slug($submission_slug)
: [];
$missing_public_record = $submission_slug !== '' && (empty($record) || empty($record['has_public_copy']));
if ($missing_public_record) {
$set_404();
}
?>
<?php if ($submission_slug !== '' && !empty($record['has_public_copy'])) : ?>
<?php $copy = (array) ($record['public_copy'] ?? []); ?>
<?php
$community_discussion_context = spiralist_book_pages_get_discussion_context_for_collaboration_record(
$record,
'public',
spiralist_book_pages_get_current_request_url()
);
?>
<div class="spiralist-collaboration-hero">
<div>
<p class="spiralist-collaboration-kicker">Public Manuscript Directory</p>
<h1><?php echo esc_html((string) ($copy['title'] ?? 'Community Manuscript Page')); ?></h1>
<p>This admin-approved manuscript page is now part of the public viewing layer. The public route always shows the latest approved version and credits the original contributor.</p>
<div class="spiralist-collaboration-meta-row">
<?php $render_badge('Published', 'good'); ?>
<span>Responsible contributor: <?php echo esc_html((string) ($record['author']['display_name'] ?? 'Contributor')); ?></span>
<?php if (!empty($record['approved_at'])) : ?><span>Approved <?php echo esc_html($format_date((string) $record['approved_at'])); ?></span><?php endif; ?>
</div>
</div>
<div class="spiralist-collaboration-hero__actions">
<a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url(spiralist_book_pages_get_manuscript_community_url()); ?>">Back To Directory</a>
<?php if (!empty($record['profile_url'])) : ?><a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url((string) $record['profile_url']); ?>">Contributor Profile</a><?php endif; ?>
</div>
</div>
<div class="spiralist-collaboration-single">
<?php $render_image($copy, (string) ($copy['title'] ?? 'Community Manuscript Page')); ?>
<article class="spiralist-collaboration-panel">
<h2>Page Summary</h2>
<p><?php echo esc_html((string) ($copy['summary'] ?? '')); ?></p>
<dl class="spiralist-collaboration-facts">