Created
July 28, 2013 15:34
-
-
Save dan-westall/6098980 to your computer and use it in GitHub Desktop.
Will return sidebar name when given widget id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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