I think is a better strategy, that you add on the activation a new capability and add this capability to the Administrator role. This makes possible for installations with much different roles to the WP default to add this capability to other roles or for the requirement of a installation to add the view to another role.
Add Cap to a Role
add_action( 'admin_init', 'fb_add_capabilities' );
function fb_add_capabilities() {
`$GLOBALS['wp_roles']->add_cap( 'administrator', '_your_custom_cap' );`
}
Check for Cap
Inside your source can you check for this capabilty:
if ( ! current_user_can( '_debug_objects' ) )
return;
Remove Cap
On the deactivation (Hook register_deactivation_hook
) and uninstall (Hook register_uninstall_hook
) of the plugin is it necessary, that you remove the cap.
remove_cap()
Example
A example in the wild can you finde in this plugin, file.