wp_find_widgets_sidebar( string $widget_id ): string|null

Finds the sidebar that a given widget belongs to.


Parameters

$widget_id string Required
The widget ID to look for.

Top ↑

Return

string|null The found sidebar's ID, or null if it was not found.


Top ↑

Source

File: wp-includes/widgets.php. View all references

function wp_find_widgets_sidebar( $widget_id ) {
	foreach ( wp_get_sidebars_widgets() as $sidebar_id => $widget_ids ) {
		foreach ( $widget_ids as $maybe_widget_id ) {
			if ( $maybe_widget_id === $widget_id ) {
				return (string) $sidebar_id;
			}
		}
	}

	return null;
}


Top ↑

Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.