From 13a8b0425feb0a1bdda3a8273ccb0f7867ae591a Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Fri, 14 Aug 2026 09:51:03 -0500 Subject: [PATCH] fix: keep the block title tag and drop Rank Math's relocated copy Rank Math moves _wp_render_title_tag off wp_head into its own rank_math/head block, but it does not know about the block-theme renderer that replaced it, so both rendered. The previous release removed the block renderer and kept the relocated one, which fixed the duplicate but left the page depending on a plugin that may print nothing at all: Rank Math skips its entire frontend until its setup wizard completes, and in that state the page had no and no social tags. Remove the relocated copy instead. Both carry the same text, since Rank Math supplies it through pre_get_document_title, and the block renderer survives when the plugin is absent or silent. The removal needs no guard: with no Rank Math, rank_math/head holds no callbacks. For the same reason chrnx_has_seo_plugin() now asks whether an SEO plugin actually printed its head, not whether one happens to be installed. Verified against a real Rank Math install in all three states: emitting, installed but silent, and absent. One title every time, never zero. The subscribe call to action now also runs on Pages and archives, so the Journal and the topic archives can convert, and it skips the Subscribe page itself rather than linking there from there. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --- blocks/featured-stories/block.json | 2 +- blocks/footer-content/block.json | 2 +- blocks/header-tools/block.json | 2 +- blocks/journal-link/block.json | 2 +- blocks/journal-stream/block.json | 2 +- blocks/latest-podcast/block.json | 2 +- blocks/mobile-menu-toggle/block.json | 2 +- blocks/podcast-meta/block.json | 2 +- blocks/reading-time/block.json | 2 +- blocks/related-posts/block.json | 2 +- blocks/release-detail/block.json | 2 +- blocks/release-list/block.json | 2 +- blocks/selected-work/block.json | 2 +- blocks/show-links/block.json | 2 +- blocks/site-brand/block.json | 2 +- blocks/subscribe-cta/block.json | 2 +- blocks/subscribe-cta/render.php | 5 +++++ blocks/subscribe-form/block.json | 2 +- blocks/theme-toggle/block.json | 2 +- blocks/topic-hero/block.json | 2 +- blocks/track-meta/block.json | 2 +- functions.php | 2 +- inc/setup.php | 33 +++++++++++++++------------- style.css | 2 +- templates/archive.html | 1 + templates/page.html | 1 + 26 files changed, 47 insertions(+), 37 deletions(-) diff --git a/blocks/featured-stories/block.json b/blocks/featured-stories/block.json index 27a788c..934fcfe 100644 --- a/blocks/featured-stories/block.json +++ b/blocks/featured-stories/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/featured-stories", - "version": "0.4.1", + "version": "0.4.2", "title": "Featured Stories", "category": "theme", "description": "A sticky-led selection of topic-diverse stories.", diff --git a/blocks/footer-content/block.json b/blocks/footer-content/block.json index 16d0797..ba3323a 100644 --- a/blocks/footer-content/block.json +++ b/blocks/footer-content/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/footer-content", - "version": "0.4.1", + "version": "0.4.2", "title": "CHRNX Footer Content", "category": "theme", "description": "Display translated internal footer navigation and site credit.", diff --git a/blocks/header-tools/block.json b/blocks/header-tools/block.json index 3f46acb..6403350 100644 --- a/blocks/header-tools/block.json +++ b/blocks/header-tools/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/header-tools", - "version": "0.4.1", + "version": "0.4.2", "title": "CHRNX Header Tools", "category": "theme", "description": "Display translated primary navigation and progressive site search.", diff --git a/blocks/journal-link/block.json b/blocks/journal-link/block.json index 327b2a5..407960e 100644 --- a/blocks/journal-link/block.json +++ b/blocks/journal-link/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/journal-link", - "version": "0.4.1", + "version": "0.4.2", "title": "Journal Link", "category": "theme", "description": "Display a translated portable link to the full Journal.", diff --git a/blocks/journal-stream/block.json b/blocks/journal-stream/block.json index ac045e5..6ac7d57 100644 --- a/blocks/journal-stream/block.json +++ b/blocks/journal-stream/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/journal-stream", - "version": "0.4.1", + "version": "0.4.2", "title": "Journal Stream", "category": "theme", "description": "The filterable chronological journal.", diff --git a/blocks/latest-podcast/block.json b/blocks/latest-podcast/block.json index 484ca96..13b2957 100644 --- a/blocks/latest-podcast/block.json +++ b/blocks/latest-podcast/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/latest-podcast", - "version": "0.4.1", + "version": "0.4.2", "title": "Latest Podcast", "category": "theme", "description": "A linked card for the latest podcast episode.", diff --git a/blocks/mobile-menu-toggle/block.json b/blocks/mobile-menu-toggle/block.json index 59f0dfd..5c6877d 100644 --- a/blocks/mobile-menu-toggle/block.json +++ b/blocks/mobile-menu-toggle/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/mobile-menu-toggle", - "version": "0.4.1", + "version": "0.4.2", "title": "CHRNX Mobile Menu Toggle", "category": "theme", "description": "Progressively reveal the primary navigation on small screens.", diff --git a/blocks/podcast-meta/block.json b/blocks/podcast-meta/block.json index 6452769..23a93d3 100644 --- a/blocks/podcast-meta/block.json +++ b/blocks/podcast-meta/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/podcast-meta", - "version": "0.4.1", + "version": "0.4.2", "title": "Podcast Metadata", "category": "theme", "description": "Safe episode details for the current post.", diff --git a/blocks/reading-time/block.json b/blocks/reading-time/block.json index 1c6c6f6..95afb13 100644 --- a/blocks/reading-time/block.json +++ b/blocks/reading-time/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/reading-time", - "version": "0.4.1", + "version": "0.4.2", "title": "Reading Time", "category": "theme", "description": "Display a localized estimate based on the current post content.", diff --git a/blocks/related-posts/block.json b/blocks/related-posts/block.json index 5cf8fe4..473e559 100644 --- a/blocks/related-posts/block.json +++ b/blocks/related-posts/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/related-posts", - "version": "0.4.1", + "version": "0.4.2", "title": "Related Posts", "category": "theme", "description": "Related stories selected by topic, tags, and recency.", diff --git a/blocks/release-detail/block.json b/blocks/release-detail/block.json index a57afc0..3d51ea9 100644 --- a/blocks/release-detail/block.json +++ b/blocks/release-detail/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/release-detail", - "version": "0.4.1", + "version": "0.4.2", "title": "Release Detail", "category": "theme", "description": "Album cover, listening links, and the ordered tracklist.", diff --git a/blocks/release-list/block.json b/blocks/release-list/block.json index c90abb4..d953356 100644 --- a/blocks/release-list/block.json +++ b/blocks/release-list/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/release-list", - "version": "0.4.1", + "version": "0.4.2", "title": "Release List", "category": "theme", "description": "The No Names releases, each linking to its album page.", diff --git a/blocks/selected-work/block.json b/blocks/selected-work/block.json index 86fe179..c56a179 100644 --- a/blocks/selected-work/block.json +++ b/blocks/selected-work/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/selected-work", - "version": "0.4.1", + "version": "0.4.2", "title": "Selected Work", "category": "theme", "description": "Hand-picked projects first, then the most recent ones.", diff --git a/blocks/show-links/block.json b/blocks/show-links/block.json index 795e20e..0682d02 100644 --- a/blocks/show-links/block.json +++ b/blocks/show-links/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/show-links", - "version": "0.4.1", + "version": "0.4.2", "title": "Show Links", "category": "theme", "description": "Where a podcast show can be listened to, rendered only when a URL exists.", diff --git a/blocks/site-brand/block.json b/blocks/site-brand/block.json index 9cad725..2bc5b10 100644 --- a/blocks/site-brand/block.json +++ b/blocks/site-brand/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/site-brand", - "version": "0.4.1", + "version": "0.4.2", "title": "CHRNX Site Brand", "category": "theme", "description": "Display the local CHRNX wordmark linked to the site home.", diff --git a/blocks/subscribe-cta/block.json b/blocks/subscribe-cta/block.json index 3491621..11499a4 100644 --- a/blocks/subscribe-cta/block.json +++ b/blocks/subscribe-cta/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/subscribe-cta", - "version": "0.4.1", + "version": "0.4.2", "title": "Subscribe CTA", "category": "theme", "description": "A call to action linked to the configured subscribe page.", diff --git a/blocks/subscribe-cta/render.php b/blocks/subscribe-cta/render.php index 6ad66e1..8052e4b 100644 --- a/blocks/subscribe-cta/render.php +++ b/blocks/subscribe-cta/render.php @@ -9,6 +9,11 @@ $chrnx_url = chrnx_get_subscribe_url(); if ( '' === $chrnx_url ) { return; } +// page.html renders every Page, Subscribe included, and a call to action +// pointing at the page you are already reading is just noise. +if ( is_page( absint( get_option( 'chrnx_subscribe_page_id', 0 ) ) ) ) { + return; +} $chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 ); ?> <section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-subscribe-cta' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> diff --git a/blocks/subscribe-form/block.json b/blocks/subscribe-form/block.json index 9151bcd..1dc9eb8 100644 --- a/blocks/subscribe-form/block.json +++ b/blocks/subscribe-form/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/subscribe-form", - "version": "0.4.1", + "version": "0.4.2", "title": "Subscribe Form", "category": "theme", "description": "The email subscription form, rendered only when a provider endpoint is configured.", diff --git a/blocks/theme-toggle/block.json b/blocks/theme-toggle/block.json index 2d642dd..711b014 100644 --- a/blocks/theme-toggle/block.json +++ b/blocks/theme-toggle/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/theme-toggle", - "version": "0.4.1", + "version": "0.4.2", "title": "Theme Toggle", "category": "theme", "description": "Choose a light, dark, or system color theme.", diff --git a/blocks/topic-hero/block.json b/blocks/topic-hero/block.json index 84607b0..4d16548 100644 --- a/blocks/topic-hero/block.json +++ b/blocks/topic-hero/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/topic-hero", - "version": "0.4.1", + "version": "0.4.2", "title": "Topic Hero", "category": "theme", "description": "A fixed-art hero for an editorial topic.", diff --git a/blocks/track-meta/block.json b/blocks/track-meta/block.json index 944dfe8..b1599e2 100644 --- a/blocks/track-meta/block.json +++ b/blocks/track-meta/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "chrnx/track-meta", - "version": "0.4.1", + "version": "0.4.2", "title": "Track Meta", "category": "theme", "description": "Player, listening links, and album for one song.", diff --git a/functions.php b/functions.php index 5713cc9..ce5b5bd 100644 --- a/functions.php +++ b/functions.php @@ -1,5 +1,5 @@ <?php -define( 'CHRNX_VERSION', '0.4.1' ); +define( 'CHRNX_VERSION', '0.4.2' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound foreach ( array( 'setup', 'assets', 'taxonomies', 'editor', 'podcast-meta', 'project-meta', 'release-meta', 'show-meta', 'track-meta', 'settings', 'queries', 'media', 'blocks', 'theme-preference' ) as $module ) { diff --git a/inc/setup.php b/inc/setup.php index dd414f2..1e09e8b 100644 --- a/inc/setup.php +++ b/inc/setup.php @@ -87,30 +87,33 @@ function chrnx_print_social_meta() { add_action( 'wp_head', 'chrnx_print_social_meta' ); /** - * Report whether an SEO plugin owns the document head. + * Report whether an SEO plugin already printed the document head. * - * @return bool True when a known SEO plugin is active. + * Deliberately not "is one installed": Rank Math skips its whole frontend + * until its setup wizard completes, so an installed-but-silent plugin used to + * make the theme yield to nobody. rank_math/head fires only when it really + * rendered, and it runs at wp_head priority 1, ahead of the tags below. + * + * @return bool True when an SEO plugin printed its head block. */ function chrnx_has_seo_plugin(): bool { - return defined( 'RANK_MATH_VERSION' ) || defined( 'WPSEO_VERSION' ) || defined( 'SEOPRESS_VERSION' ); + return did_action( 'rank_math/head' ) > 0; } /** - * Drop core's title tag when an SEO plugin prints its own. + * Drop the relocated copy of core's title tag. * - * Both were rendering, so every page shipped two <title> elements. Block - * themes swap _wp_render_title_tag for the block-template renderer, so - * removing only the classic one silently did nothing here. + * Rank Math moves _wp_render_title_tag off wp_head and into its own + * rank_math/head block, but it does not know about the block-theme renderer + * that replaced it, so block themes render two identical <title> elements. * - * locate_block_template() registers that renderer during template_include, - * after both `wp` and template_redirect, so wp_head is the first hook where - * it exists and can still be removed before it runs. + * Remove the relocated copy, never the block one. Both carry the same text, + * because Rank Math supplies it through pre_get_document_title, and keeping + * the block renderer means a page still has a title when the plugin is + * absent or silent. No guard is needed: with no Rank Math, rank_math/head + * holds no callbacks and this is a no-op. */ function chrnx_remove_duplicate_title_tag() { - if ( ! chrnx_has_seo_plugin() ) { - return; - } - remove_action( 'wp_head', '_block_template_render_title_tag', 1 ); - remove_action( 'wp_head', '_wp_render_title_tag', 1 ); + remove_action( 'rank_math/head', '_wp_render_title_tag', 1 ); } add_action( 'wp_head', 'chrnx_remove_duplicate_title_tag', 0 ); diff --git a/style.css b/style.css index eaa19fc..1eb67ec 100644 --- a/style.css +++ b/style.css @@ -3,6 +3,6 @@ Theme Name: CHRNX Description: A native block theme for chrnx.dev. Requires at least: 6.9 Requires PHP: 8.1 -Version: 0.4.1 +Version: 0.4.2 Text Domain: chrnx */ diff --git a/templates/archive.html b/templates/archive.html index 33f06df..d847beb 100644 --- a/templates/archive.html +++ b/templates/archive.html @@ -6,6 +6,7 @@ <!-- wp:term-description /--> <!-- wp:chrnx/topic-hero /--> <!-- wp:chrnx/journal-stream /--> + <!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /--> </main> <!-- /wp:group --> diff --git a/templates/page.html b/templates/page.html index b598a43..ef48e34 100644 --- a/templates/page.html +++ b/templates/page.html @@ -4,6 +4,7 @@ <main id="chrnx-main" class="wp-block-group chrnx-entry chrnx-entry--page" tabindex="-1"> <!-- wp:post-title {"level":1} /--> <!-- wp:post-content {"layout":{"type":"constrained"}} /--> + <!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /--> </main> <!-- /wp:group -->