Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#60906 new enhancement

Block Hooks: Allow adding toggle without injecting hooked block

Reported by: bernhard-reiter's profile Bernhard Reiter Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

It has been requested (by @simison) that it should be possible for a plugin to have the Block Hooks toggle (in the 'Plugins' Panel of an anchor block's block inspector) enabled, without actually inserting the block. The rationale for this is increased visibility, while still giving control to the responsible plugin to actually insert that block in its designated position (e.g. via a separate control panel by the plugin).

Change History (1)

#1 @Bernhard Reiter
5 months ago

I think this functionality should become available once we fix #59574 and #60756, which we’re tentatively planning for WP 6.6.

The tl;dr is that the toggle would infer its presence, its activation status, and the desired insertion position from the metadata.ignoredHookedBlocks attribute on the anchor block. If the hooked block is present in that array, the toggle will be present too; the toggle’s activation status is then simply determined by the presence or absence of the hooked block in the specified location.

This means that it’s possible to have the toggle displayed and set to disabled by injecting the ignoredHookedBlocks attribute into the markup, but not the hooked block itself. We probably don’t currently have an API surface for that (so it’d need to be done manually) but might add something.

Note that the technical feasibility doesn't imply that we've decided that Core should support this; I know @joen had some thoughts on the related User Experience.

Note: See TracTickets for help on using tickets.