Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move widgetTypesToHideFromLegacyWidgetBlock
  • Loading branch information
noisysocks committed Jun 15, 2021
commit a4e7764f4d2f97c31af2b27fdd658c1a619f8433
5 changes: 4 additions & 1 deletion src/wp-admin/widgets-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );

$editor_settings = get_block_editor_settings( array(), $block_editor_context );
$editor_settings = get_block_editor_settings(
get_legacy_widget_block_editor_settings(),
$block_editor_context
);

wp_add_inline_script(
'wp-edit-widgets',
Expand Down
14 changes: 14 additions & 0 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ function get_default_block_editor_settings() {
$editor_settings['gradients'] = $gradient_presets;
}

return $editor_settings;
}

/**
* Returns the block editor settings needed to use the Legacy Widget block which
* is not registered by default.
*
* @since 5.8.0
*
* @return array Settings to be used with get_block_editor_settings().
*/
function get_legacy_widget_block_editor_settings() {
$editor_settings = array();

/**
* Filters the list of widget-type IDs that should **not** be offered by the
* Legacy Widget block.
Expand Down
5 changes: 4 additions & 1 deletion src/wp-includes/class-wp-customize-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,10 @@ public function enqueue_scripts() {
if ( wp_use_widgets_block_editor() ) {
$block_editor_context = new WP_Block_Editor_Context();

$editor_settings = get_block_editor_settings( array(), $block_editor_context );
$editor_settings = get_block_editor_settings(
get_legacy_widget_block_editor_settings(),
$block_editor_context
);

wp_add_inline_script(
'wp-customize-widgets',
Expand Down
10 changes: 9 additions & 1 deletion tests/phpunit/tests/blocks/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function test_get_allowed_block_types_deprecated_filter_post_editor() {
function test_get_default_block_editor_settings() {
$settings = get_default_block_editor_settings();

$this->assertCount( 17, $settings );
$this->assertCount( 16, $settings );
$this->assertFalse( $settings['alignWide'] );
$this->assertInternalType( 'array', $settings['allowedMimeTypes'] );
$this->assertTrue( $settings['allowedBlockTypes'] );
Expand Down Expand Up @@ -265,6 +265,14 @@ function test_get_default_block_editor_settings() {
$settings['imageSizes']
);
$this->assertInternalType( 'int', $settings['maxUploadFileSize'] );
}

/**
* @ticket 53397
*/
function test_get_legacy_widget_block_editor_settings() {
$settings = get_legacy_widget_block_editor_settings();
$this->assertCount( 1, $settings );
$this->assertSameSets(
array(
'archives',
Expand Down