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 <title> 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>
This commit is contained in:
26 files changed
+47
-37
No files matched your search
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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 ?>>
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
+1
-1
@@ -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 ) {
|
||||
|
||||
+18
-15
@@ -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 );
|
||||
@@ -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
|
||||
*/
|
||||
@@ -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 -->
|
||||
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
|
||||
Reference in new issue
Block a user