PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.6.7
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.6.7
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Admin / Roles.php

Roles.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.6.7, at includes/Admin/Roles.php

75 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Admin;
4
5 use Templately\Utils\Base;
6 use Templately\Utils\Database;
7 use Templately\Utils\Options;
8
9 class Roles extends Base {
10 /**
11 * Database class
12 * @var Database
13 */
14 protected $database;
15
16 /**
17 * Options class
18 * @var Options
19 */
20 protected $options;
21
22 public function __construct() {
23 $this->database = new Database();
24 $this->options = new Options();
25 }
26
27 /**
28 * Default Roles Capabilities
29 *
30 * @return array
31 */
32 public function defaults_capabilities(): array {
33 $default_capabilities = [
34 'administrator' => [
35 'edit_templately_builder',
36 'edit_templately_settings'
37 ],
38 'editor' => [
39 ],
40 'author' => [
41 ],
42 'contributor' => [
43 ]
44 ];
45
46 return apply_filters( 'templately_default_caps', $default_capabilities );
47 }
48
49 public function setup( $remove = false ) {
50 if ( $this->options->get_option( '_templately_caps_initialized', false ) && ! $remove ) {
51 return;
52 }
53
54 global $wp_roles;
55
56 $capabilities = $this->defaults_capabilities();
57
58 if( $remove ) {
59 unset( $capabilities['administrator'] );
60 }
61
62 foreach ( $capabilities as $role => $caps ) {
63 foreach ( $caps as $cap ) {
64 if ( $remove ) {
65 $wp_roles->remove_cap( $role, $cap );
66 continue;
67 }
68
69 $wp_roles->add_cap( $role, $cap );
70 }
71 }
72
73 $this->options->get_option( '_betterdocs_caps_initialized', ! $remove );
74 }
75 }