1 <?php
2
3 /*
4 * WORDSMITH CAPABILITY CLASS
5 *
6 * this class is the base object for a custom action to be added into wordpress.
7 * it is a best prectise initiative that all actions to implement custom wordpress logic be enclosed in a single class which exnteds this class.
8 */
9
10 namespace nk2580\wordsmith\UserCapabilities;
11
12 class UserCapability {
13
14 public $role_name;
15 public $caps;
16
17 public function __construct() {
18 add_action( 'admin_init', array($this,'add_theme_caps'));
19 }
20 function add_theme_caps() {
21 $role = get_role( $this->role_name );
22 if(is_array($this->caps)){
23 foreach($this->caps as $cap){
24 $role->add_cap( $cap );
25 }
26 }
27 else{
28 $role->add_cap( $this->caps );
29 }
30 }
31
32 }
33