Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ function register_site_icon_url( $response ) {
function gutenberg_register_widgets() {
if ( gutenberg_is_experiment_enabled( 'gutenberg-widget-experiments' ) ) {
register_widget( 'WP_Widget_Block' );
// By default every widget on widgets.php is wrapped with a <form>.
// This means that you can sometimes end up with invalid HTML, e.g. when
// one of the widgets is a Search block.
//
// To fix the problem, let's add a filter that moves the form below the actual
// widget content.
add_filter( 'dynamic_sidebar_params', function($arg) {
if($arg[0]['widget_name'] === 'Block'){
$arg[0]['before_form'] = '';
$arg[0]['before_widget_content'] = '<div class="widget-content">';
$arg[0]['after_widget_content'] = '</div><form class="block-widget-form">';
$arg[0]['after_form'] = '</form>';
}
return $arg;
} );
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/widgets-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function gutenberg_widgets_init( $hook ) {
if ( 'widgets.php' === $hook ) {
wp_enqueue_style( 'wp-block-library' );
wp_enqueue_style( 'wp-block-library-theme' );
wp_add_inline_style(
'wp-block-library-theme',
'.block-widget-form .widget-control-save { display: none; }'
);
return;
}
if ( ! in_array( $hook, array( 'gutenberg_page_gutenberg-widgets', 'gutenberg_customizer' ), true ) ) {
Expand Down