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",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/featured-stories",
|
"name": "chrnx/featured-stories",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Featured Stories",
|
"title": "Featured Stories",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "A sticky-led selection of topic-diverse stories.",
|
"description": "A sticky-led selection of topic-diverse stories.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/footer-content",
|
"name": "chrnx/footer-content",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "CHRNX Footer Content",
|
"title": "CHRNX Footer Content",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Display translated internal footer navigation and site credit.",
|
"description": "Display translated internal footer navigation and site credit.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/header-tools",
|
"name": "chrnx/header-tools",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "CHRNX Header Tools",
|
"title": "CHRNX Header Tools",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Display translated primary navigation and progressive site search.",
|
"description": "Display translated primary navigation and progressive site search.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/journal-link",
|
"name": "chrnx/journal-link",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Journal Link",
|
"title": "Journal Link",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Display a translated portable link to the full Journal.",
|
"description": "Display a translated portable link to the full Journal.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/journal-stream",
|
"name": "chrnx/journal-stream",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Journal Stream",
|
"title": "Journal Stream",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "The filterable chronological journal.",
|
"description": "The filterable chronological journal.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/latest-podcast",
|
"name": "chrnx/latest-podcast",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Latest Podcast",
|
"title": "Latest Podcast",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "A linked card for the latest podcast episode.",
|
"description": "A linked card for the latest podcast episode.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/mobile-menu-toggle",
|
"name": "chrnx/mobile-menu-toggle",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "CHRNX Mobile Menu Toggle",
|
"title": "CHRNX Mobile Menu Toggle",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Progressively reveal the primary navigation on small screens.",
|
"description": "Progressively reveal the primary navigation on small screens.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/podcast-meta",
|
"name": "chrnx/podcast-meta",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Podcast Metadata",
|
"title": "Podcast Metadata",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Safe episode details for the current post.",
|
"description": "Safe episode details for the current post.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/reading-time",
|
"name": "chrnx/reading-time",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Reading Time",
|
"title": "Reading Time",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Display a localized estimate based on the current post content.",
|
"description": "Display a localized estimate based on the current post content.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/related-posts",
|
"name": "chrnx/related-posts",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Related Posts",
|
"title": "Related Posts",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Related stories selected by topic, tags, and recency.",
|
"description": "Related stories selected by topic, tags, and recency.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/release-detail",
|
"name": "chrnx/release-detail",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Release Detail",
|
"title": "Release Detail",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Album cover, listening links, and the ordered tracklist.",
|
"description": "Album cover, listening links, and the ordered tracklist.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/release-list",
|
"name": "chrnx/release-list",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Release List",
|
"title": "Release List",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "The No Names releases, each linking to its album page.",
|
"description": "The No Names releases, each linking to its album page.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/selected-work",
|
"name": "chrnx/selected-work",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Selected Work",
|
"title": "Selected Work",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Hand-picked projects first, then the most recent ones.",
|
"description": "Hand-picked projects first, then the most recent ones.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/show-links",
|
"name": "chrnx/show-links",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Show Links",
|
"title": "Show Links",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Where a podcast show can be listened to, rendered only when a URL exists.",
|
"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",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/site-brand",
|
"name": "chrnx/site-brand",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "CHRNX Site Brand",
|
"title": "CHRNX Site Brand",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Display the local CHRNX wordmark linked to the site home.",
|
"description": "Display the local CHRNX wordmark linked to the site home.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/subscribe-cta",
|
"name": "chrnx/subscribe-cta",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Subscribe CTA",
|
"title": "Subscribe CTA",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "A call to action linked to the configured subscribe page.",
|
"description": "A call to action linked to the configured subscribe page.",
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ $chrnx_url = chrnx_get_subscribe_url();
|
|||||||
if ( '' === $chrnx_url ) {
|
if ( '' === $chrnx_url ) {
|
||||||
return;
|
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 );
|
$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 ?>>
|
<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",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/subscribe-form",
|
"name": "chrnx/subscribe-form",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Subscribe Form",
|
"title": "Subscribe Form",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "The email subscription form, rendered only when a provider endpoint is configured.",
|
"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",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/theme-toggle",
|
"name": "chrnx/theme-toggle",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Theme Toggle",
|
"title": "Theme Toggle",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Choose a light, dark, or system color theme.",
|
"description": "Choose a light, dark, or system color theme.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/topic-hero",
|
"name": "chrnx/topic-hero",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Topic Hero",
|
"title": "Topic Hero",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "A fixed-art hero for an editorial topic.",
|
"description": "A fixed-art hero for an editorial topic.",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
"apiVersion": 3,
|
"apiVersion": 3,
|
||||||
"name": "chrnx/track-meta",
|
"name": "chrnx/track-meta",
|
||||||
"version": "0.4.1",
|
"version": "0.4.2",
|
||||||
"title": "Track Meta",
|
"title": "Track Meta",
|
||||||
"category": "theme",
|
"category": "theme",
|
||||||
"description": "Player, listening links, and album for one song.",
|
"description": "Player, listening links, and album for one song.",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
define( 'CHRNX_VERSION', '0.4.1' );
|
define( 'CHRNX_VERSION', '0.4.2' );
|
||||||
|
|
||||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
|
// 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 ) {
|
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' );
|
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 {
|
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
|
* Rank Math moves _wp_render_title_tag off wp_head and into its own
|
||||||
* themes swap _wp_render_title_tag for the block-template renderer, so
|
* rank_math/head block, but it does not know about the block-theme renderer
|
||||||
* removing only the classic one silently did nothing here.
|
* that replaced it, so block themes render two identical <title> elements.
|
||||||
*
|
*
|
||||||
* locate_block_template() registers that renderer during template_include,
|
* Remove the relocated copy, never the block one. Both carry the same text,
|
||||||
* after both `wp` and template_redirect, so wp_head is the first hook where
|
* because Rank Math supplies it through pre_get_document_title, and keeping
|
||||||
* it exists and can still be removed before it runs.
|
* 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() {
|
function chrnx_remove_duplicate_title_tag() {
|
||||||
if ( ! chrnx_has_seo_plugin() ) {
|
remove_action( 'rank_math/head', '_wp_render_title_tag', 1 );
|
||||||
return;
|
|
||||||
}
|
|
||||||
remove_action( 'wp_head', '_block_template_render_title_tag', 1 );
|
|
||||||
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
|
|
||||||
}
|
}
|
||||||
add_action( 'wp_head', 'chrnx_remove_duplicate_title_tag', 0 );
|
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.
|
Description: A native block theme for chrnx.dev.
|
||||||
Requires at least: 6.9
|
Requires at least: 6.9
|
||||||
Requires PHP: 8.1
|
Requires PHP: 8.1
|
||||||
Version: 0.4.1
|
Version: 0.4.2
|
||||||
Text Domain: chrnx
|
Text Domain: chrnx
|
||||||
*/
|
*/
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<!-- wp:term-description /-->
|
<!-- wp:term-description /-->
|
||||||
<!-- wp:chrnx/topic-hero /-->
|
<!-- wp:chrnx/topic-hero /-->
|
||||||
<!-- wp:chrnx/journal-stream /-->
|
<!-- wp:chrnx/journal-stream /-->
|
||||||
|
<!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /-->
|
||||||
</main>
|
</main>
|
||||||
<!-- /wp:group -->
|
<!-- /wp:group -->
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<main id="chrnx-main" class="wp-block-group chrnx-entry chrnx-entry--page" tabindex="-1">
|
<main id="chrnx-main" class="wp-block-group chrnx-entry chrnx-entry--page" tabindex="-1">
|
||||||
<!-- wp:post-title {"level":1} /-->
|
<!-- wp:post-title {"level":1} /-->
|
||||||
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
|
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
|
||||||
|
<!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /-->
|
||||||
</main>
|
</main>
|
||||||
<!-- /wp:group -->
|
<!-- /wp:group -->
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user