[wp-trac] [WordPress Trac] #64639: Allow PHP-Only Block Registration

WordPress Trac noreply at wordpress.org
Tue Feb 17 13:20:54 UTC 2026


#64639: Allow PHP-Only Block Registration
-------------------------------------------------+-------------------------
 Reporter:  wildworks                            |       Owner:  wildworks
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  7.0
Component:  Editor                               |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests gutenberg-  |     Focuses:
  merge                                          |
-------------------------------------------------+-------------------------
Changes (by wildworks):

 * owner:  (none) => wildworks
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"61661" 61661]:
 {{{
 #!CommitTicketReference repository="" revision="61661"
 Block Supports: Add autoRegister support for PHP-only block registration.

 Introduces block support for PHP-only block registration, enabling
 developers to register blocks in PHP without requiring JavaScript
 registration code.

 When a block declares `'supports' => array( 'autoRegister' => true )`
 along with a render callback, it is exposed to the client-side via a
 JavaScript global variable and registered automatically.

 Example usage:

 {{{
 register_block_type(
         'my-plugin/example',
         array(
                 'title'           => 'My Example Block',
                 'attributes'      => array(
                         'title' => array(
                                 'type'    => 'string',
                                 'default' => 'Hello World',
                         ),
                         'count' => array(
                                 'type'    => 'integer',
                                 'default' => 5,
                         ),
                 ),
                 'render_callback' => function ( $attributes ) {
                         return sprintf(
                                 '<div %1$s>%2$s: %3$d items</div>',
                                 get_block_wrapper_attributes(),
                                 esc_html( $attributes['title'] ),
                                 $attributes['count']
                         );
                 },
                 'supports'        => array(
                         'autoRegister' => true,
                 ),
         )
 );
 }}}

 Props mcsf, oandregal, ramonopoly, westonruter, wildworks.
 Fixes #64639.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64639#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list