mirror of
https://github.com/WordPress/WordPress.git
synced 2026-06-19 07:37:07 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user