Context aware widgets. My work in progress

Just like you would from a widget() method:

function wse_widget_display_callback($instance)
{

   $show_it = true;
   if(isset($instance['noHome']) && $instance['noHome'] && is_home()) $show_it = false;
   if(isset($instance['noPages']) && $instance['noPages'] && is_page()) $show_it = false;
   ...

   if($show_it)
     return $instance;

   else
     return false;

}

I’ve posted here the functions I use to accomplish this, it might be helpful. The form hooks are here, but they are part of a class…

Leave a Comment