[wp-trac] [WordPress Trac] #55301: Provide an API to prevent certain blocks being shown in Widget Areas

WordPress Trac noreply at wordpress.org
Thu Mar 3 03:39:16 UTC 2022


#55301: Provide an API to prevent certain blocks being shown in Widget Areas
-------------------------+-------------------------
 Reporter:  noisysocks   |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  6.0
Component:  Editor       |    Version:
 Severity:  normal       |   Keywords:  needs-patch
  Focuses:               |
-------------------------+-------------------------
 Copied from https://github.com/WordPress/gutenberg/issues/28517. See
 discussion there.

 ---

 ## What problem does this address?
 With the introduction of Widget Areas, Gutenberg assumes all existing
 blocks will work in this context. We have a use case where some blocks may
 not work as widgets, or may conflict with legacy widgets or things such as
 shortcodes.

 https://github.com/woocommerce/woocommerce-gutenberg-products-
 block/pull/3737

 Gutenberg does provide the `widgets_to_exclude_from_legacy_widget_block `
 filter, but this only works on widgets.

 Unlike in the post editor screen (which provides `allowed_block_types `)
 there doesn't appear to be an filter, supports variable, or any API we can
 use to state that a block should not appear in this context.

 ## What is your proposed solution?
 Some form of supports flag when the block is registered, or an
 allow/denylist where the block can be excluded from the widget area block
 inserter.

 Our current solution/workaround is to check if `'themes.php' === $pagenow`
 and not register the block.

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


More information about the wp-trac mailing list