Compares a list of sidebars with their widgets against an allowed list.
Parameters
$sidebars_widgets
arrayrequired- List of sidebars and their widget instance IDs.
$allowed_widget_ids
arrayoptional- List of widget IDs to compare against. Default: Registered widgets.
Default:
array()
Source
function _wp_remove_unregistered_widgets( $sidebars_widgets, $allowed_widget_ids = array() ) {
if ( empty( $allowed_widget_ids ) ) {
$allowed_widget_ids = array_keys( $GLOBALS['wp_registered_widgets'] );
}
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( is_array( $widgets ) ) {
$sidebars_widgets[ $sidebar ] = array_intersect( $widgets, $allowed_widget_ids );
}
}
return $sidebars_widgets;
}
Changelog
Version | Description |
---|---|
4.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.