Skip to content

Instantly share code, notes, and snippets.

@dan-westall
Created July 28, 2013 15:34
Show Gist options
  • Save dan-westall/6098980 to your computer and use it in GitHub Desktop.
Save dan-westall/6098980 to your computer and use it in GitHub Desktop.
Will return sidebar name when given widget id
function dw_get_widget_location($id){
global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets;
$widget_id = $id;
$widget = $wp_registered_widgets[$widget_id];
foreach($_wp_sidebars_widgets as $key => $value){
$sidebar = $key;
if(is_array($value)){
foreach($value as $widget){
$widgetLocations[$widget] = $sidebar;
}
}
}
return $wp_registered_sidebars[$widgetLocations[$id]]['name'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment