Skip to content

Commit

Permalink
Enable customizer legacy widgets only if set (#16956)
Browse files Browse the repository at this point in the history
* Enable customizer legacy widgets only if set

* Only add control if experiment enabled.

* Remove unnecessary repetition
  • Loading branch information
tellthemachines authored Sep 3, 2019
1 parent 6a06143 commit a400f7b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
26 changes: 14 additions & 12 deletions lib/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,22 @@ function gutenberg_customize_register( $wp_customize ) {
'sanitize_callback' => 'gutenberg_customize_sanitize',
)
);
$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,
if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-widget-experiments', get_option( 'gutenberg-experiments' ) ) ) {
$wp_customize->add_section(
'gutenberg_widget_blocks',
array(
'section' => 'gutenberg_widget_blocks',
'settings' => 'gutenberg_widget_blocks',
array( 'title' => __( 'Widget Blocks (Experimental)', 'gutenberg' ) )
);
$wp_customize->add_control(
new WP_Customize_Widget_Blocks_Control(
$wp_customize,
'gutenberg_widget_blocks',
array(
'section' => 'gutenberg_widget_blocks',
'settings' => 'gutenberg_widget_blocks',
)
)
)
);
);
}
}
add_action( 'customize_register', 'gutenberg_customize_register' );

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function gutenberg_widgets_init( $hook ) {
wp.editWidgets.%s( "widgets-editor", %s );
} );',
$initializer_name,
wp_json_encode( $settings )
wp_json_encode( gutenberg_experiments_editor_settings( $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 a400f7b

Please sign in to comment.