Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Add isDefault to server side block styles registry #30356

Closed
xavivars opened this issue Mar 29, 2021 · 3 comments
Closed

Blocks: Add isDefault to server side block styles registry #30356

xavivars opened this issue Mar 29, 2021 · 3 comments
Assignees
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes [Type] Enhancement A suggestion for improvement. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@xavivars
Copy link

xavivars commented Mar 29, 2021

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 https://github.com/WordPress/WordPress/blob/59d32bfe24cee58554ac82573d8a69dd6b6749ab/wp-includes/script-loader.php#L2311 )

@skorasaurus
Copy link
Member

Thanks for reporting. It's worth noting that there has been discussion on reconceptualizing what 'default' means when registering a block style and removing the isDefault property although no decision has been made.

@skorasaurus skorasaurus added [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Enhancement A suggestion for improvement. labels Mar 29, 2021
@gziolo gziolo added the [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. label Apr 9, 2021
@gziolo
Copy link
Member

gziolo commented Apr 9, 2021

Yes, it needs an upstream change in WordPress core. We should move it to WordPress trac.

@gziolo gziolo self-assigned this Apr 9, 2021
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Apr 9, 2021
@gziolo gziolo changed the title Add isDefault to server side block registry Blocks: Add isDefault to server side block styles registry Apr 9, 2021
@gziolo
Copy link
Member

gziolo commented Apr 9, 2021

Ticket in WP trac filed: https://core.trac.wordpress.org/ticket/53006. I will close this one. Let's continue there.

@gziolo gziolo closed this as completed Apr 9, 2021
@gziolo gziolo removed the [Status] In Progress Tracking issues with work in progress label Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes [Type] Enhancement A suggestion for improvement. [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

3 participants