_wp_remove_unregistered_widgets( array $sidebars_widgets, array $whitelist = array() )
Compares a list of sidebars with their widgets against a whitelist.
Parameters
- $sidebars_widgets
-
(Required) List of sidebars and their widget instance IDs.
- $whitelist
-
(Optional) List of widget IDs to compare against. Default: Registered widgets.
Default value: array()
Return
(array) Sidebars with whitelisted widgets.
Source
File: wp-includes/widgets.php
function _wp_remove_unregistered_widgets( $sidebars_widgets, $whitelist = array() ) {
if ( empty( $whitelist ) ) {
$whitelist = array_keys( $GLOBALS['wp_registered_widgets'] );
}
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( is_array( $widgets ) ) {
$sidebars_widgets[ $sidebar ] = array_intersect( $widgets, $whitelist );
}
}
return $sidebars_widgets;
}
Changelog
Version | Description |
---|---|
WP-4.9.0 | Introduced. |