I have 2 registered sidebars in my theme one for Products and one for Blog.
What I am trying to do is if my "Category" widget is added to the Product Sidebar the taxonomy is automatically set to "product_cats" and if added to the Blog Sidebar set the taxonomy to "category". This will allow my widget on the backend to update which categories it displays in the dropdown menu.
I have been searching the wp-includes/widgets.php file for a method or property that contains the id or name of the Parent Sidebar of the widget but can't seem to find a way to do this.
If I can get the name or id of the Parent Sidebar I would do something like this in the form method of my widget:
public function form( $instance ) {
$parent = getParentSidebarID($this); // How do you do this!
switch ($parent) {
case 'product-sidebar':
$tax = 'product_cat';
break;
case 'blog-sidebar':
$tax = 'category';
break;
default:
$tax = '';
break;
}
}
Is this possible?