PluginProbe
Members – Membership & User Role Editor Plugin / 3.2.24
Members – Membership & User Role Editor Plugin v3.2.24
3.2.25 3.2.26 3.2.24 3.2.23 3.2.22 3.2.21 trunk 0.1 0.1.1 0.2 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 2.0.0 2.0.1 2.0.2 All 66 releases
members / admin / class-cap-section.php

class-cap-section.php in Members – Membership & User Role Editor Plugin 3.2.24, at admin/class-cap-section.php

120 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Capability section class for use in the edit capabilities tabs.
4 *
5 * @package Members
6 * @subpackage Admin
7 * @author The MemberPress Team
8 * @copyright Copyright (c) 2009 - 2018, The MemberPress Team
9 * @link https://members-plugin.com/
10 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11 */
12 namespace Members\Admin;
13
14 defined('ABSPATH') || exit;
15 /**
16 * Cap section class.
17 *
18 * @since 2.0.0
19 * @access public
20 */
21 final class Cap_Section {
22
23 /**
24 * Stores the cap tabs object.
25 *
26 * @see Members_Cap_Tabs
27 * @since 2.0.0
28 * @access public
29 * @var object
30 */
31 public $manager;
32
33 /**
34 * ID of the section.
35 *
36 * @since 2.0.0
37 * @access public
38 * @var string
39 */
40 public $section = '';
41
42 /**
43 * Dashicons icon for the section.
44 *
45 * @since 2.0.0
46 * @access public
47 * @var string
48 */
49 public $icon = 'dashicons-admin-generic';
50
51 /**
52 * Label for the section.
53 *
54 * @since 2.0.0
55 * @access public
56 * @var string
57 */
58 public $label = '';
59
60 /**
61 * Array of data to pass as a json object to the Underscore template.
62 *
63 * @since 2.0.0
64 * @access public
65 * @var array
66 */
67 public $json = array();
68
69 /**
70 * Creates a new section object.
71 *
72 * @since 2.0.0
73 * @access public
74 * @param object $manager
75 * @param string $section
76 * @param array $args
77 * @return void
78 */
79 public function __construct( $manager, $section, $args = array() ) {
80
81 foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
82
83 if ( isset( $args[ $key ] ) )
84 $this->$key = $args[ $key ];
85 }
86
87 $this->manager = $manager;
88 $this->section = $section;
89 }
90
91 /**
92 * Returns the json array.
93 *
94 * @since 2.0.0
95 * @access public
96 * @return array
97 */
98 public function json() {
99 $this->to_json();
100 return $this->json;
101 }
102
103 /**
104 * Adds custom data to the json array. This data is passed to the Underscore template.
105 *
106 * @since 2.0.0
107 * @access public
108 * @return void
109 */
110 public function to_json() {
111
112 // Is the role editable?
113 $is_editable = $this->manager->role ? members_is_role_editable( $this->manager->role->name ) : true;
114
115 // Set up the ID and class.
116 $this->json['id'] = $this->section;
117 $this->json['class'] = 'members-tab-content' . ( $is_editable ? ' editable-role' : '' );
118 }
119 }
120