Skip to content

Commit

Permalink
Enable customizer legacy widgets only if set
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Aug 8, 2019
1 parent 0ca4756 commit 640d0e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ function gutenberg_customize_register( $wp_customize ) {
'sanitize_callback' => 'gutenberg_customize_sanitize',
)
);
$wp_customize->add_section(
'gutenberg_widget_blocks',
array( 'title' => __( 'Widget Blocks (Experimental)', 'gutenberg' ) )
);
if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-widget-experiments', get_option( 'gutenberg-experiments' ) ) ) {
$wp_customize->add_section(
'gutenberg_widget_blocks',
array( 'title' => __( 'Widget Blocks (Experimental)', 'gutenberg' ) )
);
}
$wp_customize->add_control(
new WP_Customize_Widget_Blocks_Control(
$wp_customize,
Expand Down
12 changes: 8 additions & 4 deletions lib/widgets-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ function gutenberg_widgets_init( $hook ) {
);
}

$experiments_exist = get_option( 'gutenberg-experiments' );
$legacy_widget_experiment = $experiments_exist ? array_key_exists( 'gutenberg-widget-experiments', get_option( 'gutenberg-experiments' ) ) : false;

$settings = array_merge(
array(
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'imageSizes' => $available_image_sizes,
'maxUploadFileSize' => $max_upload_size,
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'imageSizes' => $available_image_sizes,
'maxUploadFileSize' => $max_upload_size,
'__experimentalEnableLegacyWidgetBlock' => $legacy_widget_experiment,
),
gutenberg_get_legacy_widget_settings()
);
Expand Down
3 changes: 3 additions & 0 deletions packages/edit-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export function initialize( id, settings ) {
*/
export function customizerInitialize( id, settings ) {
registerCoreBlocks();
if ( process.env.GUTENBERG_PHASE === 2 ) {
__experimentalRegisterExperimentalCoreBlocks( settings );
}
render(
<CustomizerEditWidgetsInitializer
settings={ settings }
Expand Down

0 comments on commit 640d0e4

Please sign in to comment.