Visibility per role for your own items
Addofy lets an administrator choose per role which menus, meta boxes, columns and notices are visible. You can add a type of your own, so the items of your plugin show up in the same Visibility tab.
Add a type and a collector
Add a type with the adba_visibility_types filter and record its items with a collector through the adba_visibility_collectors filter. The Visibility tab, the export and the import then handle your type.
A collector implements Visibility\Collectors\CollectorInterface; extend AbstractCollector for the defaults.
Apply the rule yourself
Addofy only applies rules to its own six types. For your type, hide your items yourself:
if ( adba( 'rules' )->is_hidden( 'myplugin_panel', 'stats' ) ) {
return; // Do not render the panel for this role.
}
Visibility\RuleEngine::is_hidden() is the public method behind adba( 'rules' ).
Items that can never be hidden
adba_protected_items adds items that can never be hidden. Addofy's own menu is always protected, and so are its settings tabs and templates: no hook can hide them.