Make WordPress Core

Opened 2 years ago

Closed 8 months ago

Last modified 4 months ago

#55319 closed enhancement (reported-upstream)

Add filter to get_block_wrapper_attributes function

Reported by: fabiankaegy's profile fabiankaegy Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: Cc:


What problem does this address?

It is currently possible to add custom classnames to static blocks using the blocks.getSaveContent.extraProps filter in JS. This is super useful when working with custom block supports. And even core uses this system in js to add the classnames generated for for example the color classes.

In PHP however, for custom blocks this is all hardcoded in the get_block_wrapper_attributes function. Specifically inside the WP_Block_Supports Class here:

This approach makes it impossible for custom supports that plugins develop to apply to custom blocks.

What is your proposed solution?

This could be solved by adding a new hook in PHP to the get_block_wrapper_attributes function which should work the same as the
blocks.getSaveContent.extraProps hook in js.

This ticket was first created in GitHub on the Gutenberg repository in #38830( but as the code no longer exists in Gutenberg since it was moved to core in 5.8 it was suggested that the change needs to happen in core directly.

Change History (3)

#1 @fabiankaegy
2 years ago

This ticket and how it should be approached was discussed in slack here:

#2 @fabiankaegy
8 months ago

  • Resolution set to reported-upstream
  • Status changed from new to closed

This ticket was discussed in GitHub and got resolved there

#3 @swissspidy
4 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.