WP_Customize_Widgets::preview_sidebars_widgets( array $sidebars_widgets ): array

When previewing, ensures the proper previewing widgets are used.

Description

Because wp_get_sidebars_widgets() gets called early at ‘init’ (via wp_convert_widget_settings() ) and can set global variable $_wp_sidebars_widgets to the value of get_option( 'sidebars_widgets' ) before the Customizer preview filter is added, it has to be reset after the filter has been added.

Parameters

$sidebars_widgetsarrayrequired
List of widgets for the current sidebar.

Return

array

Source

public function preview_sidebars_widgets( $sidebars_widgets ) {
	$sidebars_widgets = get_option( 'sidebars_widgets', array() );

	unset( $sidebars_widgets['array_version'] );
	return $sidebars_widgets;
}

Changelog

VersionDescription
3.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.