-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Custom Blocks don't show up in Widgets #15644
Comments
How did you register your block types? Have you verified your scripts are loaded on that screen? |
I just ran into this issue. @swissspidy do you have any more info about how custom blocks should be registered so they show up in the widget editor? I would have expected that if a block is registered successfully and shows up when editing a post, that it would automatically also show up in the widget editor, but that doesn't seem to be the case. |
The root cause are these two checks: https://github.com/WordPress/wordpress-develop/blob/23528d419ab2968f250392e8552095783b138fec/src/wp-includes/script-loader.php#L2165 Neither widgets nor navigation editors are marked block editor pages which seems to be required for custom block types to be loaded. Unfortunately the resolution is not as simple as marking them as block editor pages since it results in the following: It seems like $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor();
$should_load_block_scripts_and_styles = apply_filters( 'should_load_block_scripts_and_styles', $is_block_editor_screen, $current_screen );
if ( is_admin() && ! $should_load_block_scripts_and_styles ) {
return;
} |
Since this requires updating the core, I created a core PR and a Trac ticket: WordPress/wordpress-develop#537 |
Removing the needs testing label and changing this to a WP Core Bug since this requires a core update. |
Now that the core patch is merged, I started working on the Gutenberg part here: #25826 |
Describe the bug
Custom-created Blocks can't be accessed in the widget-editor (e.g. in the Footer)
To reproduce
Steps to reproduce the behavior:
Expected behavior
Custom created blocks should be displayed and accessible.
Screenshots
Block selection of regular posts:
Block selection of widgets:
Desktop
Additional context
The text was updated successfully, but these errors were encountered: