WordPress.org

Make WordPress Core

Ticket #16617: plugin.2.php

File plugin.2.php, 736 bytes (added by jrfoell, 3 years ago)

Procedural plugin

Line 
1<?php
2/*
3Plugin Name: Add Capabilities Procedural
4*/
5
6function add_cap_procedural_activation()
7{
8        $role = get_role( 'administrator' );
9        $role->add_cap( 'add_cap_proc' );
10}
11       
12function add_cap_procedural_deactivation()
13{
14        $role = get_role( 'administrator' );
15        $role->remove_cap( 'administrator', 'add_cap_proc' );
16}
17
18function add_cap_procedural_has_capability()
19{       
20        $role = get_role('administrator');
21        if($role->has_cap('add_cap_proc' ))
22        {
23                echo "<p>procedural success</p>";
24        }
25        else
26        {
27                echo "<p>procedural failure</p>";
28        }
29}
30
31register_activation_hook(__FILE__, 'add_cap_procedural_activation');
32register_deactivation_hook(__FILE__, 'add_cap_procedural_deactivation');
33add_action('admin_footer', 'add_cap_procedural_has_capability');