私はCalleの答えの方が好きですが、これらの条件がない場合はこれでうまくいきます。
class Example {
protected $lastWidget = false;
public function __construct() {
add_filter('dynamic_sidebar_params', array($this, 'filterSidebarParams'));
}
/**
* record what sidebar widget is being processed
* @param array $widgetParams
* @return array
*/
public function filterSidebarParams($widgetParams) {
$this->lastWidget = $widgetParams;
return $widgetParams;
}
/**
* check to see if last widget recorded was in sidebar
* @param string $sidebarName
* @return bool
*/
public function isLastSidebar($sidebarName) {
return $this->lastWidget && $this->lastWidget[0]['id'] == $sidebarName;
}
}
$example = new Example();
// in your widget's code
if ($example->isLastSidebar('footer-widget-area')) {
// you're in
}