wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_find_widgets_sidebar › WordPress Function

Since5.8.0
已弃用n/a
wp_find_widgets_sidebar ( $widget_id )
参数:
  • (string) $widget_id The widget ID to look for.
    Required: Yes
返回:
  • (string|null) The found sidebar's ID, or null if it was not found.
定义在:
文档:

Finds the sidebar that a given widget belongs to.



源码

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