kasparsd/widget-context-wporg — pull request #8 by om4james (2013-10-17 03:20:47+00:00)
Title: New filters so that other plugins can override widget context visibility checks

Example use case:

A user might like the 'single post' checkbox to only apply to posts (and not other custom post types).

Currently it would apply to any custom post type.

With these new filters, the default behaviour doesn't change.

However following code could be used in another plugin to implement the above logic:

```
function widget_context_currently_override( $currently ) {

if( empty( $currently ) ) {
return $currently;
}

if ( isset($currently['is_single']) && $currently['is_single'] && 'post' !== get_post_type() ) {
// Ensure the widget doesn't display for other post types
unset($currently['is_single']);
}

return $currently;
}
add_filter( 'widget_context_currently', 'widget_context_currently_override' );
```