Uma área de pesquisa sobre o WordPress para devs e autores do tema



_wp_remove_unregistered_widgets ›

Desde4.9.0
Obsoleton/a
_wp_remove_unregistered_widgets ( $sidebars_widgets, $whitelist = array() )
Parâmetros: (2)
  • (array) $sidebars_widgets List of sidebars and their widget instance IDs.
    Required: Yes
  • (array) $whitelist Optional. List of widget IDs to compare against. Default: Registered widgets.
    Required: No
    Padrão: array()
Retorna:
  • (array) Sidebars with whitelisted widgets.
Definido em:
Codex:

Compares a list of sidebars with their widgets against a whitelist.



Fonte

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;
}