Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#53006 closed enhancement (fixed)

Blocks: Add isDefault to server side block styles registry

Reported by: gziolo's profile gziolo Owned by: gziolo's profile gziolo
Milestone: 5.8 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: has-patch
Focuses: Cc:

Description (last modified by gziolo)

Moved from GitHub (, reported by xavivars).

What problem does this address?

[As documented here](, 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 one.

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 )

Attachments (1)

53006.patch (550 bytes) - added by mukesh27 3 years ago.
Initial patch

Download all attachments as: .zip

Change History (9)

#1 @gziolo
3 years ago

  • Description modified (diff)

3 years ago

Initial patch

#2 @mukesh27
3 years ago

  • Keywords has-patch added

Hi there!

Initital 53006.patch patch uploaded.

#3 @gziolo
3 years ago

That was quick, I will test next week if nobody beats me up to it :)

#4 @xavivars
3 years ago

So it seems it sounds like a idea. I didn't push a patch because I wanted to see what people thought before, via the github issue, but I'm glad you agree with the proposal

#5 @gziolo
3 years ago

This will require additional changes in

Given that I see inline_style and style_handle fields that use snake case, I'm leaning towards is_default.

I tested with

        'name'         => 'green-list',
        'label'        => __( 'Green List' ),
        'name'         => 'blue-list',
        'label'        => __( 'Blue List' ),
        'is_default'   => true,

I can confirm that it correctly applies changes with the example used.

#6 @gziolo
3 years ago

  • Component changed from General to Editor

#7 @gziolo
3 years ago

  • Owner set to gziolo
  • Resolution set to fixed
  • Status changed from new to closed

In 50703:

Blocks: Add is_default handling to server side block styles registry

Ensures that register_block_style lets developer pass is_default flag to mark one of the block style variations as the default one.

Props mukesh27, xavivars.
Fixes #53006.

#8 @gziolo
3 years ago

Documentation changes applied on the Gutenberg project side in

Note: See TracTickets for help on using tickets.