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

Add option to filter specific blocks to specific widget areas #34788

Open
myleshyson opened this issue Sep 13, 2021 · 4 comments
Open

Add option to filter specific blocks to specific widget areas #34788

myleshyson opened this issue Sep 13, 2021 · 4 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Enhancement A suggestion for improvement.

Comments

@myleshyson
Copy link
Contributor

What problem does this address?

I would like to filter what blocks are available on a per widget area basis. Currently there doesn't seem to be a way to do this.

What is your proposed solution?

Something like this would be ideal

register_sidebar( [
    'name'            => __( 'Primary Sidebar', 'theme_name' ),
    'allowed_blocks'  => [ 'core/paragraph', 'core/latest-posts' ]
] );
@spacedmonkey spacedmonkey added [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. labels Sep 14, 2021
@myleshyson
Copy link
Contributor Author

This is related to #28517, and and I'm wondering if this should be included along with that issue?

For more context, this is important for us because some blocks don't make sense for certain contexts. For example, the columns block makes sense for a Footer widget area, but definitely should not be allowed for a Post Sidebar widget area. We need a way to force those distinctions for our editors.

@noisysocks
Copy link
Member

Grea idea. Let's include it as part of #28517 so that there isn't too many issues floating around. I'll copy your suggestion in there.

@noisysocks
Copy link
Member

Reopening this as #28517 didn't add the exact API proposed here.

@noisysocks noisysocks reopened this Aug 26, 2022
@noisysocks noisysocks added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience labels Aug 26, 2022
@cr0ybot
Copy link
Contributor

cr0ybot commented Oct 5, 2022

I'm completely failing at finding a workaround to this problem, the proposed API in register_sidebar with allowed_blocks looks rad. I'm particularly keen on creating a Social widget area that only allows the social-links and social-link blocks so that I can output a site's social media links/icons in different places while keeping the data to one source of truth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants