Skip to content

Commit

Permalink
Add block editor to customize.php
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed May 25, 2021
1 parent 5e45c4b commit 7dcbf65
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 124 deletions.
39 changes: 1 addition & 38 deletions src/wp-admin/widgets-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,7 @@
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );

$editor_settings = get_block_editor_settings(
array(
/**
* Filters the list of widget-type IDs that should **not** be offered by the
* Legacy Widget block.
*
* Returning an empty array will make all widgets available.
*
* @since 5.8.0
*
* @param array $widgets An array of excluded widget-type IDs.
*/
'widgetTypesToHideFromLegacyWidgetBlock' => apply_filters(
'widget_types_to_hide_from_legacy_widget_block',
array(
'pages',
'calendar',
'archives',
'media_audio',
'media_image',
'media_gallery',
'media_video',
'meta',
'search',
'text',
'categories',
'recent-posts',
'recent-comments',
'rss',
'tag_cloud',
'nav_menu',
'custom_html',
'block',
)
),
),
$block_editor_context
);
$editor_settings = get_block_editor_settings( array(), $block_editor_context );

wp_add_inline_script(
'wp-edit-widgets',
Expand Down
16 changes: 1 addition & 15 deletions src/wp-admin/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,7 @@
$title = __( 'Widgets' );
$parent_file = 'themes.php';

/**
* Filters whether or not to use the block editor to manage widgets.
*
* @since 5.8.0
*
* @param boolean $use_widgets_block_editor Whether or not to use the block editor to manage widgets.
*/
$use_widgets_block_editor = apply_filters(
'use_widgets_block_editor',
get_theme_support( 'widgets-block-editor' )
);

$use_widgets_block_editor = true;

if ( $use_widgets_block_editor ) {
if ( wp_use_widgets_block_editor() ) {
require ABSPATH . 'wp-admin/widgets-form-blocks.php';
} else {
require ABSPATH . 'wp-admin/widgets-form.php';
Expand Down
34 changes: 34 additions & 0 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,40 @@ function get_default_block_editor_settings() {
$editor_settings['gradients'] = $gradient_presets;
}

/**
* Filters the list of widget-type IDs that should **not** be offered by the
* Legacy Widget block.
*
* Returning an empty array will make all widgets available.
*
* @since 5.8.0
*
* @param array $widgets An array of excluded widget-type IDs.
*/
$editor_settings['widgetTypesToHideFromLegacyWidgetBlock'] = apply_filters(
'widget_types_to_hide_from_legacy_widget_block',
array(
'pages',
'calendar',
'archives',
'media_audio',
'media_image',
'media_gallery',
'media_video',
'meta',
'search',
'text',
'categories',
'recent-posts',
'recent-comments',
'rss',
'tag_cloud',
'nav_menu',
'custom_html',
'block',
)
);

return $editor_settings;
}

Expand Down
5 changes: 5 additions & 0 deletions src/wp-includes/class-wp-customize-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,8 @@ protected function content_template() {}
* WP_Customize_Date_Time_Control class.
*/
require_once ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php';

/**
* WP_Sidebar_Block_Editor_Control class.
*/
require_once ABSPATH . WPINC . '/customize/class-wp-sidebar-block-editor-control.php';
Loading

0 comments on commit 7dcbf65

Please sign in to comment.