[wp-trac] [WordPress Trac] #53006: Blocks: Add isDefault to server side block styles registry

WordPress Trac noreply at wordpress.org
Fri Apr 9 08:37:44 UTC 2021

#53006: Blocks: Add isDefault to server side block styles registry
 Reporter:  gziolo       |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  5.8
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
 Moved from GitHub (https://github.com/WordPress/gutenberg/issues/30356).

 ## What problem does this address?
 [As documented
 guides/filters/block-filters.md#block-style-variations), block styles can
 be registered both server side (using PHP method `register_block_style`)
 and client side (using `wp.blocks.registerBlockStyle`).

 While server-side registration is a convenient method to easily register
 new block styles, it lacks the ability to register a style as the default

 As an example, something that could easily be achieved like this in JS, is
 not doable in PHP

 wp.blocks.registerBlockStyle( 'core/heading', [
                 name: 'default',
                 label: 'Default',
                 isDefault: true,
                 name: 'alt',
                 label: 'Alternate',

 ## What is your proposed solution?

 Extend `register_block_style` to also accept `isDefault`.
 (it would probably require to change core code in
 /wp-includes/script-loader.php#L2311 )

Ticket URL: <https://core.trac.wordpress.org/ticket/53006>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list