WordPress at a glance
function is not described

WP_Customize_Widgets::sanitize_sidebar_widgets_js_instance() public WP 3.9.0

Strips out widget IDs for widgets which are no longer registered.

One example where this might happen is when a plugin orphans a widget in a sidebar upon deactivation.

{} It's a method of the class: WP_Customize_Widgets{}

No Hooks.


Array. Parsed list of widget IDs.


$WP_Customize_Widgets = new WP_Customize_Widgets();
$WP_Customize_Widgets->sanitize_sidebar_widgets_js_instance( $widget_ids );
$widget_ids(array) (required)
List of widget IDs.


  • Global. Array. $wp_registered_widgets


Since 3.9.0 Introduced.

Code of WP_Customize_Widgets::sanitize_sidebar_widgets_js_instance() WP 5.7.2

public function sanitize_sidebar_widgets_js_instance( $widget_ids ) {
	global $wp_registered_widgets;
	$widget_ids = array_values( array_intersect( $widget_ids, array_keys( $wp_registered_widgets ) ) );
	return $widget_ids;