diff --git a/blocks/journal-link/block.json b/blocks/journal-link/block.json
new file mode 100644
index 0000000..9e80baf
--- /dev/null
+++ b/blocks/journal-link/block.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://schemas.wp.org/trunk/block.json",
+ "apiVersion": 3,
+ "name": "chrnx/journal-link",
+ "version": "0.1.0",
+ "title": "Journal Link",
+ "category": "theme",
+ "description": "Display a translated portable link to the full Journal.",
+ "textdomain": "chrnx",
+ "supports": { "html": false },
+ "render": "file:./render.php"
+}
diff --git a/blocks/journal-link/render.php b/blocks/journal-link/render.php
new file mode 100644
index 0000000..3cf1b64
--- /dev/null
+++ b/blocks/journal-link/render.php
@@ -0,0 +1,8 @@
+
+
'chrnx-journal-link' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
diff --git a/blocks/journal-stream/render.php b/blocks/journal-stream/render.php
index 0d7201e..a08e275 100644
--- a/blocks/journal-stream/render.php
+++ b/blocks/journal-stream/render.php
@@ -101,6 +101,9 @@ $chrnx_title_id = wp_unique_id( 'chrnx-journal-title-' );
-
-
 ); ?>)
+
diff --git a/blocks/topic-hero/style.css b/blocks/topic-hero/style.css
index 425464d..702ead0 100644
--- a/blocks/topic-hero/style.css
+++ b/blocks/topic-hero/style.css
@@ -2,6 +2,12 @@
min-width: min(100%, 16rem);
}
+.chrnx-topic-hero__art img {
+ display: block;
+ height: auto;
+ max-width: 100%;
+}
+
.chrnx-topic-hero__fallback {
aspect-ratio: 4 / 5;
background-color: var(--wp--preset--color--panel);
diff --git a/inc/blocks.php b/inc/blocks.php
index a23705a..29598bf 100644
--- a/inc/blocks.php
+++ b/inc/blocks.php
@@ -17,6 +17,34 @@ function chrnx_get_heading_level( $value, $fallback_level = 2 ) {
return in_array( $level, array( 2, 3, 4, 5, 6 ), true ) ? $level : $fallback_level;
}
+/**
+ * Estimate localized reading time from stored post content without rendering it.
+ *
+ * @param string $content Raw post content.
+ * @return int Estimated whole minutes, or zero for empty content.
+ */
+function chrnx_get_reading_time_minutes( $content ) {
+ if ( ! is_string( $content ) || '' === trim( $content ) ) {
+ return 0;
+ }
+
+ $text = preg_replace( '//', ' ', strip_shortcodes( $content ) );
+ $text = html_entity_decode( wp_strip_all_tags( (string) $text, true ), ENT_QUOTES | ENT_HTML5, 'UTF-8' );
+ $text = wp_check_invalid_utf8( $text );
+ if ( '' === trim( $text ) ) {
+ return 0;
+ }
+
+ if ( str_starts_with( wp_get_word_count_type(), 'characters' ) ) {
+ $characters = preg_replace( '/\s+/u', '', $text );
+ $count = mb_strlen( (string) $characters, 'UTF-8' );
+ return max( 1, (int) ceil( $count / 500 ) );
+ }
+
+ $count = preg_match_all( "/[\p{L}\p{N}]+(?:['’\x{2010}-\x{2015}-][\p{L}\p{N}]+)*/u", $text );
+ return false === $count || 0 === $count ? 0 : max( 1, (int) ceil( $count / 200 ) );
+}
+
/**
* Render a post's meaningful featured image or decorative topic fallback.
*
@@ -74,7 +102,7 @@ function chrnx_get_editorial_card_markup( $post_id, $heading_level = 3, $class_n
/** Register all block metadata directories that exist. */
function chrnx_register_editorial_blocks() {
- $blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools' );
+ $blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools', 'reading-time', 'journal-link' );
foreach ( $blocks as $block ) {
$name = 'chrnx/' . $block;
if ( WP_Block_Type_Registry::get_instance()->is_registered( $name ) ) {
diff --git a/inc/queries.php b/inc/queries.php
index d35e524..0dd127c 100644
--- a/inc/queries.php
+++ b/inc/queries.php
@@ -332,6 +332,23 @@ function chrnx_get_journal_base_url() {
return add_query_arg( $routing_values, $base_url );
}
+/**
+ * Return the canonical full Journal destination independent of current filters.
+ *
+ * @return string Portable Journal URL.
+ */
+function chrnx_get_full_journal_url() {
+ $page = get_page_by_path( 'journal', OBJECT, 'page' );
+ if ( $page instanceof WP_Post && 'publish' === $page->post_status ) {
+ $url = get_permalink( $page );
+ if ( is_string( $url ) && '' !== $url ) {
+ return $url;
+ }
+ }
+
+ return home_url( '/journal/' );
+}
+
/**
* Build a Journal page URL from only validated public filters.
*
@@ -543,3 +560,17 @@ function chrnx_get_topic_art_asset( string $topic_slug ): string {
);
return isset( $mapping[ $topic_slug ] ) ? 'assets/images/' . $mapping[ $topic_slug ] : '';
}
+
+/**
+ * Return exact intrinsic dimensions for allowlisted topic art.
+ *
+ * @param string $topic_slug Supported topic slug.
+ * @return int[] Width and height, or an empty array.
+ */
+function chrnx_get_topic_art_dimensions( string $topic_slug ): array {
+ if ( '' === chrnx_get_topic_art_asset( $topic_slug ) ) {
+ return array();
+ }
+
+ return 'gaming' === $topic_slug ? array( 1024, 1536 ) : array( 1122, 1402 );
+}
diff --git a/patterns/about.php b/patterns/about.php
index 45b6623..c6ac744 100644
--- a/patterns/about.php
+++ b/patterns/about.php
@@ -13,9 +13,9 @@ $chrnx_research_url = esc_url( 'https://arxiv.org/abs/2603.05352' );
diff --git a/patterns/music-landing.php b/patterns/music-landing.php
index ad22d1e..0735c35 100644
--- a/patterns/music-landing.php
+++ b/patterns/music-landing.php
@@ -9,6 +9,7 @@
* @package CHRNX
*/
$chrnx_music_collage = get_theme_file_uri( 'assets/images/the-no-names-collage.jpeg' );
+$chrnx_music_cutout = get_theme_file_uri( 'assets/images/the-no-names-musician-cutout.png' );
?>
@@ -16,7 +17,12 @@ $chrnx_music_collage = get_theme_file_uri( 'assets/images/the-no-names-collage.j
-
+
+
+
; ?>)
+
; ?>)
+
+
diff --git a/patterns/podcast-show.php b/patterns/podcast-show.php
index f659f9a..d4a6595 100644
--- a/patterns/podcast-show.php
+++ b/patterns/podcast-show.php
@@ -8,10 +8,12 @@
*
* @package CHRNX
*/
+$chrnx_podcast_show_art = get_theme_file_uri( 'assets/images/alter-ego-podcasts.png' );
?>
+
diff --git a/templates/404.html b/templates/404.html
index a1f326e..b263bee 100644
--- a/templates/404.html
+++ b/templates/404.html
@@ -8,6 +8,7 @@
+
diff --git a/templates/single.html b/templates/single.html
index 04a06f9..6f9ce19 100644
--- a/templates/single.html
+++ b/templates/single.html
@@ -8,6 +8,7 @@
+
diff --git a/tests/php/BlockRenderingTest.php b/tests/php/BlockRenderingTest.php
index 5eb0f8b..4e09f4e 100644
--- a/tests/php/BlockRenderingTest.php
+++ b/tests/php/BlockRenderingTest.php
@@ -15,9 +15,9 @@ class BlockRenderingTest extends WP_UnitTestCase {
delete_option( 'chrnx_subscribe_page_id' );
}
- /** All twelve block types register from metadata. */
+ /** All fourteen block types register from metadata. */
public function test_all_editorial_blocks_are_registered() {
- $names = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools' );
+ $names = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand', 'mobile-menu-toggle', 'footer-content', 'header-tools', 'reading-time', 'journal-link' );
foreach ( $names as $name ) {
$type = WP_Block_Type_Registry::get_instance()->get_registered( 'chrnx/' . $name );
$this->assertInstanceOf( WP_Block_Type::class, $type, $name );
@@ -145,9 +145,73 @@ class BlockRenderingTest extends WP_UnitTestCase {
);
foreach ( $expected as $slug => $filename ) {
$this->assertSame( 'assets/images/' . $filename, chrnx_get_topic_art_asset( $slug ) );
+ $this->assertSame( 'gaming' === $slug ? array( 1024, 1536 ) : array( 1122, 1402 ), chrnx_get_topic_art_dimensions( $slug ) );
}
foreach ( array( '', 'unknown', '../secret.png', 'assets/images/anything.png' ) as $value ) {
$this->assertSame( '', chrnx_get_topic_art_asset( $value ) );
+ $this->assertSame( array(), chrnx_get_topic_art_dimensions( $value ) );
+ }
+ }
+
+ /** Reading time counts real Unicode words, ignores markup, and localizes singular/plural labels. */
+ public function test_reading_time_is_robust_and_localized() {
+ $this->assertSame( 0, chrnx_get_reading_time_minutes( '' ) );
+ $this->assertSame( 1, chrnx_get_reading_time_minutes( 'Árbol, café & código.
' ) );
+ $this->assertSame( 2, chrnx_get_reading_time_minutes( implode( ' ', array_fill( 0, 201, 'palabra' ) ) ) );
+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => implode( ' ', array_fill( 0, 201, 'palabra' ) ),
+ )
+ );
+ $translate = static function ( $translation, $single, $plural, $number, $domain ) {
+ if ( 'chrnx' === $domain && '%s minute read' === $single ) {
+ return 1 === $number ? '%s minuto de lectura' : '%s minutos de lectura';
+ }
+ return $translation;
+ };
+ add_filter( 'ngettext', $translate, 10, 5 );
+ try {
+ $output = $this->render_for_post( 'chrnx/reading-time', $post_id );
+ } finally {
+ remove_filter( 'ngettext', $translate, 10 );
+ }
+ $this->assertStringContainsString( '2 minutos de lectura', $output );
+ $this->assertStringNotContainsString( 'palabra', $output );
+ }
+
+ /** Empty/recovery links always point directly to a portable full Journal URL. */
+ public function test_journal_recovery_links_are_localized_and_portable() {
+ $portable_home = static function ( $url, $path ) {
+ return 'https://example.test/subdirectory/' . ltrim( (string) $path, '/' );
+ };
+ add_filter( 'home_url', $portable_home, 10, 2 );
+ try {
+ $link = render_block(
+ array(
+ 'blockName' => 'chrnx/journal-link',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ )
+ );
+ $this->assertStringContainsString( 'href="https://example.test/subdirectory/journal/"', $link );
+ $this->assertStringContainsString( 'Browse the full Journal', $link );
+
+ $stream = render_block(
+ array(
+ 'blockName' => 'chrnx/journal-stream',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ )
+ );
+ $this->assertStringContainsString( 'href="https://example.test/subdirectory/journal/"', $stream );
+ $this->assertStringContainsString( 'Browse the full Journal', $stream );
+ } finally {
+ remove_filter( 'home_url', $portable_home, 10 );
}
}
@@ -235,6 +299,18 @@ class BlockRenderingTest extends WP_UnitTestCase {
)
);
$this->assertSame( '', $unsafe );
+
+ $gaming = render_block(
+ array(
+ 'blockName' => 'chrnx/topic-hero',
+ 'attrs' => array( 'topic' => 'gaming' ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ )
+ );
+ $this->assertStringContainsString( 'width="1024"', $gaming );
+ $this->assertStringContainsString( 'height="1536"', $gaming );
}
/** Subscribe CTA is exactly empty until a published Page is configured. */
diff --git a/tests/php/PatternsTest.php b/tests/php/PatternsTest.php
index 008cf39..ec36cff 100644
--- a/tests/php/PatternsTest.php
+++ b/tests/php/PatternsTest.php
@@ -58,7 +58,7 @@ class PatternsTest extends WP_UnitTestCase {
/** Local art is generated through escaped theme URIs with intrinsic dimensions. */
public function test_art_patterns_use_only_escaped_local_theme_images() {
- foreach ( array( 'home-music', 'music-landing', 'podcast-landing' ) as $name ) {
+ foreach ( array( 'home-music', 'music-landing', 'podcast-landing', 'podcast-show' ) as $name ) {
$source = file_get_contents( get_theme_file_path( 'patterns/' . $name . '.php' ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture.
$content = $this->render_pattern( get_theme_file_path( 'patterns/' . $name . '.php' ) );
$this->assertStringContainsString( 'get_theme_file_uri(', $source, $name );
@@ -66,6 +66,15 @@ class PatternsTest extends WP_UnitTestCase {
$this->assertMatchesRegularExpression( '/
]*\bwidth="1122"[^>]*\bheight="1402"/i', $content, $name );
$this->assertMatchesRegularExpression( '/
]*\bloading="lazy"[^>]*\bdecoding="async"/i', $content, $name );
}
+ $music = $this->render_pattern( get_theme_file_path( 'patterns/music-landing.php' ) );
+ $this->assertStringContainsString( 'the-no-names-collage.jpeg', $music );
+ $this->assertStringContainsString( 'the-no-names-musician-cutout.png', $music );
+ $this->assertSame( 2, substr_count( $music, '
render_pattern( get_theme_file_path( 'patterns/podcast-show.php' ) );
+ $this->assertStringContainsString( 'alter-ego-podcasts.png', $show );
+ $this->assertStringContainsString( 'alt=""', $show );
+ $this->assertStringContainsString( 'aria-hidden="true"', $show );
}
/** Music copy contains only the exact approved public facts and release statuses. */
@@ -102,6 +111,10 @@ class PatternsTest extends WP_UnitTestCase {
$this->assertStringContainsString( 'target="_blank"', $content );
$this->assertStringContainsString( 'rel="noopener noreferrer external"', $content );
$this->assertDoesNotMatchRegularExpression( '/diagnos|inspir|overcame|despite/i', $content );
+ $plain = wp_strip_all_tags( $content );
+ $this->assertLessThan( strpos( $plain, 'autistic Level 1' ), strpos( $plain, 'Lead Developer @Expressive Tea' ) );
+ $this->assertLessThan( strpos( $plain, 'autistic Level 1' ), strpos( $plain, 'emotion modeling and game AI' ) );
+ $this->assertLessThan( strpos( $plain, 'father of three wonderful children' ), strpos( $plain, 'autistic Level 1' ) );
}
/** Reusable project/release/show/episode structures do not invent visible starter data. */
diff --git a/tests/smoke/templates.test.mjs b/tests/smoke/templates.test.mjs
index 6c3aa91..f22053e 100644
--- a/tests/smoke/templates.test.mjs
+++ b/tests/smoke/templates.test.mjs
@@ -63,6 +63,7 @@ test('single provides readable content, neutral metadata, and post-only componen
assert.match(markup, /wp:post-terms \{"term":"chrnx_topic"/);
assert.match(markup, /wp:post-terms \{"term":"chrnx_language"/);
assert.match(markup, /wp:post-date/);
+ assert.match(markup, /wp:chrnx\/reading-time/);
assert.match(markup, /wp:post-featured-image/);
assert.match(markup, /wp:post-content/);
assert.match(markup, /wp:chrnx\/podcast-meta/);
@@ -100,5 +101,6 @@ test('404 offers concise recovery with search, Journal, and home links', async (
assert.match(markup, /Page not found/);
assert.match(markup, /wp:search/);
assert.match(markup, /wp:home-link/);
+ assert.match(markup, /wp:chrnx\/journal-link/);
assert.doesNotMatch(markup, /"url":"\//);
});