Make WordPress Core

Ticket #16617: plugin.php

File plugin.php, 1021 bytes (added by jrfoell, 14 years ago)

OO Plugin

Line 
1<?php
2/*
3Plugin Name: Add Capabilities OO
4*/
5
6class AddCapOO_Plugin {
7        public function onActivation()
8        {
9                $roleMgr = new WP_Roles();
10                $roleMgr->add_cap( 'administrator', 'add_cap_oo', true );
11        }
12
13        public function onDeactivation()
14        {
15                $roleMgr = new WP_Roles();
16                $roleMgr->remove_cap( 'administrator', 'add_cap_oo' );
17        }
18       
19    public function addDebugBox()
20    {
21        wp_add_dashboard_widget('dashboard_widget', 'Debug Dashboard Widget', array($this,'debugBox'));
22    }
23
24    public function hasCapability()
25    {
26        $roleMgr = new WP_Roles();
27        $role = $roleMgr->get_role('administrator');
28        if($role->has_cap('add_cap_oo' ))
29        {
30            echo "<p>oo success</p>";
31        }
32        else
33        {
34            echo "<p>oo failure</p>";
35        }
36    }
37}
38
39$addcap = new AddCapOO_Plugin();
40register_activation_hook(__FILE__, array($addcap, 'onActivation'));
41register_deactivation_hook(__FILE__, array($addcap, 'onDeactivation'));
42add_action('admin_footer', array($addcap, 'hasCapability'));