Make WordPress Core

Changeset 62452


Ignore:
Timestamp:
06/03/2026 05:18:21 AM (2 months ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-type-registry.php

    r60809 r62452  
    5656                        _doing_it_wrong(
    5757                                __METHOD__,
    58                                 __( 'Block type names must be strings.' ),
     58                                /* translators: %s: The received block type name type. */
     59                                sprintf( __( 'Block type names must be strings, received %s.' ), gettype( $name ) ),
    5960                                '5.0.0'
    6061                        );
     
    6566                        _doing_it_wrong(
    6667                                __METHOD__,
    67                                 __( 'Block type names must not contain uppercase characters.' ),
     68                                /* translators: %s: Block name. */
     69                                sprintf( __( 'Block type names must not contain uppercase characters. "%s" was given.' ), esc_html( $name ) ),
    6870                                '5.0.0'
    6971                        );
     
    7577                        _doing_it_wrong(
    7678                                __METHOD__,
    77                                 __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type' ),
     79                                /* translators: %s: Block name. */
     80                                sprintf( __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type. "%s" was given.' ), esc_html( $name ) ),
    7881                                '5.0.0'
    7982                        );
Note: See TracChangeset for help on using the changeset viewer.