wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_wp_remove_unregistered_widgets › WordPress Function

Seit4.9.0
Veraltetn/v
_wp_remove_unregistered_widgets ( $sidebars_widgets, $allowed_widget_ids = array() )
Parameter: (2)
  • (array) $sidebars_widgets List of sidebars and their widget instance IDs.
    Erforderlich: Ja
  • (array) $allowed_widget_ids Optional. List of widget IDs to compare against. Default: Registered widgets.
    Erforderlich: Nein
    Standard: array()
Gibt zurück:
  • (array) Sidebars with allowed widgets.
Definiert in:
Codex:

Compares a list of sidebars with their widgets against an allowed list.



Quellcode

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