wp_find_widgets_sidebar( string $widget_id )
Finds the sidebar that a given widget belongs to.
Parameters
- $widget_id
-
(string) (Required) The widget id to look for.
Return
(string|null) The found sidebar's id, or null if it was not found.
Source
File: wp-includes/widgets.php
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; }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_find_widgets_sidebar