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

I want to limit the blocks available in the widget area. #33350

Closed
ddryo opened this issue Jul 12, 2021 · 2 comments
Closed

I want to limit the blocks available in the widget area. #33350

ddryo opened this issue Jul 12, 2021 · 2 comments
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@ddryo
Copy link
Contributor

ddryo commented Jul 12, 2021

I would like to limit the blocks available in the widget area to only the following two

  • Group
  • Legacy Widget

However, I want to freely place blocks inside the Group block.

What should I do in this case?

If there is currently no method to make this possible, I would like you to implement a way to make it happen.
Because the specification of the new widget feature will break the traditional theme. (Reference: #32723)

What I have tried

I was able to get the first control by using the 'allowed_block_types_all' hook.

add_filter( 'allowed_block_types_all', function ( $allowed_block_types, $block_editor_context ) {
    return ['core/legacy-widget', 'core/group' ];
}, 99, 2);

スクリーンショット 2021-07-12 11 45 14

In this case, the inside of the group block is also restricted.

@Mamaduka Mamaduka added [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets labels Jul 12, 2021
@talldan talldan added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Jul 12, 2021
@talldan
Copy link
Contributor

talldan commented Jul 12, 2021

Yes, allowed_block_types_all filters all the blocks available in the editor, even in inner blocks.

From what I understand, what you're asking isn't possible. There would need to be a few different things:

  • a way to limit the blocks available in the widget area block for the standalone widget editor
  • a way to limit the blocks available in the root block list in the customize widget editor, but in a way that doesn't affect child blocks
  • a way to define the blocks available in the group block

I realise this situation is not ideal. The widget grouping feature that you've been discussing is something that's being prioritised for after WordPress 5.8 (#33242). It's not possible now to release further enhancements to 5.8, as there's now a feature freeze and the release is fairly imminent.

While those contributing to the new widget screens hope to get everything right for 5.8, that hasn't been the case for this particular issue. The classic widgets plugin is the best option if things are not working for you, but hopefully a solution to this problem will be in place for 5.9 and everything will be back on track for you.

@ddryo
Copy link
Contributor Author

ddryo commented Jul 16, 2021

Thank you.
I'll turn it off until 5.9.

@ddryo ddryo closed this as completed Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants