From 6b7e66ee1e1c525fa9d15c50dadedc0a9934b899 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 3 Jun 2026 05:19:44 +0000 Subject: [PATCH] Blocks: Include the offending block name in registration error notices. Three of the four `_doing_it_wrong()` calls in `WP_Block_Type_Registry::register()` emitted a generic message that did not identify which block name triggered it, making it hard to locate the offending registration. The notices for non-string names, uppercase characters, and a missing namespace prefix now include the received value (the type via `gettype()` for non-strings, and the escaped name otherwise), matching the existing "already registered" notice that did already report the name. Developed in https://github.com/WordPress/wordpress-develop/pull/11478. Follow-up to r44108. Props manishxdp, desrosj, benjgrolleau, westonruter. Fixes #65039. Built from https://develop.svn.wordpress.org/trunk@62452 git-svn-id: http://core.svn.wordpress.org/trunk@61733 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-block-type-registry.php | 9 ++++++--- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-includes/class-wp-block-type-registry.php b/wp-includes/class-wp-block-type-registry.php index 969f0f0f64..aa134cee16 100644 --- a/wp-includes/class-wp-block-type-registry.php +++ b/wp-includes/class-wp-block-type-registry.php @@ -55,7 +55,8 @@ final class WP_Block_Type_Registry { if ( ! is_string( $name ) ) { _doing_it_wrong( __METHOD__, - __( 'Block type names must be strings.' ), + /* translators: %s: The received block type name type. */ + sprintf( __( 'Block type names must be strings, received %s.' ), gettype( $name ) ), '5.0.0' ); return false; @@ -64,7 +65,8 @@ final class WP_Block_Type_Registry { if ( preg_match( '/[A-Z]+/', $name ) ) { _doing_it_wrong( __METHOD__, - __( 'Block type names must not contain uppercase characters.' ), + /* translators: %s: Block name. */ + sprintf( __( 'Block type names must not contain uppercase characters. "%s" was given.' ), esc_html( $name ) ), '5.0.0' ); return false; @@ -74,7 +76,8 @@ final class WP_Block_Type_Registry { if ( ! preg_match( $name_matcher, $name ) ) { _doing_it_wrong( __METHOD__, - __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type' ), + /* translators: %s: Block name. */ + sprintf( __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type. "%s" was given.' ), esc_html( $name ) ), '5.0.0' ); return false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 2772e7d9df..95b22d518a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '7.1-alpha-62451'; +$wp_version = '7.1-alpha-62452'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.