<?php
/*
Plugin Name: Add Capabilities OO
*/

class AddCapOO_Plugin {
	public function onActivation()
	{
		$roleMgr = new WP_Roles();
		$roleMgr->add_cap( 'administrator', 'add_cap_oo', true );
	}

	public function onDeactivation()
	{
		$roleMgr = new WP_Roles();
		$roleMgr->remove_cap( 'administrator', 'add_cap_oo' );
	}
	
    public function addDebugBox()
    {
        wp_add_dashboard_widget('dashboard_widget', 'Debug Dashboard Widget', array($this,'debugBox'));
    }

    public function hasCapability()
    {
        $roleMgr = new WP_Roles();
        $role = $roleMgr->get_role('administrator');
        if($role->has_cap('add_cap_oo' ))
        {
            echo "<p>oo success</p>";
        }
        else
        {
            echo "<p>oo failure</p>";
        }
    }
}

$addcap = new AddCapOO_Plugin();
register_activation_hook(__FILE__, array($addcap, 'onActivation'));
register_deactivation_hook(__FILE__, array($addcap, 'onDeactivation'));
add_action('admin_footer', array($addcap, 'hasCapability'));
