feat: model projects as posts with a picked Selected work

Projects were hardcoded h3 elements in a pattern: no URL, no feed, no
search, uneditable without touching PHP. They follow the podcast model
now, a chrnx_topic term plus posts.

Adds a chrnx_project_featured flag with an editor toggle so the stage
lists chosen projects first and fills with the most recent. Sticky was
already spoken for by the home featured stories, so the choice needed
its own signal. journal-stream gains a pinned topic attribute, reusing
the archive filter, pagination and empty state it already had.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-13 19:41:24 -05:00
1 parent a3ba692669
commit f55d9d9b45
14 files changed
+539 -31

No files matched your search

+3 -2
View File
@@ -2,13 +2,14 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "chrnx/journal-stream",
"version": "0.1.0",
"version": "0.2.0",
"title": "Journal Stream",
"category": "theme",
"description": "The filterable chronological journal.",
"textdomain": "chrnx",
"attributes": {
"headingLevel": { "type": "integer", "default": 2, "enum": [2, 3, 4, 5, 6] }
"headingLevel": { "type": "integer", "default": 2, "enum": [2, 3, 4, 5, 6] },
"topic": { "type": "string", "default": "" }
},
"supports": { "html": false, "align": ["wide", "full"] },
"style": "file:./style.css",
+11 -3
View File
@@ -5,9 +5,15 @@
* @package CHRNX
*/
// A pinned topic reuses the taxonomy-archive path: same fixed-filter UI, same
// hidden input, same clear link, without needing an archive route.
$chrnx_pinned_slug = chrnx_validate_editorial_term_slug( $attributes['topic'] ?? '', 'chrnx_topic' );
$chrnx_pinned_term = '' !== $chrnx_pinned_slug ? get_term_by( 'slug', $chrnx_pinned_slug, 'chrnx_topic' ) : null;
$chrnx_pinned_term = $chrnx_pinned_term instanceof WP_Term ? $chrnx_pinned_term : null;
// Read-only filters do not change server state; every value is validated by the query service.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$chrnx_request = chrnx_get_journal_request_context( is_array( $_GET ) ? $_GET : array() );
$chrnx_request = chrnx_get_journal_request_context( is_array( $_GET ) ? $_GET : array(), $chrnx_pinned_term );
$chrnx_args = chrnx_get_journal_query_args( $chrnx_request );
$chrnx_query = chrnx_run_eligible_query( $chrnx_args );
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 );
@@ -17,10 +23,12 @@ $chrnx_show = chrnx_validate_editorial_term_slug( $chrnx_request['chrnx_show
$chrnx_search = $chrnx_args['s'] ?? '';
$chrnx_form_url = chrnx_get_journal_base_url();
$chrnx_title_id = wp_unique_id( 'chrnx-journal-title-' );
$chrnx_fixed = chrnx_get_journal_archive_filter();
$chrnx_fixed = chrnx_get_journal_archive_filter( $chrnx_pinned_term );
// A pinned stream is not the Journal; it is that topic's list, so it says so.
$chrnx_title = null !== $chrnx_pinned_term ? $chrnx_pinned_term->name : __( 'Journal', 'chrnx' );
?>
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-journal-stream' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-labelledby="<?php echo esc_attr( $chrnx_title_id ); ?>">
<h<?php echo esc_attr( $chrnx_heading ); ?> id="<?php echo esc_attr( $chrnx_title_id ); ?>"><?php echo esc_html__( 'Journal', 'chrnx' ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
<h<?php echo esc_attr( $chrnx_heading ); ?> id="<?php echo esc_attr( $chrnx_title_id ); ?>"><?php echo esc_html( $chrnx_title ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
<form class="chrnx-journal-stream__filters" method="get" action="<?php echo esc_url( $chrnx_form_url ); ?>">
<?php if ( isset( $chrnx_fixed['taxonomy'] ) && 'chrnx_topic' === $chrnx_fixed['taxonomy'] ) : ?>
<p class="chrnx-journal-stream__fixed-filter"><span><?php echo esc_html__( 'Topic', 'chrnx' ); ?></span> <strong><?php echo esc_html( $chrnx_fixed['label'] ); ?></strong></p>
+16
View File
@@ -0,0 +1,16 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "chrnx/selected-work",
"version": "0.2.0",
"title": "Selected Work",
"category": "theme",
"description": "Hand-picked projects first, then the most recent ones.",
"textdomain": "chrnx",
"attributes": {
"limit": { "type": "integer", "default": 3, "minimum": 1, "maximum": 12 },
"headingLevel": { "type": "integer", "default": 3, "enum": [2, 3, 4, 5, 6] }
},
"supports": { "html": false },
"render": "file:./render.php"
}
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* Selected Work block render.
*
* @package CHRNX
*/
$chrnx_limit = isset( $attributes['limit'] ) ? min( 12, max( 1, absint( $attributes['limit'] ) ) ) : 3;
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 3, 3 );
$chrnx_ids = chrnx_get_selected_project_ids( $chrnx_limit );
?>
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-selected-work' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<?php if ( empty( $chrnx_ids ) ) : ?>
<p class="chrnx-selected-work__empty"><?php echo esc_html__( 'No projects published yet.', 'chrnx' ); ?></p>
<?php else : ?>
<ul class="chrnx-selected-work__list">
<?php foreach ( $chrnx_ids as $chrnx_project_id ) : ?>
<li class="chrnx-selected-work__item">
<h<?php echo esc_attr( $chrnx_heading ); ?> class="chrnx-selected-work__title">
<a href="<?php echo esc_url( get_permalink( $chrnx_project_id ) ); ?>"><?php echo esc_html( get_the_title( $chrnx_project_id ) ); ?></a>
</h<?php echo esc_attr( $chrnx_heading ); ?>>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>