Version Description
If upgrading from a version prior to 2.0.0, please note that the plugin now requires PHP 5.3.0 or later.
Download this release
Release Info
Developer | greenshady |
Plugin | Members |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 2.0.0
- admin/class-addon.php +173 -0
- admin/class-cap-control.php +15 -12
- admin/class-cap-group-factory.php +0 -115
- admin/class-cap-section.php +15 -13
- admin/class-cap-tabs.php +46 -26
- admin/class-manage-roles.php +19 -17
- admin/class-manage-users.php +466 -0
- admin/class-meta-box-content-permissions.php +121 -43
- admin/class-meta-box-custom-cap.php +15 -13
- admin/class-meta-box-publish-role.php +14 -12
- admin/class-role-edit.php +39 -25
- admin/class-role-group-factory.php +0 -115
- admin/class-role-group.php +0 -129
- admin/class-role-list-table.php +93 -66
- admin/class-role-new.php +27 -25
- admin/class-roles.php +22 -20
- admin/class-settings.php +159 -341
- admin/class-user-edit.php +77 -35
- admin/class-user-new.php +240 -0
- admin/functions-addons.php +149 -0
- admin/functions-admin.php +9 -77
- admin/functions-help.php +11 -4
- admin/functions-role-groups.php +0 -165
- admin/functions-settings.php +118 -0
- admin/tmpl/cap-control.php +4 -4
- admin/tmpl/cap-section.php +3 -3
- admin/tmpl/cp-control-message.php +0 -11
- admin/tmpl/cp-control-role.php +0 -25
- admin/tmpl/cp-nav.php +0 -1
- admin/tmpl/cp-section.php +0 -3
- admin/views/class-view-addons.php +244 -0
- admin/views/class-view-general.php +456 -0
- admin/views/class-view.php +154 -0
- changelog.md +41 -1
- composer.json +23 -0
- css/admin.css +101 -13
- css/admin.min.css +1 -1
- img/icon-addon.png +0 -0
- img/icon-members-role-hierarchy.png +0 -0
- img/icon-members-role-levels.png +0 -0
- {admin → inc}/class-cap-group.php +29 -23
- inc/class-capability.php +81 -0
- inc/class-registry.php +149 -0
- inc/class-role-factory.php +0 -165
- inc/class-role-group.php +104 -0
- inc/class-role.php +52 -73
- inc/class-widget-login.php +23 -21
- inc/class-widget-users.php +17 -15
- inc/functions-admin-bar.php +3 -3
- {admin → inc}/functions-cap-groups.php +111 -208
- inc/functions-capabilities.php +226 -112
- inc/functions-content-permissions.php +40 -2
- inc/functions-deprecated.php +387 -11
- inc/functions-options.php +25 -3
- inc/functions-private-site.php +115 -11
- inc/functions-role-groups.php +124 -0
- inc/functions-role-meta.php +0 -59
- inc/functions-roles.php +125 -146
- inc/functions-shortcodes.php +33 -15
- inc/functions-users.php +57 -11
- inc/functions-widgets.php +7 -7
- inc/functions.php +19 -3
- inc/template.php +3 -3
- js/edit-post.js +23 -142
- js/edit-post.min.js +1 -0
- js/edit-role.js +7 -2
- js/edit-role.min.js +1 -1
- lang/members.pot +1267 -0
- languages/members.pot +0 -830
- members.php +74 -105
- readme.md +66 -4
- readme.txt +20 -12
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
admin/class-addon.php
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for handling an add-on object.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Add-on object class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
final class Addon {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Name/ID for the addon.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access protected
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $name = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Title of the add-on.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access protected
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $title = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Short description of the add-on.
|
43 |
+
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access protected
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
public $excerpt = '';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* URL where the add-on can be found.
|
52 |
+
*
|
53 |
+
* @since 2.0.0
|
54 |
+
* @access protected
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
public $url = 'https://themehybrid.com/plugins/members';
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Add-on ZIP file URL.
|
61 |
+
*
|
62 |
+
* @since 2.0.0
|
63 |
+
* @access protected
|
64 |
+
* @var string
|
65 |
+
*/
|
66 |
+
public $download_url = '';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Alternate purchase URL.
|
70 |
+
*
|
71 |
+
* @since 2.0.0
|
72 |
+
* @access protected
|
73 |
+
* @var string
|
74 |
+
*/
|
75 |
+
public $purchase_url = '';
|
76 |
+
|
77 |
+
/**
|
78 |
+
* URL for a 128x128 (size used by WordPress.org) icon image.
|
79 |
+
*
|
80 |
+
* @since 2.0.0
|
81 |
+
* @access protected
|
82 |
+
* @var string
|
83 |
+
*/
|
84 |
+
public $icon_url = '';
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Add-on plugin's author URL.
|
88 |
+
*
|
89 |
+
* @since 2.0.0
|
90 |
+
* @access protected
|
91 |
+
* @var string
|
92 |
+
*/
|
93 |
+
public $author_url = '';
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Add-on plugin's author display name.
|
97 |
+
*
|
98 |
+
* @since 2.0.0
|
99 |
+
* @access protected
|
100 |
+
* @var string
|
101 |
+
*/
|
102 |
+
public $author_name = '';
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Rating for the add-on. This is the total rating based on a 5-star rating system.
|
106 |
+
* It will be divided by the rating count, so both must be supplied.
|
107 |
+
*
|
108 |
+
* @since 2.0.0
|
109 |
+
* @access protected
|
110 |
+
* @var int
|
111 |
+
*/
|
112 |
+
public $rating = '';
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Number of ratings.
|
116 |
+
*
|
117 |
+
* @since 2.0.0
|
118 |
+
* @access protected
|
119 |
+
* @var int
|
120 |
+
*/
|
121 |
+
public $rating_count = 0;
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Number of active installs. Note that this will be displayed with a `+` at
|
125 |
+
* the end, such as `100,000+`. Exact counts are necessary. Just a round number.
|
126 |
+
*
|
127 |
+
* @since 2.0.0
|
128 |
+
* @access protected
|
129 |
+
* @var string
|
130 |
+
*/
|
131 |
+
public $install_count = 0;
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Magic method to use in case someone tries to output the object as a string.
|
135 |
+
* We'll just return the name.
|
136 |
+
*
|
137 |
+
* @since 2.0.0
|
138 |
+
* @access public
|
139 |
+
* @return string
|
140 |
+
*/
|
141 |
+
public function __toString() {
|
142 |
+
return $this->name;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Register a new object.
|
147 |
+
*
|
148 |
+
* @since 2.0.0
|
149 |
+
* @access public
|
150 |
+
* @param string $name
|
151 |
+
* @param array $args {
|
152 |
+
* @type string $label Internationalized text label.
|
153 |
+
* @type string $icon Dashicon icon in the form of `dashicons-icon-name`.
|
154 |
+
* @type array $caps Array of capabilities in the addon.
|
155 |
+
* @type bool $merge_added Whether to merge this caps into the added caps array.
|
156 |
+
* @type bool $diff_added Whether to remove previously-added caps from this addon.
|
157 |
+
* }
|
158 |
+
* @return void
|
159 |
+
*/
|
160 |
+
public function __construct( $name, $args = array() ) {
|
161 |
+
|
162 |
+
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
163 |
+
|
164 |
+
if ( isset( $args[ $key ] ) )
|
165 |
+
$this->$key = $args[ $key ];
|
166 |
+
}
|
167 |
+
|
168 |
+
$this->name = sanitize_key( $name );
|
169 |
+
|
170 |
+
if ( ! $this->icon_url )
|
171 |
+
$this->icon_url = members_plugin()->dir_uri . 'img/addon.png';
|
172 |
+
}
|
173 |
+
}
|
admin/class-cap-control.php
CHANGED
@@ -4,25 +4,27 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Cap control class.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Stores the cap tabs object.
|
23 |
*
|
24 |
* @see Members_Cap_Tabs
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var object
|
28 |
*/
|
@@ -31,7 +33,7 @@ final class Members_Cap_Control {
|
|
31 |
/**
|
32 |
* Name of the capability the control is for.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var string
|
37 |
*/
|
@@ -40,7 +42,7 @@ final class Members_Cap_Control {
|
|
40 |
/**
|
41 |
* ID of the section the control is for.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var string
|
46 |
*/
|
@@ -49,7 +51,7 @@ final class Members_Cap_Control {
|
|
49 |
/**
|
50 |
* Array of data to pass as a json object to the Underscore template.
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
* @var array
|
55 |
*/
|
@@ -58,7 +60,7 @@ final class Members_Cap_Control {
|
|
58 |
/**
|
59 |
* Creates a new control object.
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @param object $manager
|
64 |
* @param string $cap
|
@@ -80,7 +82,7 @@ final class Members_Cap_Control {
|
|
80 |
/**
|
81 |
* Returns the json array.
|
82 |
*
|
83 |
-
* @since
|
84 |
* @access public
|
85 |
* @return array
|
86 |
*/
|
@@ -92,7 +94,7 @@ final class Members_Cap_Control {
|
|
92 |
/**
|
93 |
* Adds custom data to the json array. This data is passed to the Underscore template.
|
94 |
*
|
95 |
-
* @since
|
96 |
* @access public
|
97 |
* @return void
|
98 |
*/
|
@@ -112,6 +114,7 @@ final class Members_Cap_Control {
|
|
112 |
|
113 |
// Set up the input labels.
|
114 |
$this->json['label'] = array(
|
|
|
115 |
'grant' => sprintf( esc_html__( 'Grant %s capability', 'members' ), "<code>{$this->cap}</code>" ),
|
116 |
'deny' => sprintf( esc_html__( 'Deny %s capability', 'members' ), "<code>{$this->cap}</code>" )
|
117 |
);
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Cap control class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Cap_Control {
|
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 |
*/
|
33 |
/**
|
34 |
* Name of the capability the control is for.
|
35 |
*
|
36 |
+
* @since 2.0.0
|
37 |
* @access public
|
38 |
* @var string
|
39 |
*/
|
42 |
/**
|
43 |
* ID of the section the control is for.
|
44 |
*
|
45 |
+
* @since 2.0.0
|
46 |
* @access public
|
47 |
* @var string
|
48 |
*/
|
51 |
/**
|
52 |
* Array of data to pass as a json object to the Underscore template.
|
53 |
*
|
54 |
+
* @since 2.0.0
|
55 |
* @access public
|
56 |
* @var array
|
57 |
*/
|
60 |
/**
|
61 |
* Creates a new control object.
|
62 |
*
|
63 |
+
* @since 2.0.0
|
64 |
* @access public
|
65 |
* @param object $manager
|
66 |
* @param string $cap
|
82 |
/**
|
83 |
* Returns the json array.
|
84 |
*
|
85 |
+
* @since 2.0.0
|
86 |
* @access public
|
87 |
* @return array
|
88 |
*/
|
94 |
/**
|
95 |
* Adds custom data to the json array. This data is passed to the Underscore template.
|
96 |
*
|
97 |
+
* @since 2.0.0
|
98 |
* @access public
|
99 |
* @return void
|
100 |
*/
|
114 |
|
115 |
// Set up the input labels.
|
116 |
$this->json['label'] = array(
|
117 |
+
'cap' => members_show_human_caps() && members_cap_exists( $this->cap ) ? members_get_cap( $this->cap )->label : $this->cap,
|
118 |
'grant' => sprintf( esc_html__( 'Grant %s capability', 'members' ), "<code>{$this->cap}</code>" ),
|
119 |
'deny' => sprintf( esc_html__( 'Deny %s capability', 'members' ), "<code>{$this->cap}</code>" )
|
120 |
);
|
admin/class-cap-group-factory.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Singleton factory class for storying capability group objects.
|
4 |
-
*
|
5 |
-
* @package Members
|
6 |
-
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <justin@justintadlock.com>
|
8 |
-
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
|
9 |
-
* @link http://themehybrid.com/plugins/members
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Capability group factory class.
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
* @access public
|
18 |
-
*/
|
19 |
-
final class Members_Cap_Group_Factory {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Array of group objects.
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
* @access public
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
public $groups = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor method.
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
* @access private
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
private function __construct() {}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Register a new group object
|
41 |
-
*
|
42 |
-
* @see Members_Cap_Group::__construct()
|
43 |
-
* @since 1.0.0
|
44 |
-
* @access public
|
45 |
-
* @param string $name
|
46 |
-
* @param array $args
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function register_group( $name, $args = array() ) {
|
50 |
-
|
51 |
-
if ( ! $this->group_exists( $name ) ) {
|
52 |
-
|
53 |
-
$group = new Members_Cap_Group( $name, $args );
|
54 |
-
|
55 |
-
$this->groups[ $group->name ] = $group;
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Unregisters a group object.
|
61 |
-
*
|
62 |
-
* @since 1.0.0
|
63 |
-
* @access public
|
64 |
-
* @param string $name
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function unregister_group( $name ) {
|
68 |
-
|
69 |
-
if ( $this->group_exists( $name ) )
|
70 |
-
unset( $this->groups[ $name ] );
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Checks if a group exists.
|
75 |
-
*
|
76 |
-
* @since 1.0.0
|
77 |
-
* @access public
|
78 |
-
* @param string $name
|
79 |
-
* @return bool
|
80 |
-
*/
|
81 |
-
public function group_exists( $name ) {
|
82 |
-
|
83 |
-
return isset( $this->groups[ $name ] );
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Gets a group object.
|
88 |
-
*
|
89 |
-
* @since 1.0.0
|
90 |
-
* @access public
|
91 |
-
* @param string $name
|
92 |
-
* @return object|bool
|
93 |
-
*/
|
94 |
-
public function get_group( $name ) {
|
95 |
-
|
96 |
-
return $this->group_exists( $name ) ? $this->groups[ $name ] : false;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Returns the instance.
|
101 |
-
*
|
102 |
-
* @since 1.0.0
|
103 |
-
* @access public
|
104 |
-
* @return object
|
105 |
-
*/
|
106 |
-
public static function get_instance() {
|
107 |
-
|
108 |
-
static $instance = null;
|
109 |
-
|
110 |
-
if ( is_null( $instance ) )
|
111 |
-
$instance = new Members_Cap_Group_Factory;
|
112 |
-
|
113 |
-
return $instance;
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-cap-section.php
CHANGED
@@ -4,25 +4,27 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Cap section class.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Stores the cap tabs object.
|
23 |
*
|
24 |
* @see Members_Cap_Tabs
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var object
|
28 |
*/
|
@@ -31,7 +33,7 @@ final class Members_Cap_Section {
|
|
31 |
/**
|
32 |
* ID of the section.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var string
|
37 |
*/
|
@@ -40,7 +42,7 @@ final class Members_Cap_Section {
|
|
40 |
/**
|
41 |
* Dashicons icon for the section.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var string
|
46 |
*/
|
@@ -49,7 +51,7 @@ final class Members_Cap_Section {
|
|
49 |
/**
|
50 |
* Label for the section.
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
* @var string
|
55 |
*/
|
@@ -58,7 +60,7 @@ final class Members_Cap_Section {
|
|
58 |
/**
|
59 |
* Array of data to pass as a json object to the Underscore template.
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @var array
|
64 |
*/
|
@@ -67,7 +69,7 @@ final class Members_Cap_Section {
|
|
67 |
/**
|
68 |
* Creates a new section object.
|
69 |
*
|
70 |
-
* @since
|
71 |
* @access public
|
72 |
* @param object $manager
|
73 |
* @param string $section
|
@@ -89,7 +91,7 @@ final class Members_Cap_Section {
|
|
89 |
/**
|
90 |
* Returns the json array.
|
91 |
*
|
92 |
-
* @since
|
93 |
* @access public
|
94 |
* @return array
|
95 |
*/
|
@@ -101,7 +103,7 @@ final class Members_Cap_Section {
|
|
101 |
/**
|
102 |
* Adds custom data to the json array. This data is passed to the Underscore template.
|
103 |
*
|
104 |
-
* @since
|
105 |
* @access public
|
106 |
* @return void
|
107 |
*/
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
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 |
*/
|
33 |
/**
|
34 |
* ID of the section.
|
35 |
*
|
36 |
+
* @since 2.0.0
|
37 |
* @access public
|
38 |
* @var string
|
39 |
*/
|
42 |
/**
|
43 |
* Dashicons icon for the section.
|
44 |
*
|
45 |
+
* @since 2.0.0
|
46 |
* @access public
|
47 |
* @var string
|
48 |
*/
|
51 |
/**
|
52 |
* Label for the section.
|
53 |
*
|
54 |
+
* @since 2.0.0
|
55 |
* @access public
|
56 |
* @var string
|
57 |
*/
|
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 |
*/
|
69 |
/**
|
70 |
* Creates a new section object.
|
71 |
*
|
72 |
+
* @since 2.0.0
|
73 |
* @access public
|
74 |
* @param object $manager
|
75 |
* @param string $section
|
91 |
/**
|
92 |
* Returns the json array.
|
93 |
*
|
94 |
+
* @since 2.0.0
|
95 |
* @access public
|
96 |
* @return array
|
97 |
*/
|
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 |
*/
|
admin/class-cap-tabs.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Handles building the edit caps tabs.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* The role object that we're creating tabs for.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access public
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Cap_Tabs {
|
|
30 |
/**
|
31 |
* Array of caps shown by the cap tabs.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @var array
|
36 |
*/
|
@@ -40,7 +42,7 @@ final class Members_Cap_Tabs {
|
|
40 |
* The caps the role has. Note that if this is a new role (new role screen), the default
|
41 |
* new role caps will be passed in.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var array
|
46 |
*/
|
@@ -49,7 +51,7 @@ final class Members_Cap_Tabs {
|
|
49 |
/**
|
50 |
* Array of tab sections.
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
* @var array
|
55 |
*/
|
@@ -58,7 +60,7 @@ final class Members_Cap_Tabs {
|
|
58 |
/**
|
59 |
* Array of single cap controls.
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @var array
|
64 |
*/
|
@@ -67,7 +69,7 @@ final class Members_Cap_Tabs {
|
|
67 |
/**
|
68 |
* Array of section json data.
|
69 |
*
|
70 |
-
* @since
|
71 |
* @access public
|
72 |
* @var array
|
73 |
*/
|
@@ -76,7 +78,7 @@ final class Members_Cap_Tabs {
|
|
76 |
/**
|
77 |
* Array of control json data.
|
78 |
*
|
79 |
-
* @since
|
80 |
* @access public
|
81 |
* @var array
|
82 |
*/
|
@@ -85,7 +87,7 @@ final class Members_Cap_Tabs {
|
|
85 |
/**
|
86 |
* Sets up the cap tabs.
|
87 |
*
|
88 |
-
* @since
|
89 |
* @access public
|
90 |
* @param string $role
|
91 |
* @param array $has_caps
|
@@ -99,11 +101,11 @@ final class Members_Cap_Tabs {
|
|
99 |
|
100 |
// Check if we have a role.
|
101 |
if ( $role ) {
|
102 |
-
$this->role =
|
103 |
|
104 |
// If no explicit caps were passed in, use the role's caps.
|
105 |
if ( ! $has_caps )
|
106 |
-
$this->has_caps = $this->role->
|
107 |
}
|
108 |
|
109 |
// Add sections and controls.
|
@@ -118,7 +120,7 @@ final class Members_Cap_Tabs {
|
|
118 |
* Registers the sections (and each section's controls) that will be used for
|
119 |
* the tab content.
|
120 |
*
|
121 |
-
* @since
|
122 |
* @access public
|
123 |
* @return void
|
124 |
*/
|
@@ -127,8 +129,12 @@ final class Members_Cap_Tabs {
|
|
127 |
// Hook before registering.
|
128 |
do_action( 'members_pre_edit_caps_manager_register' );
|
129 |
|
|
|
|
|
|
|
|
|
130 |
// Get and loop through the available capability groups.
|
131 |
-
foreach (
|
132 |
|
133 |
$caps = $group->caps;
|
134 |
|
@@ -137,11 +143,10 @@ final class Members_Cap_Tabs {
|
|
137 |
$caps = array_diff( $group->caps, $this->added_caps );
|
138 |
|
139 |
// Add group's caps to the added caps array.
|
140 |
-
|
141 |
-
$this->added_caps = array_unique( array_merge( $this->added_caps, $caps ) );
|
142 |
|
143 |
// Create a new section.
|
144 |
-
$this->sections[] = $section = new
|
145 |
|
146 |
// Get the section json data.
|
147 |
$this->sections_json[] = $section->json();
|
@@ -149,13 +154,28 @@ final class Members_Cap_Tabs {
|
|
149 |
// Create new controls for each cap.
|
150 |
foreach ( $caps as $cap ) {
|
151 |
|
152 |
-
$this->controls[] = $control = new
|
153 |
|
154 |
// Get the control json data.
|
155 |
$this->controls_json[] = $control->json();
|
156 |
}
|
157 |
}
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
// Hook after registering.
|
160 |
do_action( 'members_edit_caps_manager_register' );
|
161 |
}
|
@@ -163,7 +183,7 @@ final class Members_Cap_Tabs {
|
|
163 |
/**
|
164 |
* Displays the cap tabs.
|
165 |
*
|
166 |
-
* @since
|
167 |
* @access public
|
168 |
* @return void
|
169 |
*/
|
@@ -171,7 +191,7 @@ final class Members_Cap_Tabs {
|
|
171 |
|
172 |
<div id="tabcapsdiv" class="postbox">
|
173 |
|
174 |
-
<
|
175 |
|
176 |
<div class="inside">
|
177 |
|
@@ -188,7 +208,7 @@ final class Members_Cap_Tabs {
|
|
188 |
/**
|
189 |
* Outputs the tab nav.
|
190 |
*
|
191 |
-
* @since
|
192 |
* @access public
|
193 |
* @return void
|
194 |
*/
|
@@ -212,7 +232,7 @@ final class Members_Cap_Tabs {
|
|
212 |
/**
|
213 |
* Passes our sections and controls data as json to the `edit-role.js` file.
|
214 |
*
|
215 |
-
* @since
|
216 |
* @access public
|
217 |
* @return void
|
218 |
*/
|
@@ -225,7 +245,7 @@ final class Members_Cap_Tabs {
|
|
225 |
/**
|
226 |
* Outputs the Underscore JS templates.
|
227 |
*
|
228 |
-
* @since
|
229 |
* @access public
|
230 |
* @return void
|
231 |
*/
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Handles building the edit caps tabs.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Cap_Tabs {
|
22 |
|
23 |
/**
|
24 |
* The role object that we're creating tabs for.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access public
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Array of caps shown by the cap tabs.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @var array
|
38 |
*/
|
42 |
* The caps the role has. Note that if this is a new role (new role screen), the default
|
43 |
* new role caps will be passed in.
|
44 |
*
|
45 |
+
* @since 2.0.0
|
46 |
* @access public
|
47 |
* @var array
|
48 |
*/
|
51 |
/**
|
52 |
* Array of tab sections.
|
53 |
*
|
54 |
+
* @since 2.0.0
|
55 |
* @access public
|
56 |
* @var array
|
57 |
*/
|
60 |
/**
|
61 |
* Array of single cap controls.
|
62 |
*
|
63 |
+
* @since 2.0.0
|
64 |
* @access public
|
65 |
* @var array
|
66 |
*/
|
69 |
/**
|
70 |
* Array of section json data.
|
71 |
*
|
72 |
+
* @since 2.0.0
|
73 |
* @access public
|
74 |
* @var array
|
75 |
*/
|
78 |
/**
|
79 |
* Array of control json data.
|
80 |
*
|
81 |
+
* @since 2.0.0
|
82 |
* @access public
|
83 |
* @var array
|
84 |
*/
|
87 |
/**
|
88 |
* Sets up the cap tabs.
|
89 |
*
|
90 |
+
* @since 2.0.0
|
91 |
* @access public
|
92 |
* @param string $role
|
93 |
* @param array $has_caps
|
101 |
|
102 |
// Check if we have a role.
|
103 |
if ( $role ) {
|
104 |
+
$this->role = members_get_role( $role );
|
105 |
|
106 |
// If no explicit caps were passed in, use the role's caps.
|
107 |
if ( ! $has_caps )
|
108 |
+
$this->has_caps = $this->role->caps;
|
109 |
}
|
110 |
|
111 |
// Add sections and controls.
|
120 |
* Registers the sections (and each section's controls) that will be used for
|
121 |
* the tab content.
|
122 |
*
|
123 |
+
* @since 2.0.0
|
124 |
* @access public
|
125 |
* @return void
|
126 |
*/
|
129 |
// Hook before registering.
|
130 |
do_action( 'members_pre_edit_caps_manager_register' );
|
131 |
|
132 |
+
$groups = members_get_cap_groups();
|
133 |
+
|
134 |
+
uasort( $groups, 'members_priority_sort' );
|
135 |
+
|
136 |
// Get and loop through the available capability groups.
|
137 |
+
foreach ( $groups as $group ) {
|
138 |
|
139 |
$caps = $group->caps;
|
140 |
|
143 |
$caps = array_diff( $group->caps, $this->added_caps );
|
144 |
|
145 |
// Add group's caps to the added caps array.
|
146 |
+
$this->added_caps = array_unique( array_merge( $this->added_caps, $caps ) );
|
|
|
147 |
|
148 |
// Create a new section.
|
149 |
+
$this->sections[] = $section = new Cap_Section( $this, $group->name, array( 'icon' => $group->icon, 'label' => $group->label ) );
|
150 |
|
151 |
// Get the section json data.
|
152 |
$this->sections_json[] = $section->json();
|
154 |
// Create new controls for each cap.
|
155 |
foreach ( $caps as $cap ) {
|
156 |
|
157 |
+
$this->controls[] = $control = new Cap_Control( $this, $cap, array( 'section' => $group->name ) );
|
158 |
|
159 |
// Get the control json data.
|
160 |
$this->controls_json[] = $control->json();
|
161 |
}
|
162 |
}
|
163 |
|
164 |
+
// Create a new "All" section.
|
165 |
+
$this->sections[] = $section = new Cap_Section( $this, 'all', array( 'icon' => 'dashicons-plus', 'label' => esc_html__( 'All', 'members' ) ) );
|
166 |
+
|
167 |
+
// Get the section json data.
|
168 |
+
$this->sections_json[] = $section->json();
|
169 |
+
|
170 |
+
// Create new controls for each cap.
|
171 |
+
foreach ( $this->added_caps as $cap ) {
|
172 |
+
|
173 |
+
$this->controls[] = $control = new Cap_Control( $this, $cap, array( 'section' => 'all' ) );
|
174 |
+
|
175 |
+
// Get the control json data.
|
176 |
+
$this->controls_json[] = $control->json();
|
177 |
+
}
|
178 |
+
|
179 |
// Hook after registering.
|
180 |
do_action( 'members_edit_caps_manager_register' );
|
181 |
}
|
183 |
/**
|
184 |
* Displays the cap tabs.
|
185 |
*
|
186 |
+
* @since 2.0.0
|
187 |
* @access public
|
188 |
* @return void
|
189 |
*/
|
191 |
|
192 |
<div id="tabcapsdiv" class="postbox">
|
193 |
|
194 |
+
<h2 class="hndle"><?php printf( esc_html__( 'Edit Capabilities: %s', 'members' ), '<span class="members-which-tab"></span>' ); ?></h2>
|
195 |
|
196 |
<div class="inside">
|
197 |
|
208 |
/**
|
209 |
* Outputs the tab nav.
|
210 |
*
|
211 |
+
* @since 2.0.0
|
212 |
* @access public
|
213 |
* @return void
|
214 |
*/
|
232 |
/**
|
233 |
* Passes our sections and controls data as json to the `edit-role.js` file.
|
234 |
*
|
235 |
+
* @since 2.0.0
|
236 |
* @access public
|
237 |
* @return void
|
238 |
*/
|
245 |
/**
|
246 |
* Outputs the Underscore JS templates.
|
247 |
*
|
248 |
+
* @since 2.0.0
|
249 |
* @access public
|
250 |
* @return void
|
251 |
*/
|
admin/class-manage-roles.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Role management class.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Admin_Manage_Roles {
|
|
30 |
/**
|
31 |
* Name of the page we've created.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @var string
|
36 |
*/
|
@@ -39,7 +41,7 @@ final class Members_Admin_Manage_Roles {
|
|
39 |
/**
|
40 |
* The page object to show.
|
41 |
*
|
42 |
-
* @since
|
43 |
* @access public
|
44 |
* @var object
|
45 |
*/
|
@@ -48,7 +50,7 @@ final class Members_Admin_Manage_Roles {
|
|
48 |
/**
|
49 |
* Sets up our initial actions.
|
50 |
*
|
51 |
-
* @since
|
52 |
* @access public
|
53 |
* @return void
|
54 |
*/
|
@@ -62,7 +64,7 @@ final class Members_Admin_Manage_Roles {
|
|
62 |
/**
|
63 |
* Adds the roles page to the admin.
|
64 |
*
|
65 |
-
* @since
|
66 |
* @access public
|
67 |
* @return void
|
68 |
*/
|
@@ -94,11 +96,11 @@ final class Members_Admin_Manage_Roles {
|
|
94 |
|
95 |
// If viewing the edit role page.
|
96 |
if ( isset( $_REQUEST['action'] ) && 'edit' === $_REQUEST['action'] && current_user_can( 'edit_roles' ) )
|
97 |
-
$this->page_obj = new
|
98 |
|
99 |
// If viewing the role list page.
|
100 |
else
|
101 |
-
$this->page_obj = new
|
102 |
|
103 |
// Load actions.
|
104 |
add_action( "load-{$this->page}", array( $this, 'load' ) );
|
@@ -111,7 +113,7 @@ final class Members_Admin_Manage_Roles {
|
|
111 |
/**
|
112 |
* Checks posted data on load and performs actions if needed.
|
113 |
*
|
114 |
-
* @since
|
115 |
* @access public
|
116 |
* @return void
|
117 |
*/
|
@@ -124,7 +126,7 @@ final class Members_Admin_Manage_Roles {
|
|
124 |
/**
|
125 |
* Loads necessary scripts/styles.
|
126 |
*
|
127 |
-
* @since
|
128 |
* @access public
|
129 |
* @param string $hook_suffix
|
130 |
* @return void
|
@@ -138,7 +140,7 @@ final class Members_Admin_Manage_Roles {
|
|
138 |
/**
|
139 |
* Outputs the page.
|
140 |
*
|
141 |
-
* @since
|
142 |
* @access public
|
143 |
* @return void
|
144 |
*/
|
@@ -151,7 +153,7 @@ final class Members_Admin_Manage_Roles {
|
|
151 |
/**
|
152 |
* Returns the instance.
|
153 |
*
|
154 |
-
* @since
|
155 |
* @access public
|
156 |
* @return object
|
157 |
*/
|
@@ -164,4 +166,4 @@ final class Members_Admin_Manage_Roles {
|
|
164 |
}
|
165 |
}
|
166 |
|
167 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Role management class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Manage_Roles {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Name of the page we've created.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @var string
|
38 |
*/
|
41 |
/**
|
42 |
* The page object to show.
|
43 |
*
|
44 |
+
* @since 2.0.0
|
45 |
* @access public
|
46 |
* @var object
|
47 |
*/
|
50 |
/**
|
51 |
* Sets up our initial actions.
|
52 |
*
|
53 |
+
* @since 2.0.0
|
54 |
* @access public
|
55 |
* @return void
|
56 |
*/
|
64 |
/**
|
65 |
* Adds the roles page to the admin.
|
66 |
*
|
67 |
+
* @since 2.0.0
|
68 |
* @access public
|
69 |
* @return void
|
70 |
*/
|
96 |
|
97 |
// If viewing the edit role page.
|
98 |
if ( isset( $_REQUEST['action'] ) && 'edit' === $_REQUEST['action'] && current_user_can( 'edit_roles' ) )
|
99 |
+
$this->page_obj = new Role_Edit();
|
100 |
|
101 |
// If viewing the role list page.
|
102 |
else
|
103 |
+
$this->page_obj = new Roles();
|
104 |
|
105 |
// Load actions.
|
106 |
add_action( "load-{$this->page}", array( $this, 'load' ) );
|
113 |
/**
|
114 |
* Checks posted data on load and performs actions if needed.
|
115 |
*
|
116 |
+
* @since 2.0.0
|
117 |
* @access public
|
118 |
* @return void
|
119 |
*/
|
126 |
/**
|
127 |
* Loads necessary scripts/styles.
|
128 |
*
|
129 |
+
* @since 2.0.0
|
130 |
* @access public
|
131 |
* @param string $hook_suffix
|
132 |
* @return void
|
140 |
/**
|
141 |
* Outputs the page.
|
142 |
*
|
143 |
+
* @since 2.0.0
|
144 |
* @access public
|
145 |
* @return void
|
146 |
*/
|
153 |
/**
|
154 |
* Returns the instance.
|
155 |
*
|
156 |
+
* @since 2.0.0
|
157 |
* @access public
|
158 |
* @return object
|
159 |
*/
|
166 |
}
|
167 |
}
|
168 |
|
169 |
+
Manage_Roles::get_instance();
|
admin/class-manage-users.php
ADDED
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles custom functionality on the manage users screen.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Manager users screen class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
final class Manage_Users {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Holds the instances of this class.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access private
|
28 |
+
* @var object
|
29 |
+
*/
|
30 |
+
private static $instance = null;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Custom admin notices.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access public
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
public $notices = array();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructore method.
|
43 |
+
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access private
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
private function __construct() {}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Sets up needed actions/filters.
|
52 |
+
*
|
53 |
+
* @since 2.0.0
|
54 |
+
* @access private
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
private function setup_actions() {
|
58 |
+
|
59 |
+
// If multiple roles per user is not enabled, bail.
|
60 |
+
if ( ! members_multiple_user_roles_enabled() )
|
61 |
+
return;
|
62 |
+
|
63 |
+
// Add our primary actions to the load hook.
|
64 |
+
add_action( 'load-users.php', array( $this, 'load' ) );
|
65 |
+
add_action( 'load-users.php', array( $this, 'role_bulk_add' ) );
|
66 |
+
add_action( 'load-users.php', array( $this, 'role_bulk_remove' ) );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Adds actions/filters on load.
|
71 |
+
*
|
72 |
+
* @since 2.0.0
|
73 |
+
* @access public
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
public function load() {
|
77 |
+
|
78 |
+
// Add custom bulk fields.
|
79 |
+
add_action( 'restrict_manage_users', array( $this, 'bulk_fields' ), 5 );
|
80 |
+
|
81 |
+
// Custom manage users columns.
|
82 |
+
add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) );
|
83 |
+
|
84 |
+
// Handle scripts and styles.
|
85 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
86 |
+
add_action( 'admin_footer', array( $this, 'print_scripts' ), 25 );
|
87 |
+
add_action( 'admin_head', array( $this, 'print_styles' ) );
|
88 |
+
|
89 |
+
// If there was an update, add notices if they're from our plugin.
|
90 |
+
if ( isset( $_GET['update'] ) ) {
|
91 |
+
|
92 |
+
$action = sanitize_key( $_GET['update'] );
|
93 |
+
|
94 |
+
// If a role was added.
|
95 |
+
if ( 'members-role-added' === $action ) {
|
96 |
+
|
97 |
+
$this->notices['role_added'] = array( 'message' => esc_html__( 'Role added to selected users.', 'members' ), 'type' => 'success' );
|
98 |
+
|
99 |
+
// If a role was removed.
|
100 |
+
} elseif ( 'members-role-removed' === $action ) {
|
101 |
+
|
102 |
+
$this->notices['role_removed'] = array( 'message' => esc_html__( 'Role removed from selected users.', 'members' ), 'type' => 'success' );
|
103 |
+
|
104 |
+
} elseif ( 'members-error-remove-admin' === $action ) {
|
105 |
+
|
106 |
+
$this->notices['error_remove_admin'] = array( 'message' => esc_html__( 'The current user’s role must have user editing capabilities.', 'members' ), 'type' => 'error' );
|
107 |
+
$this->notices['role_removed'] = array( 'message' => esc_html__( 'Role removed from other selected users.', 'members' ), 'type' => 'success' );
|
108 |
+
}
|
109 |
+
|
110 |
+
// If we have notices, hook them in.
|
111 |
+
if ( $this->notices )
|
112 |
+
add_action( 'admin_notices', array( $this, 'notices' ) );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Adds a single role to users in bulk.
|
118 |
+
*
|
119 |
+
* @since 2.0.0
|
120 |
+
* @access public
|
121 |
+
* @return void
|
122 |
+
*/
|
123 |
+
public function role_bulk_add() {
|
124 |
+
|
125 |
+
// Bail if we ain't got users.
|
126 |
+
if ( empty( $_REQUEST['users'] ) )
|
127 |
+
return;
|
128 |
+
|
129 |
+
// Figure out if we have a role selected.
|
130 |
+
if ( ! empty( $_REQUEST['members-add-role-top'] ) && ! empty( $_REQUEST['members-add-role-submit-top'] ) )
|
131 |
+
$role = members_sanitize_role( $_REQUEST['members-add-role-top'] );
|
132 |
+
|
133 |
+
elseif ( ! empty( $_REQUEST['members-add-role-bottom'] ) && ! empty( $_REQUEST['members-add-role-submit-bottom'] ) )
|
134 |
+
$role = members_sanitize_role( $_REQUEST['members-add-role-bottom'] );
|
135 |
+
|
136 |
+
// Get only editable roles.
|
137 |
+
$editable_roles = members_get_editable_roles();
|
138 |
+
|
139 |
+
// If we don't have a role or the role is not editable, bail.
|
140 |
+
if ( empty( $role ) || ! in_array( $role, $editable_roles ) )
|
141 |
+
return;
|
142 |
+
|
143 |
+
// Validate our nonce.
|
144 |
+
check_admin_referer( 'members-bulk-users', 'members-bulk-users-nonce' );
|
145 |
+
|
146 |
+
// If the current user cannot promote users, bail.
|
147 |
+
if ( ! current_user_can( 'promote_users' ) )
|
148 |
+
return;
|
149 |
+
|
150 |
+
// Loop through the users and add the role if possible.
|
151 |
+
foreach ( (array) $_REQUEST['users'] as $user_id ) {
|
152 |
+
|
153 |
+
$user_id = absint( $user_id );
|
154 |
+
|
155 |
+
// If the user doesn't already belong to the blog, bail.
|
156 |
+
if ( is_multisite() && ! is_user_member_of_blog( $user_id ) ) {
|
157 |
+
|
158 |
+
wp_die(
|
159 |
+
sprintf(
|
160 |
+
'<h1>%s</h1> <p>%s</p>',
|
161 |
+
esc_html__( 'Whoah, partner!', 'members' ),
|
162 |
+
esc_html__( 'One of the selected users is not a member of this site.', 'members' )
|
163 |
+
),
|
164 |
+
403
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
// Check that the current user can promote this specific user.
|
169 |
+
if ( ! current_user_can( 'promote_user', $user_id ) )
|
170 |
+
continue;
|
171 |
+
|
172 |
+
// Get the user object.
|
173 |
+
$user = new \WP_User( $user_id );
|
174 |
+
|
175 |
+
// If the user doesn't have the role, add it.
|
176 |
+
if ( ! in_array( $role, $user->roles ) )
|
177 |
+
$user->add_role( $role );
|
178 |
+
}
|
179 |
+
|
180 |
+
// Redirect to the users screen.
|
181 |
+
wp_redirect( add_query_arg( 'update', 'members-role-added', 'users.php' ) );
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Removes a single role from users in bulk.
|
186 |
+
*
|
187 |
+
* @since 2.0.0
|
188 |
+
* @access public
|
189 |
+
* @return void
|
190 |
+
*/
|
191 |
+
public function role_bulk_remove() {
|
192 |
+
|
193 |
+
// Bail if we ain't got users.
|
194 |
+
if ( empty( $_REQUEST['users'] ) )
|
195 |
+
return;
|
196 |
+
|
197 |
+
// Figure out if we have a role selected.
|
198 |
+
if ( ! empty( $_REQUEST['members-remove-role-top'] ) && ! empty( $_REQUEST['members-remove-role-submit-top'] ) )
|
199 |
+
$role = members_sanitize_role( $_REQUEST['members-remove-role-top'] );
|
200 |
+
|
201 |
+
elseif ( ! empty( $_REQUEST['members-remove-role-bottom'] ) && ! empty( $_REQUEST['members-remove-role-submit-bottom'] ) )
|
202 |
+
$role = members_sanitize_role( $_REQUEST['members-remove-role-bottom'] );
|
203 |
+
|
204 |
+
// Get only editable roles.
|
205 |
+
$editable_roles = members_get_editable_roles();
|
206 |
+
|
207 |
+
// If we don't have a role or the role is not editable, bail.
|
208 |
+
if ( empty( $role ) || ! in_array( $role, $editable_roles ) )
|
209 |
+
return;
|
210 |
+
|
211 |
+
// Validate our nonce.
|
212 |
+
check_admin_referer( 'members-bulk-users', 'members-bulk-users-nonce' );
|
213 |
+
|
214 |
+
// If the current user cannot promote users, bail.
|
215 |
+
if ( ! current_user_can( 'promote_users' ) )
|
216 |
+
return;
|
217 |
+
|
218 |
+
// Get the current user.
|
219 |
+
$current_user = wp_get_current_user();
|
220 |
+
|
221 |
+
$m_role = members_get_role( $role );
|
222 |
+
|
223 |
+
$update = 'members-role-removed';
|
224 |
+
|
225 |
+
// Loop through the users and remove the role if possible.
|
226 |
+
foreach ( (array) $_REQUEST['users'] as $user_id ) {
|
227 |
+
|
228 |
+
$user_id = absint( $user_id );
|
229 |
+
|
230 |
+
// If the user doesn't already belong to the blog, bail.
|
231 |
+
if ( is_multisite() && ! is_user_member_of_blog( $user_id ) ) {
|
232 |
+
|
233 |
+
wp_die(
|
234 |
+
sprintf(
|
235 |
+
'<h1>%s</h1> <p>%s</p>',
|
236 |
+
esc_html__( 'Whoah, partner!', 'members' ),
|
237 |
+
esc_html__( 'One of the selected users is not a member of this site.', 'members' )
|
238 |
+
),
|
239 |
+
403
|
240 |
+
);
|
241 |
+
}
|
242 |
+
|
243 |
+
// Check that the current user can promote this specific user.
|
244 |
+
if ( ! current_user_can( 'promote_user', $user_id ) )
|
245 |
+
continue;
|
246 |
+
|
247 |
+
$is_current_user = $user_id == $current_user->ID;
|
248 |
+
$role_can_promote = in_array( 'promote_users', $m_role->granted_caps );
|
249 |
+
$can_manage_network = is_multisite() && current_user_can( 'manage_network_users' );
|
250 |
+
|
251 |
+
// If the removed role has the `promote_users` cap and user is removing it from themselves.
|
252 |
+
if ( $is_current_user && $role_can_promote && ! $can_manage_network ) {
|
253 |
+
|
254 |
+
$can_remove = false;
|
255 |
+
|
256 |
+
// Loop through the current user's roles.
|
257 |
+
foreach ( $current_user->roles as $_r ) {
|
258 |
+
|
259 |
+
// If the current user has another role that can promote users, it's
|
260 |
+
// safe to remove the role. Else, the current user needs to keep
|
261 |
+
// the role.
|
262 |
+
if ( $role !== $_r && in_array( 'promote_users', members_get_role( $_r )->granted_caps ) ) {
|
263 |
+
|
264 |
+
$can_remove = true;
|
265 |
+
break;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
if ( ! $can_remove ) {
|
270 |
+
$update = 'members-error-remove-admin';
|
271 |
+
continue;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
// Get the user object.
|
276 |
+
$user = new \WP_User( $user_id );
|
277 |
+
|
278 |
+
// If the user has the role, remove it.
|
279 |
+
if ( in_array( $role, $user->roles ) )
|
280 |
+
$user->remove_role( $role );
|
281 |
+
}
|
282 |
+
|
283 |
+
// Redirect to the users screen.
|
284 |
+
wp_redirect( add_query_arg( 'update', $update, 'users.php' ) );
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Print admin notices.
|
289 |
+
*
|
290 |
+
* @since 2.0.0
|
291 |
+
* @access public
|
292 |
+
* @param string $which
|
293 |
+
* @return void
|
294 |
+
*/
|
295 |
+
public function notices() {
|
296 |
+
|
297 |
+
if ( $this->notices ) : ?>
|
298 |
+
|
299 |
+
<?php foreach ( $this->notices as $notice ) : ?>
|
300 |
+
|
301 |
+
<div class="notice notice-<?php echo esc_attr( $notice['type'] ); ?> is-dismissible">
|
302 |
+
<?php echo wpautop( '<strong>' . $notice['message'] . '</strong>' ); ?>
|
303 |
+
</div>
|
304 |
+
|
305 |
+
<?php endforeach;
|
306 |
+
|
307 |
+
endif;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Outputs "add role" and "remove role" dropdown select fields.
|
312 |
+
*
|
313 |
+
* @since 2.0.0
|
314 |
+
* @access public
|
315 |
+
* @param string $which
|
316 |
+
* @return void
|
317 |
+
*/
|
318 |
+
public function bulk_fields( $which ) {
|
319 |
+
|
320 |
+
if ( ! current_user_can( 'promote_users' ) )
|
321 |
+
return;
|
322 |
+
|
323 |
+
wp_nonce_field( 'members-bulk-users', 'members-bulk-users-nonce' ); ?>
|
324 |
+
|
325 |
+
<label class="screen-reader-text" for="<?php echo esc_attr( "members-add-role-{$which}" ); ?>">
|
326 |
+
<?php esc_html_e( 'Add role…', 'members' ); ?>
|
327 |
+
</label>
|
328 |
+
|
329 |
+
<select name="<?php echo esc_attr( "members-add-role-{$which}" ); ?>" id="<?php echo esc_attr( "members-add-role-{$which}" ); ?>" style="display: inline-block; float: none;">
|
330 |
+
<option value=""><?php esc_html_e( 'Add role…', 'members' ); ?></option>
|
331 |
+
<?php wp_dropdown_roles(); ?>
|
332 |
+
</select>
|
333 |
+
|
334 |
+
<?php submit_button( esc_html__( 'Add', 'members' ), 'secondary', esc_attr( "members-add-role-submit-{$which}" ), false ); ?>
|
335 |
+
|
336 |
+
<label class="screen-reader-text" for="<?php echo esc_attr( "members-remove-role-{$which}" ); ?>">
|
337 |
+
<?php esc_html_e( 'Remove role…', 'members' ); ?>
|
338 |
+
</label>
|
339 |
+
|
340 |
+
<select name="<?php echo esc_attr( "members-remove-role-{$which}" ); ?>" id="<?php echo esc_attr( "members-remove-role-{$which}" ); ?>" style="display: inline-block; float: none;">
|
341 |
+
<option value=""><?php esc_html_e( 'Remove role…', 'members' ); ?></option>
|
342 |
+
<?php wp_dropdown_roles(); ?>
|
343 |
+
</select>
|
344 |
+
|
345 |
+
<?php submit_button( esc_html__( 'Remove', 'members' ), 'secondary', esc_attr( "members-remove-role-submit-{$which}" ), false );
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Handles table column headers.
|
350 |
+
*
|
351 |
+
* @since 2.0.0
|
352 |
+
* @access public
|
353 |
+
* @param array $columns
|
354 |
+
* @return array
|
355 |
+
*/
|
356 |
+
public function manage_users_columns( $columns ) {
|
357 |
+
|
358 |
+
// Make sure role column is named correctly.
|
359 |
+
if ( isset( $columns['role'] ) )
|
360 |
+
$columns['role'] = esc_html__( 'Roles', 'members' );
|
361 |
+
|
362 |
+
return $columns;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Handles the output of the roles column on the `users.php` screen.
|
367 |
+
*
|
368 |
+
* @since 2.0.0
|
369 |
+
* @access public
|
370 |
+
* @param string $output
|
371 |
+
* @param string $column
|
372 |
+
* @param int $user_id
|
373 |
+
* @return string
|
374 |
+
*/
|
375 |
+
public function manage_users_custom_column( $output, $column, $user_id ) {
|
376 |
+
|
377 |
+
if ( 'roles' === $column ) {
|
378 |
+
|
379 |
+
$user = new \WP_User( $user_id );
|
380 |
+
|
381 |
+
$user_roles = array();
|
382 |
+
$output = esc_html__( 'None', 'members' );
|
383 |
+
|
384 |
+
if ( is_array( $user->roles ) ) {
|
385 |
+
|
386 |
+
foreach ( $user->roles as $role ) {
|
387 |
+
|
388 |
+
if ( members_role_exists( $role ) )
|
389 |
+
$user_roles[] = members_translate_role( $role );
|
390 |
+
}
|
391 |
+
|
392 |
+
$output = join( ', ', $user_roles );
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
return $output;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Enqueue scripts.
|
401 |
+
*
|
402 |
+
* @since 2.0.0
|
403 |
+
* @access public
|
404 |
+
* @return void
|
405 |
+
*/
|
406 |
+
public function enqueue() {
|
407 |
+
|
408 |
+
wp_enqueue_script( 'jquery' );
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Enqueue the plugin admin CSS.
|
413 |
+
*
|
414 |
+
* @since 2.0.0
|
415 |
+
* @access public
|
416 |
+
* @return void
|
417 |
+
*/
|
418 |
+
public function print_scripts() { ?>
|
419 |
+
|
420 |
+
<script>
|
421 |
+
jQuery( document ).ready( function() {
|
422 |
+
|
423 |
+
jQuery(
|
424 |
+
'label[for="new_role"], label[for="new_role2"], #new_role, #new_role2, #changeit, #changeit2'
|
425 |
+
).remove();
|
426 |
+
} );
|
427 |
+
</script>
|
428 |
+
|
429 |
+
<?php }
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Hides the core WP change role form fields because these are hardcoded in.
|
433 |
+
*
|
434 |
+
* @since 2.0.0
|
435 |
+
* @access public
|
436 |
+
* @return void
|
437 |
+
*/
|
438 |
+
public function print_styles() { ?>
|
439 |
+
|
440 |
+
<style type="text/css">
|
441 |
+
label[for="new_role"], #new_role, #changeit,
|
442 |
+
label[for="new_role2"], #new_role2, #changeit2 { display: none !important; }
|
443 |
+
</style>
|
444 |
+
|
445 |
+
<?php }
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Returns the instance.
|
449 |
+
*
|
450 |
+
* @since 2.0.0
|
451 |
+
* @access public
|
452 |
+
* @return object
|
453 |
+
*/
|
454 |
+
public static function get_instance() {
|
455 |
+
|
456 |
+
if ( is_null( self::$instance ) ) {
|
457 |
+
self::$instance = new self;
|
458 |
+
|
459 |
+
self::$instance->setup_actions();
|
460 |
+
}
|
461 |
+
|
462 |
+
return self::$instance;
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
Manage_Users::get_instance();
|
admin/class-meta-box-content-permissions.php
CHANGED
@@ -4,33 +4,46 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class to handle the content permissios meta box and saving the meta.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
28 |
private static $instance;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Sets up the appropriate actions.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access protected
|
35 |
* @return void
|
36 |
*/
|
@@ -48,12 +61,19 @@ final class Members_Meta_Box_Content_Permissions {
|
|
48 |
* Fires on the page load hook to add actions specifically for the post and
|
49 |
* new post screens.
|
50 |
*
|
51 |
-
* @since
|
52 |
* @access public
|
53 |
* @return void
|
54 |
*/
|
55 |
public function load() {
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
// Enqueue scripts/styles.
|
58 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
59 |
|
@@ -67,19 +87,20 @@ final class Members_Meta_Box_Content_Permissions {
|
|
67 |
/**
|
68 |
* Enqueues scripts styles.
|
69 |
*
|
70 |
-
* @since
|
71 |
* @access public
|
72 |
* @return void
|
73 |
*/
|
74 |
public function enqueue() {
|
75 |
|
|
|
76 |
wp_enqueue_style( 'members-admin' );
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
* Adds the meta box.
|
81 |
*
|
82 |
-
* @since
|
83 |
* @access public
|
84 |
* @param string $post_type
|
85 |
* @return void
|
@@ -90,19 +111,32 @@ final class Members_Meta_Box_Content_Permissions {
|
|
90 |
if ( ! current_user_can( 'restrict_content' ) )
|
91 |
return;
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
// Get the post type object.
|
94 |
-
$type = get_post_type_object(
|
95 |
|
96 |
-
//
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
* Outputs the meta box HTML.
|
104 |
*
|
105 |
-
* @since
|
106 |
* @access public
|
107 |
* @param object $post
|
108 |
* @global object $wp_roles
|
@@ -118,6 +152,9 @@ final class Members_Meta_Box_Content_Permissions {
|
|
118 |
// Get the roles saved for the post.
|
119 |
$roles = get_post_meta( $post->ID, '_members_access_role', false );
|
120 |
|
|
|
|
|
|
|
121 |
// Convert old post meta to the new system if no roles were found.
|
122 |
if ( empty( $roles ) )
|
123 |
$roles = members_convert_old_post_meta( $post->ID );
|
@@ -128,35 +165,69 @@ final class Members_Meta_Box_Content_Permissions {
|
|
128 |
// Hook for firing at the top of the meta box.
|
129 |
do_action( 'members_cp_meta_box_before', $post ); ?>
|
130 |
|
131 |
-
<
|
132 |
-
<?php esc_html_e( "Limit access to this post's content to users of the selected roles.", 'members' ); ?>
|
133 |
-
</p>
|
134 |
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
<
|
138 |
|
139 |
-
|
140 |
-
<li>
|
141 |
-
<label>
|
142 |
-
<input type="checkbox" name="members_access_role[]" <?php checked( is_array( $roles ) && in_array( $role, $roles ) ); ?> value="<?php echo esc_attr( $role ); ?>" />
|
143 |
-
<?php echo esc_html( translate_user_role( $name ) ); ?>
|
144 |
-
</label>
|
145 |
-
</li>
|
146 |
-
<?php endforeach; ?>
|
147 |
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
// Hook that fires at the end of the meta box.
|
162 |
do_action( 'members_cp_meta_box_after', $post );
|
@@ -165,7 +236,7 @@ final class Members_Meta_Box_Content_Permissions {
|
|
165 |
/**
|
166 |
* Saves the post meta.
|
167 |
*
|
168 |
-
* @since
|
169 |
* @access public
|
170 |
* @param int $post_id
|
171 |
* @param object $post
|
@@ -173,6 +244,13 @@ final class Members_Meta_Box_Content_Permissions {
|
|
173 |
*/
|
174 |
public function update( $post_id, $post = '' ) {
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
// Fix for attachment save issue in WordPress 3.5.
|
177 |
// @link http://core.trac.wordpress.org/ticket/21963
|
178 |
if ( ! is_object( $post ) )
|
@@ -204,7 +282,7 @@ final class Members_Meta_Box_Content_Permissions {
|
|
204 |
$old_message = members_get_post_access_message( $post_id );
|
205 |
|
206 |
// Get the new message.
|
207 |
-
$new_message = isset( $_POST['members_access_error'] ) ?
|
208 |
|
209 |
// If we have don't have a new message but do have an old one, delete it.
|
210 |
if ( '' == $new_message && $old_message )
|
@@ -218,7 +296,7 @@ final class Members_Meta_Box_Content_Permissions {
|
|
218 |
/**
|
219 |
* Returns the instance.
|
220 |
*
|
221 |
-
* @since
|
222 |
* @access public
|
223 |
* @return object
|
224 |
*/
|
@@ -231,4 +309,4 @@ final class Members_Meta_Box_Content_Permissions {
|
|
231 |
}
|
232 |
}
|
233 |
|
234 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class to handle the content permissios meta box and saving the meta.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Meta_Box_Content_Permissions {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
30 |
private static $instance;
|
31 |
|
32 |
+
/**
|
33 |
+
* Whether this is a new post. Once the post is saved and we're
|
34 |
+
* no longer on the `post-new.php` screen, this is going to be
|
35 |
+
* `false`.
|
36 |
+
*
|
37 |
+
* @since 2.0.0
|
38 |
+
* @access public
|
39 |
+
* @var bool
|
40 |
+
*/
|
41 |
+
public $is_new_post = false;
|
42 |
+
|
43 |
/**
|
44 |
* Sets up the appropriate actions.
|
45 |
*
|
46 |
+
* @since 2.0.0
|
47 |
* @access protected
|
48 |
* @return void
|
49 |
*/
|
61 |
* Fires on the page load hook to add actions specifically for the post and
|
62 |
* new post screens.
|
63 |
*
|
64 |
+
* @since 2.0.0
|
65 |
* @access public
|
66 |
* @return void
|
67 |
*/
|
68 |
public function load() {
|
69 |
|
70 |
+
// Make sure meta box is allowed for this post type.
|
71 |
+
if ( ! $this->maybe_enable() )
|
72 |
+
return;
|
73 |
+
|
74 |
+
// Is this a new post?
|
75 |
+
$this->is_new_post = 'load-post-new.php' === current_action();
|
76 |
+
|
77 |
// Enqueue scripts/styles.
|
78 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
79 |
|
87 |
/**
|
88 |
* Enqueues scripts styles.
|
89 |
*
|
90 |
+
* @since 2.0.0
|
91 |
* @access public
|
92 |
* @return void
|
93 |
*/
|
94 |
public function enqueue() {
|
95 |
|
96 |
+
wp_enqueue_script( 'members-edit-post' );
|
97 |
wp_enqueue_style( 'members-admin' );
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
* Adds the meta box.
|
102 |
*
|
103 |
+
* @since 2.0.0
|
104 |
* @access public
|
105 |
* @param string $post_type
|
106 |
* @return void
|
111 |
if ( ! current_user_can( 'restrict_content' ) )
|
112 |
return;
|
113 |
|
114 |
+
// Add the meta box.
|
115 |
+
add_meta_box( 'members-cp', esc_html__( 'Content Permissions', 'members' ), array( $this, 'meta_box' ), $post_type, 'advanced', 'high' );
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Checks if Content Permissions should appear for the given post type.
|
120 |
+
*
|
121 |
+
* @since 2.0.0
|
122 |
+
* @access public
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
public function maybe_enable() {
|
126 |
+
|
127 |
// Get the post type object.
|
128 |
+
$type = get_post_type_object( get_current_screen()->post_type );
|
129 |
|
130 |
+
// Only enable for public post types and non-attachments by default.
|
131 |
+
$enable = 'attachment' !== $type->name && $type->public;
|
132 |
+
|
133 |
+
return apply_filters( "members_enable_{$type->name}_content_permissions", $enable );
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
* Outputs the meta box HTML.
|
138 |
*
|
139 |
+
* @since 2.0.0
|
140 |
* @access public
|
141 |
* @param object $post
|
142 |
* @global object $wp_roles
|
152 |
// Get the roles saved for the post.
|
153 |
$roles = get_post_meta( $post->ID, '_members_access_role', false );
|
154 |
|
155 |
+
if ( ! $roles && $this->is_new_post )
|
156 |
+
$roles = apply_filters( 'members_default_post_roles', array(), $post->ID );
|
157 |
+
|
158 |
// Convert old post meta to the new system if no roles were found.
|
159 |
if ( empty( $roles ) )
|
160 |
$roles = members_convert_old_post_meta( $post->ID );
|
165 |
// Hook for firing at the top of the meta box.
|
166 |
do_action( 'members_cp_meta_box_before', $post ); ?>
|
167 |
|
168 |
+
<div class="members-tabs members-cp-tabs">
|
|
|
|
|
169 |
|
170 |
+
<ul class="members-tab-nav">
|
171 |
+
<li class="members-tab-title">
|
172 |
+
<a href="#members-tab-cp-roles">
|
173 |
+
<i class="dashicons dashicons-groups"></i>
|
174 |
+
<span class="label"><?php esc_html_e( 'Roles', 'members' ); ?></span>
|
175 |
+
</a>
|
176 |
+
</li>
|
177 |
+
<li class="members-tab-title">
|
178 |
+
<a href="#members-tab-cp-message">
|
179 |
+
<i class="dashicons dashicons-edit"></i>
|
180 |
+
<span class="label"><?php esc_html_e( 'Error Message', 'members' ); ?></span>
|
181 |
+
</a>
|
182 |
+
</li>
|
183 |
+
</ul>
|
184 |
|
185 |
+
<div class="members-tab-wrap">
|
186 |
|
187 |
+
<div id="members-tab-cp-roles" class="members-tab-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
+
<span class="members-tabs-label">
|
190 |
+
<?php esc_html_e( 'Limit access to the content to users of the selected roles.', 'members' ); ?>
|
191 |
+
</span>
|
192 |
+
|
193 |
+
<div class="members-cp-role-list-wrap">
|
194 |
+
|
195 |
+
<ul class="members-cp-role-list">
|
196 |
+
|
197 |
+
<?php foreach ( $_wp_roles as $role => $name ) : ?>
|
198 |
+
<li>
|
199 |
+
<label>
|
200 |
+
<input type="checkbox" name="members_access_role[]" <?php checked( is_array( $roles ) && in_array( $role, $roles ) ); ?> value="<?php echo esc_attr( $role ); ?>" />
|
201 |
+
<?php echo esc_html( translate_user_role( $name ) ); ?>
|
202 |
+
</label>
|
203 |
+
</li>
|
204 |
+
<?php endforeach; ?>
|
205 |
+
|
206 |
+
</ul>
|
207 |
+
</div>
|
208 |
|
209 |
+
<span class="members-tabs-description">
|
210 |
+
<?php printf( esc_html__( 'If no roles are selected, everyone can view the content. The author, any users who can edit the content, and users with the %s capability can view the content regardless of role.', 'members' ), '<code>restrict_content</code>' ); ?>
|
211 |
+
</span>
|
212 |
|
213 |
+
</div>
|
214 |
+
|
215 |
+
<div id="members-tab-cp-message" class="members-tab-content">
|
216 |
+
|
217 |
+
<?php wp_editor(
|
218 |
+
get_post_meta( $post->ID, '_members_access_error', true ),
|
219 |
+
'members_access_error',
|
220 |
+
array(
|
221 |
+
'drag_drop_upload' => true,
|
222 |
+
'editor_height' => 200
|
223 |
+
)
|
224 |
+
); ?>
|
225 |
+
|
226 |
+
</div>
|
227 |
+
|
228 |
+
</div><!-- .members-tab-wrap -->
|
229 |
+
|
230 |
+
</div><!-- .members-tabs --><?php
|
231 |
|
232 |
// Hook that fires at the end of the meta box.
|
233 |
do_action( 'members_cp_meta_box_after', $post );
|
236 |
/**
|
237 |
* Saves the post meta.
|
238 |
*
|
239 |
+
* @since 2.0.0
|
240 |
* @access public
|
241 |
* @param int $post_id
|
242 |
* @param object $post
|
244 |
*/
|
245 |
public function update( $post_id, $post = '' ) {
|
246 |
|
247 |
+
$do_autosave = defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE;
|
248 |
+
$is_autosave = wp_is_post_autosave( $post_id );
|
249 |
+
$is_revision = wp_is_post_revision( $post_id );
|
250 |
+
|
251 |
+
if ( $do_autosave || $is_autosave || $is_revision )
|
252 |
+
return;
|
253 |
+
|
254 |
// Fix for attachment save issue in WordPress 3.5.
|
255 |
// @link http://core.trac.wordpress.org/ticket/21963
|
256 |
if ( ! is_object( $post ) )
|
282 |
$old_message = members_get_post_access_message( $post_id );
|
283 |
|
284 |
// Get the new message.
|
285 |
+
$new_message = isset( $_POST['members_access_error'] ) ? wp_kses_post( wp_unslash( $_POST['members_access_error'] ) ) : '';
|
286 |
|
287 |
// If we have don't have a new message but do have an old one, delete it.
|
288 |
if ( '' == $new_message && $old_message )
|
296 |
/**
|
297 |
* Returns the instance.
|
298 |
*
|
299 |
+
* @since 2.0.0
|
300 |
* @access public
|
301 |
* @return object
|
302 |
*/
|
309 |
}
|
310 |
}
|
311 |
|
312 |
+
Meta_Box_Content_Permissions::get_instance();
|
admin/class-meta-box-custom-cap.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class to handle the new cap meta box on the edit/new role screen.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Meta_Box_Custom_Cap {
|
|
30 |
/**
|
31 |
* Adds our methods to the proper hooks.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
@@ -43,7 +45,7 @@ final class Members_Meta_Box_Custom_Cap {
|
|
43 |
/**
|
44 |
* Runs on the page load hook to hook in the meta boxes.
|
45 |
*
|
46 |
-
* @since
|
47 |
* @access public
|
48 |
* @return void
|
49 |
*/
|
@@ -55,7 +57,7 @@ final class Members_Meta_Box_Custom_Cap {
|
|
55 |
/**
|
56 |
* Adds the meta box.
|
57 |
*
|
58 |
-
* @since
|
59 |
* @access public
|
60 |
* @param string $screen_id
|
61 |
* @param string $role
|
@@ -74,7 +76,7 @@ final class Members_Meta_Box_Custom_Cap {
|
|
74 |
/**
|
75 |
* Outputs the meta box HTML.
|
76 |
*
|
77 |
-
* @since
|
78 |
* @access public
|
79 |
* @return void
|
80 |
*/
|
@@ -85,14 +87,14 @@ final class Members_Meta_Box_Custom_Cap {
|
|
85 |
</p>
|
86 |
|
87 |
<p>
|
88 |
-
<button type="button" class="button-secondary" id="members-add-new-cap"><?php
|
89 |
</p>
|
90 |
<?php }
|
91 |
|
92 |
/**
|
93 |
* Returns the instance.
|
94 |
*
|
95 |
-
* @since
|
96 |
* @access public
|
97 |
* @return object
|
98 |
*/
|
@@ -105,4 +107,4 @@ final class Members_Meta_Box_Custom_Cap {
|
|
105 |
}
|
106 |
}
|
107 |
|
108 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class to handle the new cap meta box on the edit/new role screen.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Meta_Box_Custom_Cap {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Adds our methods to the proper hooks.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @return void
|
38 |
*/
|
45 |
/**
|
46 |
* Runs on the page load hook to hook in the meta boxes.
|
47 |
*
|
48 |
+
* @since 2.0.0
|
49 |
* @access public
|
50 |
* @return void
|
51 |
*/
|
57 |
/**
|
58 |
* Adds the meta box.
|
59 |
*
|
60 |
+
* @since 2.0.0
|
61 |
* @access public
|
62 |
* @param string $screen_id
|
63 |
* @param string $role
|
76 |
/**
|
77 |
* Outputs the meta box HTML.
|
78 |
*
|
79 |
+
* @since 2.0.0
|
80 |
* @access public
|
81 |
* @return void
|
82 |
*/
|
87 |
</p>
|
88 |
|
89 |
<p>
|
90 |
+
<button type="button" class="button-secondary" id="members-add-new-cap"><?php echo esc_html_x( 'Add New', 'capability', 'members' ); ?></button>
|
91 |
</p>
|
92 |
<?php }
|
93 |
|
94 |
/**
|
95 |
* Returns the instance.
|
96 |
*
|
97 |
+
* @since 2.0.0
|
98 |
* @access public
|
99 |
* @return object
|
100 |
*/
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
Meta_Box_Custom_Cap::get_instance();
|
admin/class-meta-box-publish-role.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class to handle the role meta box edit/new role screen.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Meta_Box_Publish_Role {
|
|
30 |
/**
|
31 |
* Adds our methods to the proper hooks.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
@@ -43,7 +45,7 @@ final class Members_Meta_Box_Publish_Role {
|
|
43 |
/**
|
44 |
* Runs on the page load hook to hook in the meta boxes.
|
45 |
*
|
46 |
-
* @since
|
47 |
* @access public
|
48 |
* @return void
|
49 |
*/
|
@@ -55,7 +57,7 @@ final class Members_Meta_Box_Publish_Role {
|
|
55 |
/**
|
56 |
* Adds the meta box.
|
57 |
*
|
58 |
-
* @since
|
59 |
* @access public
|
60 |
* @param string $screen_id
|
61 |
* @return void
|
@@ -68,7 +70,7 @@ final class Members_Meta_Box_Publish_Role {
|
|
68 |
/**
|
69 |
* Outputs the meta box HTML.
|
70 |
*
|
71 |
-
* @since
|
72 |
* @access public
|
73 |
* @param object $role
|
74 |
* @return void
|
@@ -140,7 +142,7 @@ final class Members_Meta_Box_Publish_Role {
|
|
140 |
/**
|
141 |
* Returns the instance.
|
142 |
*
|
143 |
-
* @since
|
144 |
* @access public
|
145 |
* @return object
|
146 |
*/
|
@@ -153,4 +155,4 @@ final class Members_Meta_Box_Publish_Role {
|
|
153 |
}
|
154 |
}
|
155 |
|
156 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class to handle the role meta box edit/new role screen.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Meta_Box_Publish_Role {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Adds our methods to the proper hooks.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @return void
|
38 |
*/
|
45 |
/**
|
46 |
* Runs on the page load hook to hook in the meta boxes.
|
47 |
*
|
48 |
+
* @since 2.0.0
|
49 |
* @access public
|
50 |
* @return void
|
51 |
*/
|
57 |
/**
|
58 |
* Adds the meta box.
|
59 |
*
|
60 |
+
* @since 2.0.0
|
61 |
* @access public
|
62 |
* @param string $screen_id
|
63 |
* @return void
|
70 |
/**
|
71 |
* Outputs the meta box HTML.
|
72 |
*
|
73 |
+
* @since 2.0.0
|
74 |
* @access public
|
75 |
* @param object $role
|
76 |
* @return void
|
142 |
/**
|
143 |
* Returns the instance.
|
144 |
*
|
145 |
+
* @since 2.0.0
|
146 |
* @access public
|
147 |
* @return object
|
148 |
*/
|
155 |
}
|
156 |
}
|
157 |
|
158 |
+
Meta_Box_Publish_Role::get_instance();
|
admin/class-role-edit.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class that displays the edit role screen and handles the form submissions for that page.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Current role object to be edited/viewed.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access protected
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Admin_Role_Edit {
|
|
30 |
/**
|
31 |
* Current Members role object to be edited/viewed.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access protected
|
35 |
* @var object
|
36 |
*/
|
@@ -39,7 +41,7 @@ final class Members_Admin_Role_Edit {
|
|
39 |
/**
|
40 |
* Whether the current role can be edited.
|
41 |
*
|
42 |
-
* @since
|
43 |
* @access protected
|
44 |
* @var bool
|
45 |
*/
|
@@ -48,7 +50,7 @@ final class Members_Admin_Role_Edit {
|
|
48 |
/**
|
49 |
* Available capabilities.
|
50 |
*
|
51 |
-
* @since
|
52 |
* @access protected
|
53 |
* @var array
|
54 |
*/
|
@@ -57,7 +59,7 @@ final class Members_Admin_Role_Edit {
|
|
57 |
/**
|
58 |
* Whether the page was updated.
|
59 |
*
|
60 |
-
* @since
|
61 |
* @access protected
|
62 |
* @var bool
|
63 |
*/
|
@@ -66,7 +68,7 @@ final class Members_Admin_Role_Edit {
|
|
66 |
/**
|
67 |
* Sets up some necessary actions/filters.
|
68 |
*
|
69 |
-
* @since
|
70 |
* @access public
|
71 |
* @return void
|
72 |
*/
|
@@ -79,7 +81,7 @@ final class Members_Admin_Role_Edit {
|
|
79 |
/**
|
80 |
* Runs on the `load-{$page}` hook. This is the handler for form submissions.
|
81 |
*
|
82 |
-
* @since
|
83 |
* @access public
|
84 |
* @return void
|
85 |
*/
|
@@ -166,7 +168,7 @@ final class Members_Admin_Role_Edit {
|
|
166 |
$_cap = members_sanitize_cap( $grant_new_cap );
|
167 |
|
168 |
// If not an existing cap, add it.
|
169 |
-
if ( ! in_array( $_cap, $this->capabilities ) ) {
|
170 |
$this->role->add_cap( $_cap );
|
171 |
|
172 |
$push_caps[] = $_cap;
|
@@ -179,7 +181,7 @@ final class Members_Admin_Role_Edit {
|
|
179 |
$_cap = members_sanitize_cap( $deny_new_cap );
|
180 |
|
181 |
// If not a granted cap and not an existing cap, add it.
|
182 |
-
if ( ! in_array( $_cap, $this->capabilities ) && ! in_array( $_cap, $grant_new_caps ) ) {
|
183 |
$this->role->add_cap( $_cap, false );
|
184 |
|
185 |
$push_caps[] = $_cap;
|
@@ -200,8 +202,16 @@ final class Members_Admin_Role_Edit {
|
|
200 |
}
|
201 |
}
|
202 |
|
203 |
-
// Add the updated role to the role
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
// Reset the Members role object.
|
207 |
$this->members_role = members_get_role( $this->role->name );
|
@@ -213,15 +223,19 @@ final class Members_Admin_Role_Edit {
|
|
213 |
|
214 |
// If successful update.
|
215 |
if ( $this->role_updated )
|
216 |
-
add_settings_error( 'members_edit_role', 'role_updated', sprintf( esc_html__( '%s role updated.', 'members' ),
|
217 |
|
218 |
// If the role is not editable.
|
219 |
if ( ! $this->is_editable )
|
220 |
-
add_settings_error( 'members_edit_role', 'role_uneditable', sprintf( esc_html__( 'The %s role is not editable. This means that it is most likely added via another plugin for a special use or that you do not have permission to edit it.', 'members' ),
|
|
|
|
|
|
|
|
|
221 |
|
222 |
// If a new role was added (redirect from new role screen).
|
223 |
if ( isset( $_GET['message'] ) && 'role_added' === $_GET['message'] )
|
224 |
-
add_settings_error( 'members_edit_role', 'role_added', sprintf( esc_html__( 'The %s role has been created.', 'members' ),
|
225 |
|
226 |
// Load page hook.
|
227 |
do_action( 'members_load_role_edit' );
|
@@ -237,7 +251,7 @@ final class Members_Admin_Role_Edit {
|
|
237 |
/**
|
238 |
* Adds help tabs.
|
239 |
*
|
240 |
-
* @since
|
241 |
* @access public
|
242 |
* @return void
|
243 |
*/
|
@@ -259,7 +273,7 @@ final class Members_Admin_Role_Edit {
|
|
259 |
/**
|
260 |
* Enqueue scripts/styles.
|
261 |
*
|
262 |
-
* @since
|
263 |
* @access public
|
264 |
* @return void
|
265 |
*/
|
@@ -272,7 +286,7 @@ final class Members_Admin_Role_Edit {
|
|
272 |
/**
|
273 |
* Displays the page content.
|
274 |
*
|
275 |
-
* @since
|
276 |
* @access public
|
277 |
* @return void
|
278 |
*/
|
@@ -284,7 +298,7 @@ final class Members_Admin_Role_Edit {
|
|
284 |
<?php esc_html_e( 'Edit Role', 'members' ); ?>
|
285 |
|
286 |
<?php if ( current_user_can( 'create_roles' ) ) : ?>
|
287 |
-
<?php printf( '<a class="page-title-action" href="%s">%s</a>', esc_url( members_get_new_role_url() ),
|
288 |
<?php endif; ?>
|
289 |
</h1>
|
290 |
|
@@ -304,7 +318,7 @@ final class Members_Admin_Role_Edit {
|
|
304 |
|
305 |
<div id="titlewrap">
|
306 |
<span class="screen-reader-text"><?php esc_html_e( 'Role Name', 'members' ); ?></span>
|
307 |
-
<input type="text" disabled="disabled" readonly="readonly" value="<?php echo esc_attr(
|
308 |
</div><!-- #titlewrap -->
|
309 |
|
310 |
<div class="inside">
|
@@ -315,7 +329,7 @@ final class Members_Admin_Role_Edit {
|
|
315 |
|
316 |
</div><!-- .members-title-div -->
|
317 |
|
318 |
-
<?php $cap_tabs = new
|
319 |
<?php $cap_tabs->display(); ?>
|
320 |
|
321 |
</div><!-- #post-body-content -->
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class that displays the edit role screen and handles the form submissions for that page.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Role_Edit {
|
22 |
|
23 |
/**
|
24 |
* Current role object to be edited/viewed.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access protected
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Current Members role object to be edited/viewed.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access protected
|
37 |
* @var object
|
38 |
*/
|
41 |
/**
|
42 |
* Whether the current role can be edited.
|
43 |
*
|
44 |
+
* @since 2.0.0
|
45 |
* @access protected
|
46 |
* @var bool
|
47 |
*/
|
50 |
/**
|
51 |
* Available capabilities.
|
52 |
*
|
53 |
+
* @since 2.0.0
|
54 |
* @access protected
|
55 |
* @var array
|
56 |
*/
|
59 |
/**
|
60 |
* Whether the page was updated.
|
61 |
*
|
62 |
+
* @since 2.0.0
|
63 |
* @access protected
|
64 |
* @var bool
|
65 |
*/
|
68 |
/**
|
69 |
* Sets up some necessary actions/filters.
|
70 |
*
|
71 |
+
* @since 2.0.0
|
72 |
* @access public
|
73 |
* @return void
|
74 |
*/
|
81 |
/**
|
82 |
* Runs on the `load-{$page}` hook. This is the handler for form submissions.
|
83 |
*
|
84 |
+
* @since 2.0.0
|
85 |
* @access public
|
86 |
* @return void
|
87 |
*/
|
168 |
$_cap = members_sanitize_cap( $grant_new_cap );
|
169 |
|
170 |
// If not an existing cap, add it.
|
171 |
+
if ( 'do_not_allow' !== $_cap && ! in_array( $_cap, $this->capabilities ) ) {
|
172 |
$this->role->add_cap( $_cap );
|
173 |
|
174 |
$push_caps[] = $_cap;
|
181 |
$_cap = members_sanitize_cap( $deny_new_cap );
|
182 |
|
183 |
// If not a granted cap and not an existing cap, add it.
|
184 |
+
if ( 'do_not_allow' !== $_cap && ! in_array( $_cap, $this->capabilities ) && ! in_array( $_cap, $grant_new_caps ) ) {
|
185 |
$this->role->add_cap( $_cap, false );
|
186 |
|
187 |
$push_caps[] = $_cap;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
+
// Add the updated role to the role registry.
|
206 |
+
members_unregister_role( $this->role->name );
|
207 |
+
|
208 |
+
members_register_role(
|
209 |
+
$this->role->name,
|
210 |
+
array(
|
211 |
+
'label' => $this->members_role->label,
|
212 |
+
'caps' => $this->role->capabilities
|
213 |
+
)
|
214 |
+
);
|
215 |
|
216 |
// Reset the Members role object.
|
217 |
$this->members_role = members_get_role( $this->role->name );
|
223 |
|
224 |
// If successful update.
|
225 |
if ( $this->role_updated )
|
226 |
+
add_settings_error( 'members_edit_role', 'role_updated', sprintf( esc_html__( '%s role updated.', 'members' ), members_get_role( $this->role->name )->label ), 'updated' );
|
227 |
|
228 |
// If the role is not editable.
|
229 |
if ( ! $this->is_editable )
|
230 |
+
add_settings_error( 'members_edit_role', 'role_uneditable', sprintf( esc_html__( 'The %s role is not editable. This means that it is most likely added via another plugin for a special use or that you do not have permission to edit it.', 'members' ), members_get_role( $this->role->name )->label ) );
|
231 |
+
|
232 |
+
// If editing the core administrator role.
|
233 |
+
if ( 'administrator' === $this->role->name )
|
234 |
+
add_settings_error( 'members_edit_role', 'role_is_admin', sprintf( esc_html__( 'The %s role is typically the most important role on the site. Please take extreme caution that you do not inadvertently remove necessary capabilities.', 'members' ), members_get_role( $this->role->name )->label ) );
|
235 |
|
236 |
// If a new role was added (redirect from new role screen).
|
237 |
if ( isset( $_GET['message'] ) && 'role_added' === $_GET['message'] )
|
238 |
+
add_settings_error( 'members_edit_role', 'role_added', sprintf( esc_html__( 'The %s role has been created.', 'members' ), members_get_role( $this->role->name )->label ), 'updated' );
|
239 |
|
240 |
// Load page hook.
|
241 |
do_action( 'members_load_role_edit' );
|
251 |
/**
|
252 |
* Adds help tabs.
|
253 |
*
|
254 |
+
* @since 2.0.0
|
255 |
* @access public
|
256 |
* @return void
|
257 |
*/
|
273 |
/**
|
274 |
* Enqueue scripts/styles.
|
275 |
*
|
276 |
+
* @since 2.0.0
|
277 |
* @access public
|
278 |
* @return void
|
279 |
*/
|
286 |
/**
|
287 |
* Displays the page content.
|
288 |
*
|
289 |
+
* @since 2.0.0
|
290 |
* @access public
|
291 |
* @return void
|
292 |
*/
|
298 |
<?php esc_html_e( 'Edit Role', 'members' ); ?>
|
299 |
|
300 |
<?php if ( current_user_can( 'create_roles' ) ) : ?>
|
301 |
+
<?php printf( '<a class="page-title-action" href="%s">%s</a>', esc_url( members_get_new_role_url() ), esc_html_x( 'Add New', 'role', 'members' ) ); ?>
|
302 |
<?php endif; ?>
|
303 |
</h1>
|
304 |
|
318 |
|
319 |
<div id="titlewrap">
|
320 |
<span class="screen-reader-text"><?php esc_html_e( 'Role Name', 'members' ); ?></span>
|
321 |
+
<input type="text" disabled="disabled" readonly="readonly" value="<?php echo esc_attr( members_get_role( $this->role->name )->label ); ?>" />
|
322 |
</div><!-- #titlewrap -->
|
323 |
|
324 |
<div class="inside">
|
329 |
|
330 |
</div><!-- .members-title-div -->
|
331 |
|
332 |
+
<?php $cap_tabs = new Cap_Tabs( $this->role->name ); ?>
|
333 |
<?php $cap_tabs->display(); ?>
|
334 |
|
335 |
</div><!-- #post-body-content -->
|
admin/class-role-group-factory.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Singleton factory class for storying role group objects.
|
4 |
-
*
|
5 |
-
* @package Members
|
6 |
-
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <justin@justintadlock.com>
|
8 |
-
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
|
9 |
-
* @link http://themehybrid.com/plugins/members
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Roleability group factory class.
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
* @access public
|
18 |
-
*/
|
19 |
-
final class Members_Role_Group_Factory {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Array of group objects.
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
* @access public
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
public $groups = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor method.
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
* @access private
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
private function __construct() {}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Register a new group object
|
41 |
-
*
|
42 |
-
* @see Members_Role_Group::__construct()
|
43 |
-
* @since 1.0.0
|
44 |
-
* @access public
|
45 |
-
* @param string $name
|
46 |
-
* @param array $args
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function register_group( $name, $args = array() ) {
|
50 |
-
|
51 |
-
if ( ! $this->group_exists( $name ) ) {
|
52 |
-
|
53 |
-
$group = new Members_Role_Group( $name, $args );
|
54 |
-
|
55 |
-
$this->groups[ $group->name ] = $group;
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Unregisters a group object.
|
61 |
-
*
|
62 |
-
* @since 1.0.0
|
63 |
-
* @access public
|
64 |
-
* @param string $name
|
65 |
-
* @return void
|
66 |
-
*/
|
67 |
-
public function unregister_group( $name ) {
|
68 |
-
|
69 |
-
if ( $this->group_exists( $name ) && false === $this->get( $name )->_internal )
|
70 |
-
unset( $this->groups[ $name ] );
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Checks if a group exists.
|
75 |
-
*
|
76 |
-
* @since 1.0.0
|
77 |
-
* @access public
|
78 |
-
* @param string $name
|
79 |
-
* @return bool
|
80 |
-
*/
|
81 |
-
public function group_exists( $name ) {
|
82 |
-
|
83 |
-
return isset( $this->groups[ $name ] );
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Gets a group object.
|
88 |
-
*
|
89 |
-
* @since 1.0.0
|
90 |
-
* @access public
|
91 |
-
* @param string $name
|
92 |
-
* @return object|bool
|
93 |
-
*/
|
94 |
-
public function get_group( $name ) {
|
95 |
-
|
96 |
-
return $this->group_exists( $name ) ? $this->groups[ $name ] : false;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Returns the instance.
|
101 |
-
*
|
102 |
-
* @since 1.0.0
|
103 |
-
* @access public
|
104 |
-
* @return object
|
105 |
-
*/
|
106 |
-
public static function get_instance() {
|
107 |
-
|
108 |
-
static $instance = null;
|
109 |
-
|
110 |
-
if ( is_null( $instance ) )
|
111 |
-
$instance = new Members_Role_Group_Factory;
|
112 |
-
|
113 |
-
return $instance;
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-role-group.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for handling a role group object.
|
4 |
-
*
|
5 |
-
* @package Members
|
6 |
-
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <justin@justintadlock.com>
|
8 |
-
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
|
9 |
-
* @link http://themehybrid.com/plugins/members
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Role group object class.
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
* @access public
|
18 |
-
*/
|
19 |
-
final class Members_Role_Group {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Stores the properties for the object.
|
23 |
-
*
|
24 |
-
* @since 1.0.0
|
25 |
-
* @access protected
|
26 |
-
* @var array
|
27 |
-
*/
|
28 |
-
protected $args = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Magic method for getting object properties.
|
32 |
-
*
|
33 |
-
* @since 1.0.0
|
34 |
-
* @access public
|
35 |
-
* @param string $property
|
36 |
-
* @return mixed
|
37 |
-
*/
|
38 |
-
public function __get( $property ) {
|
39 |
-
|
40 |
-
return isset( $this->$property ) ? $this->args[ $property ] : null;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Magic method for setting object properties.
|
45 |
-
*
|
46 |
-
* @since 1.0.0
|
47 |
-
* @access public
|
48 |
-
* @param string $property
|
49 |
-
* @param mixed $value
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function __set( $property, $value ) {
|
53 |
-
|
54 |
-
if ( isset( $this->$property ) )
|
55 |
-
$this->args[ $property ] = $value;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Magic method for checking if a property is set.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @access public
|
63 |
-
* @param string $property
|
64 |
-
* @return bool
|
65 |
-
*/
|
66 |
-
public function __isset( $property ) {
|
67 |
-
|
68 |
-
return isset( $this->args[ $property ] );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Don't allow properties to be unset.
|
73 |
-
*
|
74 |
-
* @since 3.0.0
|
75 |
-
* @access public
|
76 |
-
* @param string $property
|
77 |
-
* @return void
|
78 |
-
*/
|
79 |
-
public function __unset( $property ) {}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Magic method to use in case someone tries to output the object as a string.
|
83 |
-
* We'll just return the name.
|
84 |
-
*
|
85 |
-
* @since 1.0.0
|
86 |
-
* @access public
|
87 |
-
* @return string
|
88 |
-
*/
|
89 |
-
public function __toString() {
|
90 |
-
return $this->name;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Register a new object.
|
95 |
-
*
|
96 |
-
* @since 1.0.0
|
97 |
-
* @access public
|
98 |
-
* @param string $name
|
99 |
-
* @param array $args {
|
100 |
-
* @type string $label Internationalized text label.
|
101 |
-
* @type string $icon Count label in admin.
|
102 |
-
* @type array $roles Array of roles in the group.
|
103 |
-
* }
|
104 |
-
* @return void
|
105 |
-
*/
|
106 |
-
public function __construct( $name, $args = array() ) {
|
107 |
-
|
108 |
-
$name = sanitize_key( $name );
|
109 |
-
|
110 |
-
$defaults = array(
|
111 |
-
'label' => '',
|
112 |
-
'label_count' => '',
|
113 |
-
'roles' => array(),
|
114 |
-
'show_in_view_list' => true
|
115 |
-
);
|
116 |
-
|
117 |
-
$this->args = wp_parse_args( $args, $defaults );
|
118 |
-
|
119 |
-
// Get the roles that exist.
|
120 |
-
$existing_roles = array_keys( members_get_role_names() );
|
121 |
-
|
122 |
-
// Remove roles that don't exist.
|
123 |
-
if ( $this->args['roles'] )
|
124 |
-
$this->args['roles'] = array_intersect( $existing_roles, $this->args['roles'] );
|
125 |
-
|
126 |
-
// Set the name.
|
127 |
-
$this->args['name'] = $name;
|
128 |
-
}
|
129 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-role-list-table.php
CHANGED
@@ -4,34 +4,45 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Role list table for the roles management page in the admin. Extends the core `WP_List_Table`
|
15 |
* class in the admin.
|
16 |
*
|
17 |
-
* @since
|
18 |
* @access public
|
19 |
*/
|
20 |
-
class
|
21 |
|
22 |
/**
|
23 |
* The current view.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @access public
|
27 |
* @var string
|
28 |
*/
|
29 |
public $role_view = 'all';
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
* Allowed role views.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var array
|
37 |
*/
|
@@ -40,7 +51,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
40 |
/**
|
41 |
* The default role. This will be assigned the value of `get_option( 'default_role' )`.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @var string
|
46 |
*/
|
@@ -49,7 +60,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
49 |
/**
|
50 |
* The current user object.
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
* @var object
|
55 |
*/
|
@@ -58,7 +69,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
58 |
/**
|
59 |
* Sets up the list table.
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @return void
|
64 |
*/
|
@@ -72,7 +83,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
72 |
parent::__construct( $args );
|
73 |
|
74 |
// Get the current user object.
|
75 |
-
$this->current_user = new WP_User( get_current_user_id() );
|
76 |
|
77 |
// Get the defined default role.
|
78 |
$this->default_role = get_option( 'default_role', $this->default_role );
|
@@ -81,32 +92,24 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
81 |
$this->allowed_role_views = array_keys( $this->get_views() );
|
82 |
|
83 |
// Get the current view.
|
84 |
-
if ( isset( $_GET['
|
85 |
-
$this->role_view = $_GET['
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
* Sets up the items (roles) to list.
|
90 |
*
|
91 |
-
* @since
|
92 |
* @access public
|
93 |
* @return void
|
94 |
*/
|
95 |
public function prepare_items() {
|
96 |
|
97 |
-
|
98 |
-
if ( 'all' === $this->role_view ) {
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
} else {
|
104 |
-
// Get the current group being viewed.
|
105 |
-
$group = members_get_role_group( $this->role_view );
|
106 |
-
|
107 |
-
// Set the roles array.
|
108 |
-
$roles = $group ? $group->roles : array();
|
109 |
-
}
|
110 |
|
111 |
// Allow devs to filter the items.
|
112 |
$roles = apply_filters( 'members_manage_roles_items', $roles, $this->role_view );
|
@@ -168,7 +171,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
168 |
* Returns an array of columns to show.
|
169 |
*
|
170 |
* @see members_manage_roles_columns()
|
171 |
-
* @since
|
172 |
* @access public
|
173 |
* @return array
|
174 |
*/
|
@@ -195,7 +198,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
195 |
/**
|
196 |
* The checkbox column callback.
|
197 |
*
|
198 |
-
* @since
|
199 |
* @access protected
|
200 |
* @param string $role
|
201 |
* @return string
|
@@ -214,7 +217,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
214 |
/**
|
215 |
* The role name column callback.
|
216 |
*
|
217 |
-
* @since
|
218 |
* @access protected
|
219 |
* @param string $role
|
220 |
* @return string
|
@@ -226,11 +229,11 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
226 |
|
227 |
// If the role is the default role.
|
228 |
if ( $role == get_option( 'default_role' ) )
|
229 |
-
$states[] = esc_html__( 'Default Role', 'members' );
|
230 |
|
231 |
// If the current user has this role.
|
232 |
if ( members_current_user_has_role( $role ) )
|
233 |
-
$states[] = esc_html__( 'Your Role', 'members' );
|
234 |
|
235 |
// Allow devs to filter the role states.
|
236 |
$states = apply_filters( 'members_role_states', $states, $role );
|
@@ -238,14 +241,14 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
238 |
// If we have states, string them together.
|
239 |
if ( ! empty( $states ) ) {
|
240 |
|
241 |
-
foreach ( $states as $state )
|
242 |
-
$
|
243 |
|
244 |
-
$role_states = ' – ' . $
|
245 |
}
|
246 |
|
247 |
// Add the title and role states.
|
248 |
-
$title = sprintf( '<strong><a class="row-title" href="%s">%s</a>%s</strong>', esc_url( members_get_edit_role_url( $role ) ), esc_html(
|
249 |
|
250 |
return apply_filters( 'members_manage_roles_column_role_name', $title, $role );
|
251 |
}
|
@@ -253,7 +256,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
253 |
/**
|
254 |
* The role column callback.
|
255 |
*
|
256 |
-
* @since
|
257 |
* @access protected
|
258 |
* @param string $role
|
259 |
* @return string
|
@@ -265,7 +268,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
265 |
/**
|
266 |
* The users column callback.
|
267 |
*
|
268 |
-
* @since
|
269 |
* @access protected
|
270 |
* @param string $role
|
271 |
* @return string
|
@@ -277,7 +280,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
277 |
/**
|
278 |
* The caps column callback.
|
279 |
*
|
280 |
-
* @since
|
281 |
* @access protected
|
282 |
* @param string $role
|
283 |
* @return string
|
@@ -289,7 +292,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
289 |
/**
|
290 |
* The caps column callback.
|
291 |
*
|
292 |
-
* @since
|
293 |
* @access protected
|
294 |
* @param string $role
|
295 |
* @return string
|
@@ -301,7 +304,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
301 |
/**
|
302 |
* Returns the name of the primary column.
|
303 |
*
|
304 |
-
* @since
|
305 |
* @access protected
|
306 |
* @return string
|
307 |
*/
|
@@ -312,7 +315,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
312 |
/**
|
313 |
* Handles the row actions.
|
314 |
*
|
315 |
-
* @since
|
316 |
* @access protected
|
317 |
* @param string $role
|
318 |
* @param string $column_name
|
@@ -366,7 +369,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
366 |
/**
|
367 |
* Returns an array of sortable columns.
|
368 |
*
|
369 |
-
* @since
|
370 |
* @access protected
|
371 |
* @return array
|
372 |
*/
|
@@ -381,31 +384,46 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
381 |
/**
|
382 |
* Returns an array of views for the list table.
|
383 |
*
|
384 |
-
* @since
|
385 |
* @access protected
|
386 |
* @return array
|
387 |
*/
|
388 |
protected function get_views() {
|
389 |
|
390 |
-
|
391 |
-
$
|
392 |
-
|
393 |
-
if ( $active )
|
394 |
-
$active->roles = members_get_active_role_slugs();
|
395 |
-
|
396 |
-
if ( $inactive )
|
397 |
-
$inactive->roles = members_get_inactive_role_slugs();
|
398 |
|
399 |
$views = array();
|
400 |
$current = ' class="current"';
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
);
|
410 |
|
411 |
// Loop through the role groups and put them into the view list.
|
@@ -415,19 +433,28 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
415 |
if ( ! $group->show_in_view_list )
|
416 |
continue;
|
417 |
|
418 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
// Skip any views with 0 roles.
|
421 |
if ( 0 >= $count )
|
422 |
continue;
|
423 |
|
424 |
-
$noop = $
|
425 |
|
426 |
// Add the view link.
|
427 |
-
$views[ $
|
428 |
'<a%s href="%s">%s</a>',
|
429 |
-
$
|
430 |
-
'all' === $
|
431 |
sprintf( translate_nooped_plural( $noop, $count, $noop['domain'] ), sprintf( '<span class="count">(%s)</span>', number_format_i18n( $count ) ) )
|
432 |
);
|
433 |
}
|
@@ -438,7 +465,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
438 |
/**
|
439 |
* Displays the list table.
|
440 |
*
|
441 |
-
* @since
|
442 |
* @access public
|
443 |
* @return void
|
444 |
*/
|
@@ -452,7 +479,7 @@ class Members_Role_List_Table extends WP_List_Table {
|
|
452 |
/**
|
453 |
* Returns an array of bulk actions available.
|
454 |
*
|
455 |
-
* @since
|
456 |
* @access protected
|
457 |
* @return array
|
458 |
*/
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Role list table for the roles management page in the admin. Extends the core `WP_List_Table`
|
17 |
* class in the admin.
|
18 |
*
|
19 |
+
* @since 2.0.0
|
20 |
* @access public
|
21 |
*/
|
22 |
+
class Role_List_Table extends \WP_List_Table {
|
23 |
|
24 |
/**
|
25 |
* The current view.
|
26 |
*
|
27 |
+
* @since 2.0.0
|
28 |
* @access public
|
29 |
* @var string
|
30 |
*/
|
31 |
public $role_view = 'all';
|
32 |
|
33 |
+
/**
|
34 |
+
* Array of role views.
|
35 |
+
*
|
36 |
+
* @since 2.0.0
|
37 |
+
* @access public
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
public $role_views = array();
|
41 |
+
|
42 |
/**
|
43 |
* Allowed role views.
|
44 |
*
|
45 |
+
* @since 2.0.0
|
46 |
* @access public
|
47 |
* @var array
|
48 |
*/
|
51 |
/**
|
52 |
* The default role. This will be assigned the value of `get_option( 'default_role' )`.
|
53 |
*
|
54 |
+
* @since 2.0.0
|
55 |
* @access public
|
56 |
* @var string
|
57 |
*/
|
60 |
/**
|
61 |
* The current user object.
|
62 |
*
|
63 |
+
* @since 2.0.0
|
64 |
* @access public
|
65 |
* @var object
|
66 |
*/
|
69 |
/**
|
70 |
* Sets up the list table.
|
71 |
*
|
72 |
+
* @since 2.0.0
|
73 |
* @access public
|
74 |
* @return void
|
75 |
*/
|
83 |
parent::__construct( $args );
|
84 |
|
85 |
// Get the current user object.
|
86 |
+
$this->current_user = new \WP_User( get_current_user_id() );
|
87 |
|
88 |
// Get the defined default role.
|
89 |
$this->default_role = get_option( 'default_role', $this->default_role );
|
92 |
$this->allowed_role_views = array_keys( $this->get_views() );
|
93 |
|
94 |
// Get the current view.
|
95 |
+
if ( isset( $_GET['view'] ) && in_array( $_GET['view'], $this->allowed_role_views ) )
|
96 |
+
$this->role_view = $_GET['view'];
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
* Sets up the items (roles) to list.
|
101 |
*
|
102 |
+
* @since 2.0.0
|
103 |
* @access public
|
104 |
* @return void
|
105 |
*/
|
106 |
public function prepare_items() {
|
107 |
|
108 |
+
$roles = array();
|
|
|
109 |
|
110 |
+
// Get the roles for the view.
|
111 |
+
if ( ! empty( $this->role_views[ $this->role_view ]['roles'] ) )
|
112 |
+
$roles = $this->role_views[ $this->role_view ]['roles'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
// Allow devs to filter the items.
|
115 |
$roles = apply_filters( 'members_manage_roles_items', $roles, $this->role_view );
|
171 |
* Returns an array of columns to show.
|
172 |
*
|
173 |
* @see members_manage_roles_columns()
|
174 |
+
* @since 2.0.0
|
175 |
* @access public
|
176 |
* @return array
|
177 |
*/
|
198 |
/**
|
199 |
* The checkbox column callback.
|
200 |
*
|
201 |
+
* @since 2.0.0
|
202 |
* @access protected
|
203 |
* @param string $role
|
204 |
* @return string
|
217 |
/**
|
218 |
* The role name column callback.
|
219 |
*
|
220 |
+
* @since 2.0.0
|
221 |
* @access protected
|
222 |
* @param string $role
|
223 |
* @return string
|
229 |
|
230 |
// If the role is the default role.
|
231 |
if ( $role == get_option( 'default_role' ) )
|
232 |
+
$states['default'] = esc_html__( 'Default Role', 'members' );
|
233 |
|
234 |
// If the current user has this role.
|
235 |
if ( members_current_user_has_role( $role ) )
|
236 |
+
$states['mine'] = esc_html__( 'Your Role', 'members' );
|
237 |
|
238 |
// Allow devs to filter the role states.
|
239 |
$states = apply_filters( 'members_role_states', $states, $role );
|
241 |
// If we have states, string them together.
|
242 |
if ( ! empty( $states ) ) {
|
243 |
|
244 |
+
foreach ( $states as $state => $label )
|
245 |
+
$states[ $state ] = sprintf( '<span class="role-state">%s</span>', $label );
|
246 |
|
247 |
+
$role_states = ' – ' . join( ', ', $states );
|
248 |
}
|
249 |
|
250 |
// Add the title and role states.
|
251 |
+
$title = sprintf( '<strong><a class="row-title" href="%s">%s</a>%s</strong>', esc_url( members_get_edit_role_url( $role ) ), esc_html( members_get_role( $role )->label ), $role_states );
|
252 |
|
253 |
return apply_filters( 'members_manage_roles_column_role_name', $title, $role );
|
254 |
}
|
256 |
/**
|
257 |
* The role column callback.
|
258 |
*
|
259 |
+
* @since 2.0.0
|
260 |
* @access protected
|
261 |
* @param string $role
|
262 |
* @return string
|
268 |
/**
|
269 |
* The users column callback.
|
270 |
*
|
271 |
+
* @since 2.0.0
|
272 |
* @access protected
|
273 |
* @param string $role
|
274 |
* @return string
|
280 |
/**
|
281 |
* The caps column callback.
|
282 |
*
|
283 |
+
* @since 2.0.0
|
284 |
* @access protected
|
285 |
* @param string $role
|
286 |
* @return string
|
292 |
/**
|
293 |
* The caps column callback.
|
294 |
*
|
295 |
+
* @since 2.0.0
|
296 |
* @access protected
|
297 |
* @param string $role
|
298 |
* @return string
|
304 |
/**
|
305 |
* Returns the name of the primary column.
|
306 |
*
|
307 |
+
* @since 2.0.0
|
308 |
* @access protected
|
309 |
* @return string
|
310 |
*/
|
315 |
/**
|
316 |
* Handles the row actions.
|
317 |
*
|
318 |
+
* @since 2.0.0
|
319 |
* @access protected
|
320 |
* @param string $role
|
321 |
* @param string $column_name
|
369 |
/**
|
370 |
* Returns an array of sortable columns.
|
371 |
*
|
372 |
+
* @since 2.0.0
|
373 |
* @access protected
|
374 |
* @return array
|
375 |
*/
|
384 |
/**
|
385 |
* Returns an array of views for the list table.
|
386 |
*
|
387 |
+
* @since 2.0.0
|
388 |
* @access protected
|
389 |
* @return array
|
390 |
*/
|
391 |
protected function get_views() {
|
392 |
|
393 |
+
// Get the current user.
|
394 |
+
$current_user = wp_get_current_user();
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
$views = array();
|
397 |
$current = ' class="current"';
|
398 |
+
|
399 |
+
$this->role_views['all'] = array(
|
400 |
+
'label_count' => _n_noop( 'All %s', 'All %s', 'members' ),
|
401 |
+
'roles' => array_keys( members_get_roles() )
|
402 |
+
);
|
403 |
+
|
404 |
+
$this->role_views['mine'] = array(
|
405 |
+
'label_count' => _n_noop( 'Mine %s', 'Mine %s', 'members' ),
|
406 |
+
'roles' => $current_user->roles
|
407 |
+
);
|
408 |
+
|
409 |
+
$this->role_views['active'] = array(
|
410 |
+
'label_count' => _n_noop( 'Has Users %s', 'Has Users %s', 'members' ),
|
411 |
+
'roles' => members_get_active_roles()
|
412 |
+
);
|
413 |
+
|
414 |
+
$this->role_views['inactive'] = array(
|
415 |
+
'label_count' => _n_noop( 'No Users %s', 'No Users %s', 'members' ),
|
416 |
+
'roles' =>members_get_inactive_roles()
|
417 |
+
);
|
418 |
+
|
419 |
+
$this->role_views['editable'] = array(
|
420 |
+
'label_count' => _n_noop( 'Editable %s', 'Editable %s', 'members' ),
|
421 |
+
'roles' => members_get_editable_roles()
|
422 |
+
);
|
423 |
+
|
424 |
+
$this->role_views['uneditable'] = array(
|
425 |
+
'label_count' => _n_noop( 'Uneditable %s', 'Uneditable %s', 'members' ),
|
426 |
+
'roles' => members_get_uneditable_roles()
|
427 |
);
|
428 |
|
429 |
// Loop through the role groups and put them into the view list.
|
433 |
if ( ! $group->show_in_view_list )
|
434 |
continue;
|
435 |
|
436 |
+
$this->role_views[ "group-{$group->name}" ] = array(
|
437 |
+
'label_count' => $group->label_count,
|
438 |
+
'roles' => $group->roles
|
439 |
+
);
|
440 |
+
}
|
441 |
+
|
442 |
+
// Loop through the default views and put them into the view list.
|
443 |
+
foreach ( $this->role_views as $view => $args ) {
|
444 |
+
|
445 |
+
$count = count( $args['roles'] );
|
446 |
|
447 |
// Skip any views with 0 roles.
|
448 |
if ( 0 >= $count )
|
449 |
continue;
|
450 |
|
451 |
+
$noop = $args['label_count'];
|
452 |
|
453 |
// Add the view link.
|
454 |
+
$views[ $view ] = sprintf(
|
455 |
'<a%s href="%s">%s</a>',
|
456 |
+
$view === $this->role_view ? $current : '',
|
457 |
+
'all' === $view ? esc_url( members_get_edit_roles_url() ) : esc_url( members_get_role_view_url( $view ) ),
|
458 |
sprintf( translate_nooped_plural( $noop, $count, $noop['domain'] ), sprintf( '<span class="count">(%s)</span>', number_format_i18n( $count ) ) )
|
459 |
);
|
460 |
}
|
465 |
/**
|
466 |
* Displays the list table.
|
467 |
*
|
468 |
+
* @since 2.0.0
|
469 |
* @access public
|
470 |
* @return void
|
471 |
*/
|
479 |
/**
|
480 |
* Returns an array of bulk actions available.
|
481 |
*
|
482 |
+
* @since 2.0.0
|
483 |
* @access protected
|
484 |
* @return array
|
485 |
*/
|
admin/class-role-new.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class that displays the new role screen and handles the form submissions for that page.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Admin_Role_New {
|
|
30 |
/**
|
31 |
* Name of the page we've created.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @var string
|
36 |
*/
|
@@ -39,7 +41,7 @@ final class Members_Admin_Role_New {
|
|
39 |
/**
|
40 |
* Role that's being created.
|
41 |
*
|
42 |
-
* @since
|
43 |
* @access public
|
44 |
* @var string
|
45 |
*/
|
@@ -48,7 +50,7 @@ final class Members_Admin_Role_New {
|
|
48 |
/**
|
49 |
* Name of the role that's being created.
|
50 |
*
|
51 |
-
* @since
|
52 |
* @access public
|
53 |
* @var string
|
54 |
*/
|
@@ -57,7 +59,7 @@ final class Members_Admin_Role_New {
|
|
57 |
/**
|
58 |
* Array of the role's capabilities.
|
59 |
*
|
60 |
-
* @since
|
61 |
* @access public
|
62 |
* @var array
|
63 |
*/
|
@@ -66,7 +68,7 @@ final class Members_Admin_Role_New {
|
|
66 |
/**
|
67 |
* Conditional to see if we're cloning a role.
|
68 |
*
|
69 |
-
* @since
|
70 |
* @access public
|
71 |
* @var bool
|
72 |
*/
|
@@ -75,7 +77,7 @@ final class Members_Admin_Role_New {
|
|
75 |
/**
|
76 |
* Role that is being cloned.
|
77 |
*
|
78 |
-
* @since
|
79 |
* @access public
|
80 |
* @var string
|
81 |
*/
|
@@ -84,7 +86,7 @@ final class Members_Admin_Role_New {
|
|
84 |
/**
|
85 |
* Sets up our initial actions.
|
86 |
*
|
87 |
-
* @since
|
88 |
* @access public
|
89 |
* @return void
|
90 |
*/
|
@@ -98,7 +100,7 @@ final class Members_Admin_Role_New {
|
|
98 |
/**
|
99 |
* Adds the roles page to the admin.
|
100 |
*
|
101 |
-
* @since
|
102 |
* @access public
|
103 |
* @return void
|
104 |
*/
|
@@ -117,7 +119,7 @@ final class Members_Admin_Role_New {
|
|
117 |
/**
|
118 |
* Checks posted data on load and performs actions if needed.
|
119 |
*
|
120 |
-
* @since
|
121 |
* @access public
|
122 |
* @return void
|
123 |
*/
|
@@ -179,7 +181,7 @@ final class Members_Admin_Role_New {
|
|
179 |
|
180 |
$_cap = members_sanitize_cap( $grant_new_cap );
|
181 |
|
182 |
-
if ( ! in_array( $_cap, $_m_caps ) )
|
183 |
$new_caps[ $_cap ] = true;
|
184 |
}
|
185 |
|
@@ -187,7 +189,7 @@ final class Members_Admin_Role_New {
|
|
187 |
|
188 |
$_cap = members_sanitize_cap( $deny_new_cap );
|
189 |
|
190 |
-
if ( ! in_array( $_cap, $_m_caps ) )
|
191 |
$new_caps[ $_cap ] = false;
|
192 |
}
|
193 |
|
@@ -262,7 +264,7 @@ final class Members_Admin_Role_New {
|
|
262 |
/**
|
263 |
* Adds help tabs.
|
264 |
*
|
265 |
-
* @since
|
266 |
* @access public
|
267 |
* @return void
|
268 |
*/
|
@@ -284,7 +286,7 @@ final class Members_Admin_Role_New {
|
|
284 |
/**
|
285 |
* Enqueue scripts/styles.
|
286 |
*
|
287 |
-
* @since
|
288 |
* @access public
|
289 |
* @return void
|
290 |
*/
|
@@ -297,7 +299,7 @@ final class Members_Admin_Role_New {
|
|
297 |
/**
|
298 |
* Outputs the page.
|
299 |
*
|
300 |
-
* @since
|
301 |
* @access public
|
302 |
* @return void
|
303 |
*/
|
@@ -323,7 +325,7 @@ final class Members_Admin_Role_New {
|
|
323 |
|
324 |
<div id="titlewrap">
|
325 |
<span class="screen-reader-text"><?php esc_html_e( 'Role Name', 'members' ); ?></span>
|
326 |
-
<input type="text" name="role_name" value="<?php echo ! $this->role && $this->clone_role ? esc_attr( sprintf( __( '%s Clone', 'members' ),
|
327 |
</div><!-- #titlewrap -->
|
328 |
|
329 |
<div class="inside">
|
@@ -336,7 +338,7 @@ final class Members_Admin_Role_New {
|
|
336 |
|
337 |
</div><!-- .members-title-div -->
|
338 |
|
339 |
-
<?php $cap_tabs = new
|
340 |
<?php $cap_tabs->display(); ?>
|
341 |
|
342 |
</div><!-- #post-body-content -->
|
@@ -362,7 +364,7 @@ final class Members_Admin_Role_New {
|
|
362 |
/**
|
363 |
* Filters the new role default caps in the case that we're cloning a role.
|
364 |
*
|
365 |
-
* @since
|
366 |
* @access public
|
367 |
* @param array $capabilities
|
368 |
* @param array
|
@@ -383,7 +385,7 @@ final class Members_Admin_Role_New {
|
|
383 |
/**
|
384 |
* Returns the instance.
|
385 |
*
|
386 |
-
* @since
|
387 |
* @access public
|
388 |
* @return object
|
389 |
*/
|
@@ -396,4 +398,4 @@ final class Members_Admin_Role_New {
|
|
396 |
}
|
397 |
}
|
398 |
|
399 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class that displays the new role screen and handles the form submissions for that page.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Role_New {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Name of the page we've created.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @var string
|
38 |
*/
|
41 |
/**
|
42 |
* Role that's being created.
|
43 |
*
|
44 |
+
* @since 2.0.0
|
45 |
* @access public
|
46 |
* @var string
|
47 |
*/
|
50 |
/**
|
51 |
* Name of the role that's being created.
|
52 |
*
|
53 |
+
* @since 2.0.0
|
54 |
* @access public
|
55 |
* @var string
|
56 |
*/
|
59 |
/**
|
60 |
* Array of the role's capabilities.
|
61 |
*
|
62 |
+
* @since 2.0.0
|
63 |
* @access public
|
64 |
* @var array
|
65 |
*/
|
68 |
/**
|
69 |
* Conditional to see if we're cloning a role.
|
70 |
*
|
71 |
+
* @since 2.0.0
|
72 |
* @access public
|
73 |
* @var bool
|
74 |
*/
|
77 |
/**
|
78 |
* Role that is being cloned.
|
79 |
*
|
80 |
+
* @since 2.0.0
|
81 |
* @access public
|
82 |
* @var string
|
83 |
*/
|
86 |
/**
|
87 |
* Sets up our initial actions.
|
88 |
*
|
89 |
+
* @since 2.0.0
|
90 |
* @access public
|
91 |
* @return void
|
92 |
*/
|
100 |
/**
|
101 |
* Adds the roles page to the admin.
|
102 |
*
|
103 |
+
* @since 2.0.0
|
104 |
* @access public
|
105 |
* @return void
|
106 |
*/
|
119 |
/**
|
120 |
* Checks posted data on load and performs actions if needed.
|
121 |
*
|
122 |
+
* @since 2.0.0
|
123 |
* @access public
|
124 |
* @return void
|
125 |
*/
|
181 |
|
182 |
$_cap = members_sanitize_cap( $grant_new_cap );
|
183 |
|
184 |
+
if ( 'do_not_allow' !== $_cap && ! in_array( $_cap, $_m_caps ) )
|
185 |
$new_caps[ $_cap ] = true;
|
186 |
}
|
187 |
|
189 |
|
190 |
$_cap = members_sanitize_cap( $deny_new_cap );
|
191 |
|
192 |
+
if ( 'do_not_allow' !== $_cap && ! in_array( $_cap, $_m_caps ) )
|
193 |
$new_caps[ $_cap ] = false;
|
194 |
}
|
195 |
|
264 |
/**
|
265 |
* Adds help tabs.
|
266 |
*
|
267 |
+
* @since 2.0.0
|
268 |
* @access public
|
269 |
* @return void
|
270 |
*/
|
286 |
/**
|
287 |
* Enqueue scripts/styles.
|
288 |
*
|
289 |
+
* @since 2.0.0
|
290 |
* @access public
|
291 |
* @return void
|
292 |
*/
|
299 |
/**
|
300 |
* Outputs the page.
|
301 |
*
|
302 |
+
* @since 2.0.0
|
303 |
* @access public
|
304 |
* @return void
|
305 |
*/
|
325 |
|
326 |
<div id="titlewrap">
|
327 |
<span class="screen-reader-text"><?php esc_html_e( 'Role Name', 'members' ); ?></span>
|
328 |
+
<input type="text" name="role_name" value="<?php echo ! $this->role && $this->clone_role ? esc_attr( sprintf( __( '%s Clone', 'members' ), members_get_role( $this->clone_role )->label ) ) : esc_attr( $this->role_name ); ?>" placeholder="<?php esc_attr_e( 'Enter role name', 'members' ); ?>" />
|
329 |
</div><!-- #titlewrap -->
|
330 |
|
331 |
<div class="inside">
|
338 |
|
339 |
</div><!-- .members-title-div -->
|
340 |
|
341 |
+
<?php $cap_tabs = new Cap_Tabs( '', $this->capabilities ); ?>
|
342 |
<?php $cap_tabs->display(); ?>
|
343 |
|
344 |
</div><!-- #post-body-content -->
|
364 |
/**
|
365 |
* Filters the new role default caps in the case that we're cloning a role.
|
366 |
*
|
367 |
+
* @since 2.0.0
|
368 |
* @access public
|
369 |
* @param array $capabilities
|
370 |
* @param array
|
385 |
/**
|
386 |
* Returns the instance.
|
387 |
*
|
388 |
+
* @since 2.0.0
|
389 |
* @access public
|
390 |
* @return object
|
391 |
*/
|
398 |
}
|
399 |
}
|
400 |
|
401 |
+
Role_New::get_instance();
|
admin/class-roles.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Class that displays the roles admin screen and handles requests for that page.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Sets up some necessary actions/filters.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access public
|
26 |
* @return void
|
27 |
*/
|
@@ -40,7 +42,7 @@ final class Members_Admin_Roles {
|
|
40 |
/**
|
41 |
* Modifies the current screen object.
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
* @return void
|
46 |
*/
|
@@ -53,7 +55,7 @@ final class Members_Admin_Roles {
|
|
53 |
/**
|
54 |
* Sets up the roles column headers.
|
55 |
*
|
56 |
-
* @since
|
57 |
* @access public
|
58 |
* @param array $columns
|
59 |
* @return array
|
@@ -75,7 +77,7 @@ final class Members_Admin_Roles {
|
|
75 |
/**
|
76 |
* Runs on the `load-{$page}` hook. This is the handler for form submissions and requests.
|
77 |
*
|
78 |
-
* @since
|
79 |
* @access public
|
80 |
* @return void
|
81 |
*/
|
@@ -126,7 +128,7 @@ final class Members_Admin_Roles {
|
|
126 |
if ( members_role_exists( $role ) ) {
|
127 |
|
128 |
// Add role deleted message.
|
129 |
-
add_settings_error( 'members_roles', 'role_deleted', sprintf( esc_html__( '%s role deleted.', 'members' ),
|
130 |
|
131 |
// Delete the role.
|
132 |
members_delete_role( $role );
|
@@ -141,7 +143,7 @@ final class Members_Admin_Roles {
|
|
141 |
/**
|
142 |
* Enqueue scripts/styles.
|
143 |
*
|
144 |
-
* @since
|
145 |
* @access public
|
146 |
* @return void
|
147 |
*/
|
@@ -154,13 +156,13 @@ final class Members_Admin_Roles {
|
|
154 |
/**
|
155 |
* Displays the page content.
|
156 |
*
|
157 |
-
* @since
|
158 |
* @access public
|
159 |
* @return void
|
160 |
*/
|
161 |
public function page() {
|
162 |
|
163 |
-
require_once( members_plugin()->
|
164 |
|
165 |
<div class="wrap">
|
166 |
|
@@ -168,7 +170,7 @@ final class Members_Admin_Roles {
|
|
168 |
<?php esc_html_e( 'Roles', 'members' ); ?>
|
169 |
|
170 |
<?php if ( current_user_can( 'create_roles' ) ) : ?>
|
171 |
-
<a href="<?php echo esc_url( members_get_new_role_url() ); ?>" class="page-title-action"><?php
|
172 |
<?php endif; ?>
|
173 |
</h1>
|
174 |
|
@@ -178,7 +180,7 @@ final class Members_Admin_Roles {
|
|
178 |
|
179 |
<form id="roles" action="<?php echo esc_url( members_get_edit_roles_url() ); ?>" method="post">
|
180 |
|
181 |
-
<?php $table = new
|
182 |
<?php $table->prepare_items(); ?>
|
183 |
<?php $table->display(); ?>
|
184 |
|
@@ -192,7 +194,7 @@ final class Members_Admin_Roles {
|
|
192 |
/**
|
193 |
* Adds help tabs.
|
194 |
*
|
195 |
-
* @since
|
196 |
* @access public
|
197 |
* @return void
|
198 |
*/
|
@@ -244,7 +246,7 @@ final class Members_Admin_Roles {
|
|
244 |
/**
|
245 |
* Overview help tab callback function.
|
246 |
*
|
247 |
-
* @since
|
248 |
* @access public
|
249 |
* @return void
|
250 |
*/
|
@@ -258,7 +260,7 @@ final class Members_Admin_Roles {
|
|
258 |
/**
|
259 |
* Screen content help tab callback function.
|
260 |
*
|
261 |
-
* @since
|
262 |
* @access public
|
263 |
* @return void
|
264 |
*/
|
@@ -277,7 +279,7 @@ final class Members_Admin_Roles {
|
|
277 |
/**
|
278 |
* Row actions help tab callback function.
|
279 |
*
|
280 |
-
* @since
|
281 |
* @access public
|
282 |
* @return void
|
283 |
*/
|
@@ -298,7 +300,7 @@ final class Members_Admin_Roles {
|
|
298 |
/**
|
299 |
* Bulk actions help tab callback function.
|
300 |
*
|
301 |
-
* @since
|
302 |
* @access public
|
303 |
* @return void
|
304 |
*/
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Class that displays the roles admin screen and handles requests for that page.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Roles {
|
22 |
|
23 |
/**
|
24 |
* Sets up some necessary actions/filters.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access public
|
28 |
* @return void
|
29 |
*/
|
42 |
/**
|
43 |
* Modifies the current screen object.
|
44 |
*
|
45 |
+
* @since 2.0.0
|
46 |
* @access public
|
47 |
* @return void
|
48 |
*/
|
55 |
/**
|
56 |
* Sets up the roles column headers.
|
57 |
*
|
58 |
+
* @since 2.0.0
|
59 |
* @access public
|
60 |
* @param array $columns
|
61 |
* @return array
|
77 |
/**
|
78 |
* Runs on the `load-{$page}` hook. This is the handler for form submissions and requests.
|
79 |
*
|
80 |
+
* @since 2.0.0
|
81 |
* @access public
|
82 |
* @return void
|
83 |
*/
|
128 |
if ( members_role_exists( $role ) ) {
|
129 |
|
130 |
// Add role deleted message.
|
131 |
+
add_settings_error( 'members_roles', 'role_deleted', sprintf( esc_html__( '%s role deleted.', 'members' ), members_get_role( $role )->label ), 'updated' );
|
132 |
|
133 |
// Delete the role.
|
134 |
members_delete_role( $role );
|
143 |
/**
|
144 |
* Enqueue scripts/styles.
|
145 |
*
|
146 |
+
* @since 2.0.0
|
147 |
* @access public
|
148 |
* @return void
|
149 |
*/
|
156 |
/**
|
157 |
* Displays the page content.
|
158 |
*
|
159 |
+
* @since 2.0.0
|
160 |
* @access public
|
161 |
* @return void
|
162 |
*/
|
163 |
public function page() {
|
164 |
|
165 |
+
require_once( members_plugin()->dir . 'admin/class-role-list-table.php' ); ?>
|
166 |
|
167 |
<div class="wrap">
|
168 |
|
170 |
<?php esc_html_e( 'Roles', 'members' ); ?>
|
171 |
|
172 |
<?php if ( current_user_can( 'create_roles' ) ) : ?>
|
173 |
+
<a href="<?php echo esc_url( members_get_new_role_url() ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'role', 'members' ); ?></a>
|
174 |
<?php endif; ?>
|
175 |
</h1>
|
176 |
|
180 |
|
181 |
<form id="roles" action="<?php echo esc_url( members_get_edit_roles_url() ); ?>" method="post">
|
182 |
|
183 |
+
<?php $table = new Role_List_Table(); ?>
|
184 |
<?php $table->prepare_items(); ?>
|
185 |
<?php $table->display(); ?>
|
186 |
|
194 |
/**
|
195 |
* Adds help tabs.
|
196 |
*
|
197 |
+
* @since 2.0.0
|
198 |
* @access public
|
199 |
* @return void
|
200 |
*/
|
246 |
/**
|
247 |
* Overview help tab callback function.
|
248 |
*
|
249 |
+
* @since 2.0.0
|
250 |
* @access public
|
251 |
* @return void
|
252 |
*/
|
260 |
/**
|
261 |
* Screen content help tab callback function.
|
262 |
*
|
263 |
+
* @since 2.0.0
|
264 |
* @access public
|
265 |
* @return void
|
266 |
*/
|
279 |
/**
|
280 |
* Row actions help tab callback function.
|
281 |
*
|
282 |
+
* @since 2.0.0
|
283 |
* @access public
|
284 |
* @return void
|
285 |
*/
|
300 |
/**
|
301 |
* Bulk actions help tab callback function.
|
302 |
*
|
303 |
+
* @since 2.0.0
|
304 |
* @access public
|
305 |
* @return void
|
306 |
*/
|
admin/class-settings.php
CHANGED
@@ -4,28 +4,30 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Sets up and handles the plugin settings screen.
|
15 |
*
|
16 |
* @since 1.0.0
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
*
|
24 |
-
* @since
|
25 |
-
* @access
|
26 |
-
* @var
|
27 |
*/
|
28 |
-
|
29 |
|
30 |
/**
|
31 |
* Settings page name.
|
@@ -37,316 +39,227 @@ final class Members_Settings_Page {
|
|
37 |
public $settings_page = '';
|
38 |
|
39 |
/**
|
40 |
-
* Holds an array the
|
41 |
*
|
42 |
-
* @since
|
43 |
* @access public
|
44 |
* @var array
|
45 |
*/
|
46 |
-
public $
|
47 |
|
48 |
/**
|
49 |
-
*
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
* @access public
|
53 |
-
* @return void
|
54 |
-
*/
|
55 |
-
private function __construct() {
|
56 |
-
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Sets up custom admin menus.
|
61 |
*
|
62 |
* @since 1.0.0
|
63 |
* @access public
|
64 |
-
* @return
|
65 |
*/
|
66 |
-
public function
|
67 |
-
|
68 |
-
// Create the settings page.
|
69 |
-
$this->settings_page = add_options_page(
|
70 |
-
esc_html__( 'Members Settings', 'members' ),
|
71 |
-
esc_html_x( 'Members', 'admin screen', 'members' ),
|
72 |
-
apply_filters( 'members_settings_capability', 'manage_options' ),
|
73 |
-
'members-settings',
|
74 |
-
array( $this, 'settings_page' )
|
75 |
-
);
|
76 |
-
|
77 |
-
if ( $this->settings_page ) {
|
78 |
-
|
79 |
-
// Register setings.
|
80 |
-
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
81 |
|
82 |
-
|
83 |
-
add_action( "load-{$this->settings_page}", array( $this, 'add_help_tabs' ) );
|
84 |
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
}
|
|
|
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
*
|
92 |
*
|
93 |
* @since 1.0.0
|
94 |
* @access public
|
95 |
-
* @param string $hook_suffix
|
96 |
* @return void
|
97 |
*/
|
98 |
-
|
99 |
-
|
100 |
-
if ( $this->settings_page !== $hook_suffix )
|
101 |
-
return;
|
102 |
-
|
103 |
-
wp_enqueue_script( 'members-settings' );
|
104 |
-
}
|
105 |
|
106 |
/**
|
107 |
-
*
|
108 |
*
|
109 |
-
* @since
|
110 |
-
* @access
|
111 |
* @return void
|
112 |
*/
|
113 |
-
function
|
114 |
-
|
115 |
-
// Get the current plugin settings w/o the defaults.
|
116 |
-
$this->settings = get_option( 'members_settings' );
|
117 |
-
|
118 |
-
// Register the setting.
|
119 |
-
register_setting( 'members_settings', 'members_settings', array( $this, 'validate_settings' ) );
|
120 |
-
|
121 |
-
/* === Settings Sections === */
|
122 |
|
123 |
-
//
|
124 |
-
|
125 |
-
add_settings_section( 'content_permissions', esc_html__( 'Content Permissions', 'members' ), '__return_false', $this->settings_page );
|
126 |
-
add_settings_section( 'sidebar_widgets', esc_html__( 'Sidebar Widgets', 'members' ), '__return_false', $this->settings_page );
|
127 |
-
add_settings_section( 'private_site', esc_html__( 'Private Site', 'members' ), '__return_false', $this->settings_page );
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
add_settings_field( 'explicit_denied_caps', esc_html__( 'Capabilities', 'members' ), array( $this, 'field_explicit_denied_caps' ), $this->settings_page, 'roles_caps' );
|
134 |
-
add_settings_field( 'enable_multi_roles', esc_html__( 'Multiple User Roles', 'members' ), array( $this, 'field_enable_multi_roles' ), $this->settings_page, 'roles_caps' );
|
135 |
-
|
136 |
-
// Content permissions fields.
|
137 |
-
add_settings_field( 'enable_content_permissions', esc_html__( 'Enable Permissions', 'members' ), array( $this, 'field_enable_content_permissions' ), $this->settings_page, 'content_permissions' );
|
138 |
-
add_settings_field( 'content_permissions_error', esc_html__( 'Error Message', 'members' ), array( $this, 'field_content_permissions_error' ), $this->settings_page, 'content_permissions' );
|
139 |
-
|
140 |
-
// Widgets fields.
|
141 |
-
add_settings_field( 'widget_login', esc_html__( 'Login Widget', 'members' ), array( $this, 'field_widget_login' ), $this->settings_page, 'sidebar_widgets' );
|
142 |
-
add_settings_field( 'widget_users', esc_html__( 'Users Widget', 'members' ), array( $this, 'field_widget_users' ), $this->settings_page, 'sidebar_widgets' );
|
143 |
-
|
144 |
-
// Private site fields.
|
145 |
-
add_settings_field( 'enable_private_site', esc_html__( 'Enable Private Site', 'members' ), array( $this, 'field_enable_private_site' ), $this->settings_page, 'private_site' );
|
146 |
-
add_settings_field( 'enable_private_feed', esc_html__( 'Disable Feed', 'members' ), array( $this, 'field_enable_private_feed' ), $this->settings_page, 'private_site' );
|
147 |
-
add_settings_field( 'private_feed_error', esc_html__( 'Feed Error Message', 'members' ), array( $this, 'field_private_feed_error' ), $this->settings_page, 'private_site' );
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
-
*
|
152 |
*
|
153 |
-
* @since
|
154 |
-
* @access
|
155 |
-
* @param array $input
|
156 |
-
* @return array
|
157 |
-
*/
|
158 |
-
function validate_settings( $settings ) {
|
159 |
-
|
160 |
-
// Validate true/false checkboxes.
|
161 |
-
$settings['role_manager'] = ! empty( $settings['role_manager'] ) ? true : false;
|
162 |
-
$settings['explicit_denied_caps'] = ! empty( $settings['explicit_denied_caps'] ) ? true : false;
|
163 |
-
$settings['multi_roles'] = ! empty( $settings['multi_roles'] ) ? true : false;
|
164 |
-
$settings['content_permissions'] = ! empty( $settings['content_permissions'] ) ? true : false;
|
165 |
-
$settings['login_form_widget'] = ! empty( $settings['login_form_widget'] ) ? true : false;
|
166 |
-
$settings['users_widget'] = ! empty( $settings['users_widget'] ) ? true : false;
|
167 |
-
$settings['private_blog'] = ! empty( $settings['private_blog'] ) ? true : false;
|
168 |
-
$settings['private_feed'] = ! empty( $settings['private_feed'] ) ? true : false;
|
169 |
-
|
170 |
-
// Kill evil scripts.
|
171 |
-
$settings['content_permissions_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['content_permissions_error'] ) ) );
|
172 |
-
$settings['private_feed_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['private_feed_error'] ) ) );
|
173 |
-
|
174 |
-
// Return the validated/sanitized settings.
|
175 |
-
return $settings;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Role/Caps section callback.
|
180 |
-
*
|
181 |
-
* @since 1.0.0
|
182 |
-
* @access public
|
183 |
* @return void
|
184 |
*/
|
185 |
-
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
</p>
|
190 |
-
<?php }
|
191 |
|
192 |
/**
|
193 |
-
*
|
194 |
*
|
195 |
-
* @since
|
196 |
* @access public
|
|
|
197 |
* @return void
|
198 |
*/
|
199 |
-
public function
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
</label>
|
205 |
-
<?php }
|
206 |
|
207 |
/**
|
208 |
-
*
|
209 |
*
|
210 |
-
* @since
|
211 |
* @access public
|
|
|
212 |
* @return void
|
213 |
*/
|
214 |
-
public function
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
</label>
|
220 |
-
<?php }
|
221 |
|
222 |
/**
|
223 |
-
*
|
224 |
*
|
225 |
-
* @since
|
226 |
* @access public
|
227 |
-
* @
|
|
|
228 |
*/
|
229 |
-
public function
|
230 |
|
231 |
-
|
232 |
-
|
233 |
-
<?php esc_html_e( 'Allow users to be assigned more than a single role.', 'members' ); ?>
|
234 |
-
</label>
|
235 |
-
<?php }
|
236 |
|
237 |
/**
|
238 |
-
*
|
239 |
*
|
240 |
-
* @since
|
241 |
* @access public
|
242 |
-
* @
|
|
|
243 |
*/
|
244 |
-
public function
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
<?php esc_html_e( 'Enable the content permissions feature.', 'members' ); ?>
|
249 |
-
</label>
|
250 |
-
<?php }
|
251 |
|
252 |
/**
|
253 |
-
*
|
254 |
*
|
255 |
* @since 1.0.0
|
256 |
* @access public
|
257 |
* @return void
|
258 |
*/
|
259 |
-
public function
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
'
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
)
|
269 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
-
*
|
274 |
*
|
275 |
-
* @since
|
276 |
* @access public
|
277 |
* @return void
|
278 |
*/
|
279 |
-
public function
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
<?php esc_html_e( 'Enable the login form widget.', 'members' ); ?>
|
284 |
-
</label>
|
285 |
-
<?php }
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
*
|
290 |
-
* @since 1.0.0
|
291 |
-
* @access public
|
292 |
-
* @return void
|
293 |
-
*/
|
294 |
-
public function field_widget_users() { ?>
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
|
302 |
/**
|
303 |
-
*
|
304 |
*
|
305 |
-
* @since
|
306 |
* @access public
|
307 |
* @return void
|
308 |
*/
|
309 |
-
public function
|
310 |
|
311 |
-
<
|
312 |
-
|
313 |
-
|
314 |
-
</label>
|
315 |
<?php }
|
316 |
|
317 |
/**
|
318 |
-
*
|
319 |
*
|
320 |
* @since 1.0.0
|
321 |
* @access public
|
|
|
322 |
* @return void
|
323 |
*/
|
324 |
-
public function
|
325 |
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
331 |
|
332 |
/**
|
333 |
-
*
|
334 |
*
|
335 |
* @since 1.0.0
|
336 |
* @access public
|
337 |
* @return void
|
338 |
*/
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
'members_settings_private_feed_error',
|
344 |
-
array(
|
345 |
-
'textarea_name' => 'members_settings[private_feed_error]',
|
346 |
-
'drag_drop_upload' => true,
|
347 |
-
'editor_height' => 250
|
348 |
-
)
|
349 |
-
);
|
350 |
}
|
351 |
|
352 |
/**
|
@@ -359,152 +272,57 @@ final class Members_Settings_Page {
|
|
359 |
public function settings_page() { ?>
|
360 |
|
361 |
<div class="wrap">
|
362 |
-
<h1><?php
|
|
|
|
|
|
|
|
|
363 |
|
364 |
-
|
365 |
-
<?php settings_fields( 'members_settings' ); ?>
|
366 |
-
<?php do_settings_sections( $this->settings_page ); ?>
|
367 |
-
<?php submit_button( esc_attr__( 'Update Settings', 'members' ), 'primary' ); ?>
|
368 |
-
</form>
|
369 |
|
370 |
</div><!-- wrap -->
|
371 |
<?php }
|
372 |
|
373 |
/**
|
374 |
-
*
|
375 |
-
*
|
376 |
-
* @since 1.0.0
|
377 |
-
* @access public
|
378 |
-
* @return void
|
379 |
-
*/
|
380 |
-
public function add_help_tabs() {
|
381 |
-
|
382 |
-
// Get the current screen.
|
383 |
-
$screen = get_current_screen();
|
384 |
-
|
385 |
-
// Roles/Caps help tab.
|
386 |
-
$screen->add_help_tab(
|
387 |
-
array(
|
388 |
-
'id' => 'roles-caps',
|
389 |
-
'title' => esc_html__( 'Role and Capabilities', 'members' ),
|
390 |
-
'callback' => array( $this, 'help_tab_roles_caps' )
|
391 |
-
)
|
392 |
-
);
|
393 |
-
|
394 |
-
// Content Permissions help tab.
|
395 |
-
$screen->add_help_tab(
|
396 |
-
array(
|
397 |
-
'id' => 'content-permissions',
|
398 |
-
'title' => esc_html__( 'Content Permissions', 'members' ),
|
399 |
-
'callback' => array( $this, 'help_tab_content_permissions' )
|
400 |
-
)
|
401 |
-
);
|
402 |
-
|
403 |
-
// Widgets help tab.
|
404 |
-
$screen->add_help_tab(
|
405 |
-
array(
|
406 |
-
'id' => 'sidebar-widgets',
|
407 |
-
'title' => esc_html__( 'Sidebar Widgets', 'members' ),
|
408 |
-
'callback' => array( $this, 'help_tab_sidebar_widgets' )
|
409 |
-
)
|
410 |
-
);
|
411 |
-
|
412 |
-
// Private Site help tab.
|
413 |
-
$screen->add_help_tab(
|
414 |
-
array(
|
415 |
-
'id' => 'private-site',
|
416 |
-
'title' => esc_html__( 'Private Site', 'members' ),
|
417 |
-
'callback' => array( $this, 'help_tab_private_site' )
|
418 |
-
)
|
419 |
-
);
|
420 |
-
|
421 |
-
// Get docs and help links.
|
422 |
-
$docs_link = sprintf( '<li><a href="https://github.com/justintadlock/members/blob/master/readme.md">%s</a></li>', esc_html__( 'Documentation', 'members' ) );
|
423 |
-
$help_link = sprintf( '<li><a href="http://themehybrid.com/board/topics">%s</a></li>', esc_html__( 'Support Forums', 'members' ) );
|
424 |
-
$tut_link = sprintf( '<li><a href="http://justintadlock.com/archives/2009/08/30/users-roles-and-capabilities-in-wordpress">%s</a></li>', esc_html__( 'Users, Roles, and Capabilities', 'members' ) );
|
425 |
-
|
426 |
-
// Set the help sidebar.
|
427 |
-
$screen->set_help_sidebar( members_get_help_sidebar_text() );
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Displays the roles/caps help tab.
|
432 |
*
|
433 |
-
* @since
|
434 |
* @access public
|
435 |
* @return void
|
436 |
*/
|
437 |
-
|
438 |
|
439 |
-
<
|
440 |
-
<?php esc_html_e( 'The role manager allows you to manage roles on your site by giving you the ability to create, edit, and delete any role. Note that changes to roles do not change settings for the Members plugin. You are literally changing data in your WordPress database. This plugin feature merely provides an interface for you to make these changes.', 'members' ); ?>
|
441 |
-
</p>
|
442 |
|
443 |
-
|
444 |
-
<?php esc_html_e( 'Tick the checkbox for denied capabilities to always take precedence over granted capabilities when there is a conflict. This is only relevant when using multiple roles per user.', 'members' ); ?>
|
445 |
-
</p>
|
446 |
|
447 |
-
|
448 |
-
|
449 |
-
</p>
|
450 |
-
<?php }
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
*
|
455 |
-
* @since 1.0.0
|
456 |
-
* @access public
|
457 |
-
* @return void
|
458 |
-
*/
|
459 |
-
public function help_tab_content_permissions() { ?>
|
460 |
|
461 |
-
|
462 |
-
|
463 |
-
</p>
|
464 |
-
<?php }
|
465 |
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
* @since 1.0.0
|
470 |
-
* @access public
|
471 |
-
* @return void
|
472 |
-
*/
|
473 |
-
public function help_tab_sidebar_widgets() { ?>
|
474 |
|
475 |
-
|
476 |
-
<?php esc_html_e( "The sidebar widgets feature adds additional widgets for use in your theme's sidebars.", 'members' ); ?>
|
477 |
-
</p>
|
478 |
-
<?php }
|
479 |
-
|
480 |
-
/**
|
481 |
-
* Displays the private site help tab.
|
482 |
-
*
|
483 |
-
* @since 1.0.0
|
484 |
-
* @access public
|
485 |
-
* @return void
|
486 |
-
*/
|
487 |
-
public function help_tab_private_site() { ?>
|
488 |
|
489 |
-
|
490 |
-
<?php esc_html_e( 'The private site feature redirects all users who are not logged into the site to the login page, creating an entirely private site. You may also replace your feed content with a custom error message.', 'members' ); ?>
|
491 |
-
</p>
|
492 |
<?php }
|
493 |
|
494 |
/**
|
495 |
-
*
|
496 |
*
|
497 |
-
* @since
|
498 |
-
* @
|
499 |
-
* @
|
|
|
500 |
*/
|
501 |
-
public
|
502 |
-
|
503 |
-
if ( ! self::$instance )
|
504 |
-
self::$instance = new self;
|
505 |
-
|
506 |
-
return self::$instance;
|
507 |
-
}
|
508 |
}
|
509 |
|
510 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Sets up and handles the plugin settings screen.
|
17 |
*
|
18 |
* @since 1.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Settings_Page {
|
22 |
|
23 |
/**
|
24 |
+
* Admin page name/ID.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
+
* @var string
|
29 |
*/
|
30 |
+
public $name = 'members-settings';
|
31 |
|
32 |
/**
|
33 |
* Settings page name.
|
39 |
public $settings_page = '';
|
40 |
|
41 |
/**
|
42 |
+
* Holds an array the settings page views.
|
43 |
*
|
44 |
+
* @since 2.0.0
|
45 |
* @access public
|
46 |
* @var array
|
47 |
*/
|
48 |
+
public $views = array();
|
49 |
|
50 |
/**
|
51 |
+
* Returns the instance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
*
|
53 |
* @since 1.0.0
|
54 |
* @access public
|
55 |
+
* @return object
|
56 |
*/
|
57 |
+
public static function get_instance() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
static $instance = null;
|
|
|
60 |
|
61 |
+
if ( is_null( $instance ) ) {
|
62 |
+
$instance = new self;
|
63 |
+
$instance->includes();
|
64 |
+
$instance->setup_actions();
|
65 |
}
|
66 |
+
|
67 |
+
return $instance;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Constructor method.
|
72 |
*
|
73 |
* @since 1.0.0
|
74 |
* @access public
|
|
|
75 |
* @return void
|
76 |
*/
|
77 |
+
private function __construct() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
/**
|
80 |
+
* Loads settings files.
|
81 |
*
|
82 |
+
* @since 2.0.0
|
83 |
+
* @access private
|
84 |
* @return void
|
85 |
*/
|
86 |
+
private function includes() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
// Include the settings functions.
|
89 |
+
require_once( members_plugin()->dir . 'admin/functions-settings.php' );
|
|
|
|
|
|
|
90 |
|
91 |
+
// Load settings view classes.
|
92 |
+
require_once( members_plugin()->dir . 'admin/views/class-view.php' );
|
93 |
+
require_once( members_plugin()->dir . 'admin/views/class-view-general.php' );
|
94 |
+
require_once( members_plugin()->dir . 'admin/views/class-view-addons.php' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Sets up initial actions.
|
99 |
*
|
100 |
+
* @since 2.0.0
|
101 |
+
* @access private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
* @return void
|
103 |
*/
|
104 |
+
private function setup_actions() {
|
105 |
|
106 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
107 |
+
}
|
|
|
|
|
108 |
|
109 |
/**
|
110 |
+
* Register a view.
|
111 |
*
|
112 |
+
* @since 2.0.0
|
113 |
* @access public
|
114 |
+
* @param object $view
|
115 |
* @return void
|
116 |
*/
|
117 |
+
public function register_view( $view ) {
|
118 |
|
119 |
+
if ( ! $this->view_exists( $view->name ) )
|
120 |
+
$this->views[ $view->name ] = $view;
|
121 |
+
}
|
|
|
|
|
122 |
|
123 |
/**
|
124 |
+
* Unregister a view.
|
125 |
*
|
126 |
+
* @since 2.0.0
|
127 |
* @access public
|
128 |
+
* @param string $name
|
129 |
* @return void
|
130 |
*/
|
131 |
+
public function unregister_view( $name ) {
|
132 |
|
133 |
+
if ( $this->view_exists( $name ) )
|
134 |
+
unset( $this->view[ $name ] );
|
135 |
+
}
|
|
|
|
|
136 |
|
137 |
/**
|
138 |
+
* Get a view object
|
139 |
*
|
140 |
+
* @since 2.0.0
|
141 |
* @access public
|
142 |
+
* @param string $name
|
143 |
+
* @return object
|
144 |
*/
|
145 |
+
public function get_view( $name ) {
|
146 |
|
147 |
+
return $this->view_exists( $name ) ? $this->views[ $name ] : false;
|
148 |
+
}
|
|
|
|
|
|
|
149 |
|
150 |
/**
|
151 |
+
* Check if a view exists.
|
152 |
*
|
153 |
+
* @since 2.0.0
|
154 |
* @access public
|
155 |
+
* @param string $name
|
156 |
+
* @return bool
|
157 |
*/
|
158 |
+
public function view_exists( $name ) {
|
159 |
|
160 |
+
return isset( $this->views[ $name ] );
|
161 |
+
}
|
|
|
|
|
|
|
162 |
|
163 |
/**
|
164 |
+
* Sets up custom admin menus.
|
165 |
*
|
166 |
* @since 1.0.0
|
167 |
* @access public
|
168 |
* @return void
|
169 |
*/
|
170 |
+
public function admin_menu() {
|
171 |
+
|
172 |
+
// Create the settings page.
|
173 |
+
$this->settings_page = add_options_page(
|
174 |
+
esc_html_x( 'Members', 'admin screen', 'members' ),
|
175 |
+
esc_html_x( 'Members', 'admin screen', 'members' ),
|
176 |
+
apply_filters( 'members_settings_capability', 'manage_options' ),
|
177 |
+
$this->name,
|
178 |
+
array( $this, 'settings_page' )
|
|
|
179 |
);
|
180 |
+
|
181 |
+
if ( $this->settings_page ) {
|
182 |
+
|
183 |
+
do_action( 'members_register_settings_views', $this );
|
184 |
+
|
185 |
+
uasort( $this->views, 'members_priority_sort' );
|
186 |
+
|
187 |
+
// Register setings.
|
188 |
+
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
189 |
+
|
190 |
+
// Page load callback.
|
191 |
+
add_action( "load-{$this->settings_page}", array( $this, 'load' ) );
|
192 |
+
|
193 |
+
// Enqueue scripts/styles.
|
194 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
195 |
+
}
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
+
* Runs on page load.
|
200 |
*
|
201 |
+
* @since 2.0.0
|
202 |
* @access public
|
203 |
* @return void
|
204 |
*/
|
205 |
+
public function load() {
|
206 |
|
207 |
+
// Print custom styles.
|
208 |
+
add_action( 'admin_head', array( $this, 'print_styles' ) );
|
|
|
|
|
|
|
209 |
|
210 |
+
// Add help tabs for the current view.
|
211 |
+
$view = $this->get_view( members_get_current_settings_view() );
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
+
if ( $view ) {
|
214 |
+
$view->load();
|
215 |
+
$view->add_help_tabs();
|
216 |
+
}
|
217 |
+
}
|
218 |
|
219 |
/**
|
220 |
+
* Print styles to the header.
|
221 |
*
|
222 |
+
* @since 2.0.0
|
223 |
* @access public
|
224 |
* @return void
|
225 |
*/
|
226 |
+
public function print_styles() { ?>
|
227 |
|
228 |
+
<style type="text/css">
|
229 |
+
.settings_page_members-settings .wp-filter { margin-bottom: 15px; }
|
230 |
+
</style>
|
|
|
231 |
<?php }
|
232 |
|
233 |
/**
|
234 |
+
* Enqueue scripts/styles.
|
235 |
*
|
236 |
* @since 1.0.0
|
237 |
* @access public
|
238 |
+
* @param string $hook_suffix
|
239 |
* @return void
|
240 |
*/
|
241 |
+
public function enqueue( $hook_suffix ) {
|
242 |
|
243 |
+
if ( $this->settings_page !== $hook_suffix )
|
244 |
+
return;
|
245 |
+
|
246 |
+
$view = $this->get_view( members_get_current_settings_view() );
|
247 |
+
|
248 |
+
if ( $view )
|
249 |
+
$view->enqueue();
|
250 |
+
}
|
251 |
|
252 |
/**
|
253 |
+
* Registers the plugin settings.
|
254 |
*
|
255 |
* @since 1.0.0
|
256 |
* @access public
|
257 |
* @return void
|
258 |
*/
|
259 |
+
function register_settings() {
|
260 |
+
|
261 |
+
foreach ( $this->views as $view )
|
262 |
+
$view->register_settings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
264 |
|
265 |
/**
|
272 |
public function settings_page() { ?>
|
273 |
|
274 |
<div class="wrap">
|
275 |
+
<h1><?php echo esc_html_x( 'Members', 'admin screen', 'members' ); ?></h1>
|
276 |
+
|
277 |
+
<div class="wp-filter">
|
278 |
+
<?php $this->filter_links(); ?>
|
279 |
+
</div>
|
280 |
|
281 |
+
<?php $this->get_view( members_get_current_settings_view() )->template(); ?>
|
|
|
|
|
|
|
|
|
282 |
|
283 |
</div><!-- wrap -->
|
284 |
<?php }
|
285 |
|
286 |
/**
|
287 |
+
* Outputs the list of views.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
*
|
289 |
+
* @since 2.0.0
|
290 |
* @access public
|
291 |
* @return void
|
292 |
*/
|
293 |
+
private function filter_links() { ?>
|
294 |
|
295 |
+
<ul class="filter-links">
|
|
|
|
|
296 |
|
297 |
+
<?php foreach ( $this->views as $view ) :
|
|
|
|
|
298 |
|
299 |
+
// Determine current class.
|
300 |
+
$class = $view->name === members_get_current_settings_view() ? 'class="current"' : '';
|
|
|
|
|
301 |
|
302 |
+
// Get the URL.
|
303 |
+
$url = members_get_settings_view_url( $view->name );
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
+
if ( 'general' === $view->name )
|
306 |
+
$url = remove_query_arg( 'view', $url ); ?>
|
|
|
|
|
307 |
|
308 |
+
<li class="<?php echo sanitize_html_class( $view->name ); ?>">
|
309 |
+
<a href="<?php echo esc_url( $url ); ?>" <?php echo $class; ?>><?php echo esc_html( $view->label ); ?></a>
|
310 |
+
</li>
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
+
<?php endforeach; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
|
314 |
+
</ul>
|
|
|
|
|
315 |
<?php }
|
316 |
|
317 |
/**
|
318 |
+
* Adds help tabs.
|
319 |
*
|
320 |
+
* @since 1.0.0
|
321 |
+
* @deprecated 2.0.0
|
322 |
+
* @access public
|
323 |
+
* @return void
|
324 |
*/
|
325 |
+
public function add_help_tabs() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
327 |
|
328 |
+
Settings_Page::get_instance();
|
admin/class-user-edit.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Edit user screen class.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Holds the instances of this class.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access private
|
26 |
* @var object
|
27 |
*/
|
@@ -30,7 +32,7 @@ final class Members_Admin_User_Edit {
|
|
30 |
/**
|
31 |
* Sets up needed actions/filters for the admin to initialize.
|
32 |
*
|
33 |
-
* @since
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
@@ -47,25 +49,28 @@ final class Members_Admin_User_Edit {
|
|
47 |
/**
|
48 |
* Adds actions/filters on load.
|
49 |
*
|
50 |
-
* @since
|
51 |
* @access public
|
52 |
* @return void
|
53 |
*/
|
54 |
public function load_user_edit() {
|
55 |
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
add_action( 'show_user_profile', array( $this, 'profile_fields' ) );
|
59 |
add_action( 'edit_user_profile', array( $this, 'profile_fields' ) );
|
60 |
|
61 |
// Must use `profile_update` to change role. Otherwise, WP will wipe it out.
|
62 |
-
add_action( 'profile_update', array( $this, 'role_update' ) );
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
* Adds custom profile fields.
|
67 |
*
|
68 |
-
* @since
|
69 |
* @access public
|
70 |
* @param object $user
|
71 |
* @return void
|
@@ -78,13 +83,13 @@ final class Members_Admin_User_Edit {
|
|
78 |
|
79 |
$user_roles = (array) $user->roles;
|
80 |
|
81 |
-
$
|
82 |
|
83 |
-
|
84 |
|
85 |
wp_nonce_field( 'new_user_roles', 'members_new_user_roles_nonce' ); ?>
|
86 |
|
87 |
-
<
|
88 |
|
89 |
<table class="form-table">
|
90 |
|
@@ -92,16 +97,22 @@ final class Members_Admin_User_Edit {
|
|
92 |
<th><?php esc_html_e( 'User Roles', 'members' ); ?></th>
|
93 |
|
94 |
<td>
|
95 |
-
<
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
</td>
|
106 |
</tr>
|
107 |
|
@@ -113,12 +124,13 @@ final class Members_Admin_User_Edit {
|
|
113 |
* on a different hook, `profile_update`. Using the normal hooks on the edit user screen won't work
|
114 |
* because WP will wipe out the role.
|
115 |
*
|
116 |
-
* @since
|
117 |
* @access public
|
118 |
* @param int $user_id
|
|
|
119 |
* @return void
|
120 |
*/
|
121 |
-
public function role_update( $user_id ) {
|
122 |
|
123 |
// If the current user can't promote users or edit this particular user, bail.
|
124 |
if ( ! current_user_can( 'promote_users' ) || ! current_user_can( 'edit_user', $user_id ) )
|
@@ -129,13 +141,13 @@ final class Members_Admin_User_Edit {
|
|
129 |
return;
|
130 |
|
131 |
// Create a new user object.
|
132 |
-
|
133 |
|
134 |
// If we have an array of roles.
|
135 |
if ( ! empty( $_POST['members_user_roles'] ) ) {
|
136 |
|
137 |
// Get the current user roles.
|
138 |
-
$old_roles = (array) $
|
139 |
|
140 |
// Sanitize the posted roles.
|
141 |
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
@@ -144,8 +156,8 @@ final class Members_Admin_User_Edit {
|
|
144 |
foreach ( $new_roles as $new_role ) {
|
145 |
|
146 |
// If the user doesn't already have the role, add it.
|
147 |
-
if ( members_is_role_editable( $new_role ) && ! in_array( $new_role, (array) $
|
148 |
-
$
|
149 |
}
|
150 |
|
151 |
// Loop through the current user roles.
|
@@ -153,7 +165,7 @@ final class Members_Admin_User_Edit {
|
|
153 |
|
154 |
// If the role is editable and not in the new roles array, remove it.
|
155 |
if ( members_is_role_editable( $old_role ) && ! in_array( $old_role, $new_roles ) )
|
156 |
-
$
|
157 |
}
|
158 |
|
159 |
// If the posted roles are empty.
|
@@ -164,15 +176,45 @@ final class Members_Admin_User_Edit {
|
|
164 |
|
165 |
// Remove the role if it is editable.
|
166 |
if ( members_is_role_editable( $old_role ) )
|
167 |
-
$
|
168 |
}
|
169 |
}
|
170 |
}
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
/**
|
173 |
* Enqueue the plugin admin CSS.
|
174 |
*
|
175 |
-
* @since
|
176 |
* @access public
|
177 |
* @return void
|
178 |
*/
|
@@ -185,7 +227,7 @@ final class Members_Admin_User_Edit {
|
|
185 |
/**
|
186 |
* Returns the instance.
|
187 |
*
|
188 |
-
* @since
|
189 |
* @access public
|
190 |
* @return object
|
191 |
*/
|
@@ -198,4 +240,4 @@ final class Members_Admin_User_Edit {
|
|
198 |
}
|
199 |
}
|
200 |
|
201 |
-
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
/**
|
16 |
* Edit user screen class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class User_Edit {
|
22 |
|
23 |
/**
|
24 |
* Holds the instances of this class.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access private
|
28 |
* @var object
|
29 |
*/
|
32 |
/**
|
33 |
* Sets up needed actions/filters for the admin to initialize.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @return void
|
38 |
*/
|
49 |
/**
|
50 |
* Adds actions/filters on load.
|
51 |
*
|
52 |
+
* @since 2.0.0
|
53 |
* @access public
|
54 |
* @return void
|
55 |
*/
|
56 |
public function load_user_edit() {
|
57 |
|
58 |
+
// Handle scripts and styles.
|
59 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
60 |
+
add_action( 'admin_footer', array( $this, 'print_scripts' ), 25 );
|
61 |
+
add_action( 'admin_head', array( $this, 'print_styles' ) );
|
62 |
|
63 |
add_action( 'show_user_profile', array( $this, 'profile_fields' ) );
|
64 |
add_action( 'edit_user_profile', array( $this, 'profile_fields' ) );
|
65 |
|
66 |
// Must use `profile_update` to change role. Otherwise, WP will wipe it out.
|
67 |
+
add_action( 'profile_update', array( $this, 'role_update' ), 10, 2 );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
* Adds custom profile fields.
|
72 |
*
|
73 |
+
* @since 2.0.0
|
74 |
* @access public
|
75 |
* @param object $user
|
76 |
* @return void
|
83 |
|
84 |
$user_roles = (array) $user->roles;
|
85 |
|
86 |
+
$roles = members_get_roles();
|
87 |
|
88 |
+
ksort( $roles );
|
89 |
|
90 |
wp_nonce_field( 'new_user_roles', 'members_new_user_roles_nonce' ); ?>
|
91 |
|
92 |
+
<h2><?php esc_html_e( 'Roles', 'members' ); ?></h2>
|
93 |
|
94 |
<table class="form-table">
|
95 |
|
97 |
<th><?php esc_html_e( 'User Roles', 'members' ); ?></th>
|
98 |
|
99 |
<td>
|
100 |
+
<div class="wp-tab-panel">
|
101 |
+
<ul>
|
102 |
+
<?php foreach ( $roles as $role ) : ?>
|
103 |
+
|
104 |
+
<?php if ( members_is_role_editable( $role->name ) ) :?>
|
105 |
+
<li>
|
106 |
+
<label>
|
107 |
+
<input type="checkbox" name="members_user_roles[]" value="<?php echo esc_attr( $role->name ); ?>" <?php checked( in_array( $role->name, $user_roles ) ); ?> />
|
108 |
+
<?php echo esc_html( $role->label ); ?>
|
109 |
+
</label>
|
110 |
+
</li>
|
111 |
+
<?php endif; ?>
|
112 |
+
|
113 |
+
<?php endforeach; ?>
|
114 |
+
</ul>
|
115 |
+
</div>
|
116 |
</td>
|
117 |
</tr>
|
118 |
|
124 |
* on a different hook, `profile_update`. Using the normal hooks on the edit user screen won't work
|
125 |
* because WP will wipe out the role.
|
126 |
*
|
127 |
+
* @since 2.0.0
|
128 |
* @access public
|
129 |
* @param int $user_id
|
130 |
+
* @param object $old_user_data
|
131 |
* @return void
|
132 |
*/
|
133 |
+
public function role_update( $user_id, $old_user_data ) {
|
134 |
|
135 |
// If the current user can't promote users or edit this particular user, bail.
|
136 |
if ( ! current_user_can( 'promote_users' ) || ! current_user_can( 'edit_user', $user_id ) )
|
141 |
return;
|
142 |
|
143 |
// Create a new user object.
|
144 |
+
//$user = new WP_User( $user_id );
|
145 |
|
146 |
// If we have an array of roles.
|
147 |
if ( ! empty( $_POST['members_user_roles'] ) ) {
|
148 |
|
149 |
// Get the current user roles.
|
150 |
+
$old_roles = (array) $old_user_data->roles;
|
151 |
|
152 |
// Sanitize the posted roles.
|
153 |
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
156 |
foreach ( $new_roles as $new_role ) {
|
157 |
|
158 |
// If the user doesn't already have the role, add it.
|
159 |
+
if ( members_is_role_editable( $new_role ) && ! in_array( $new_role, (array) $old_user_data->roles ) )
|
160 |
+
$old_user_data->add_role( $new_role );
|
161 |
}
|
162 |
|
163 |
// Loop through the current user roles.
|
165 |
|
166 |
// If the role is editable and not in the new roles array, remove it.
|
167 |
if ( members_is_role_editable( $old_role ) && ! in_array( $old_role, $new_roles ) )
|
168 |
+
$old_user_data->remove_role( $old_role );
|
169 |
}
|
170 |
|
171 |
// If the posted roles are empty.
|
176 |
|
177 |
// Remove the role if it is editable.
|
178 |
if ( members_is_role_editable( $old_role ) )
|
179 |
+
$old_user_data->remove_role( $old_role );
|
180 |
}
|
181 |
}
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
+
* Enqueue scripts.
|
186 |
+
*
|
187 |
+
* @since 2.0.0
|
188 |
+
* @access public
|
189 |
+
* @return void
|
190 |
+
*/
|
191 |
+
public function enqueue() {
|
192 |
+
|
193 |
+
wp_enqueue_script( 'jquery' );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Enqueue the plugin admin CSS.
|
198 |
+
*
|
199 |
+
* @since 2.0.0
|
200 |
+
* @access public
|
201 |
+
* @return void
|
202 |
+
*/
|
203 |
+
public function print_scripts() { ?>
|
204 |
+
|
205 |
+
<script>
|
206 |
+
jQuery( document ).ready( function() {
|
207 |
+
|
208 |
+
jQuery( '.user-role-wrap' ).remove();
|
209 |
+
} );
|
210 |
+
</script>
|
211 |
+
|
212 |
+
<?php }
|
213 |
+
|
214 |
/**
|
215 |
* Enqueue the plugin admin CSS.
|
216 |
*
|
217 |
+
* @since 2.0.0
|
218 |
* @access public
|
219 |
* @return void
|
220 |
*/
|
227 |
/**
|
228 |
* Returns the instance.
|
229 |
*
|
230 |
+
* @since 2.0.0
|
231 |
* @access public
|
232 |
* @return object
|
233 |
*/
|
240 |
}
|
241 |
}
|
242 |
|
243 |
+
User_Edit::get_instance();
|
admin/class-user-new.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles custom functionality on the new user screen, such as multiple user roles.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Edit user screen class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
final class User_New {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Holds the instances of this class.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access private
|
28 |
+
* @var object
|
29 |
+
*/
|
30 |
+
private static $instance;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor method.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access private
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
private function __construct() {}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Sets up needed actions/filters for the admin to initialize.
|
43 |
+
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access private
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
private function setup_actions() {
|
49 |
+
|
50 |
+
// If multiple roles per user is not enabled, bail.
|
51 |
+
if ( ! members_multiple_user_roles_enabled() )
|
52 |
+
return;
|
53 |
+
|
54 |
+
// Only run our customization on the 'user-edit.php' page in the admin.
|
55 |
+
add_action( 'load-user-new.php', array( $this, 'load' ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Adds actions/filters on load.
|
60 |
+
*
|
61 |
+
* @since 2.0.0
|
62 |
+
* @access public
|
63 |
+
* @return void
|
64 |
+
*/
|
65 |
+
public function load() {
|
66 |
+
|
67 |
+
// Adds the profile fields.
|
68 |
+
add_action( 'user_new_form', array( $this, 'profile_fields' ) );
|
69 |
+
|
70 |
+
// Sets the new user's roles.
|
71 |
+
add_action( 'user_register', array( $this, 'user_register' ) );
|
72 |
+
|
73 |
+
// Handle scripts.
|
74 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
75 |
+
add_action( 'admin_footer', array( $this, 'print_scripts' ), 25 );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Adds custom profile fields.
|
80 |
+
*
|
81 |
+
* @since 2.0.0
|
82 |
+
* @access public
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
public function profile_fields() {
|
86 |
+
|
87 |
+
if ( ! current_user_can( 'promote_users' ) )
|
88 |
+
return;
|
89 |
+
|
90 |
+
// Get the default user roles.
|
91 |
+
$new_user_roles = apply_filters( 'members_default_user_roles', array( get_option( 'default_role' ) ) );
|
92 |
+
|
93 |
+
// If the form was submitted but didn't go through, get the posted roles.
|
94 |
+
if ( isset( $_POST['createuser'] ) && ! empty( $_POST['members_user_roles'] ) )
|
95 |
+
$new_user_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
96 |
+
|
97 |
+
$roles = members_get_roles();
|
98 |
+
|
99 |
+
ksort( $roles );
|
100 |
+
|
101 |
+
wp_nonce_field( 'new_user_roles', 'members_new_user_roles_nonce' ); ?>
|
102 |
+
|
103 |
+
<table class="form-table">
|
104 |
+
|
105 |
+
<tr>
|
106 |
+
<th><?php esc_html_e( 'User Roles', 'members' ); ?></th>
|
107 |
+
|
108 |
+
<td>
|
109 |
+
<div class="wp-tab-panel">
|
110 |
+
<ul>
|
111 |
+
<?php foreach ( $roles as $role ) : ?>
|
112 |
+
|
113 |
+
<?php if ( members_is_role_editable( $role->name ) ) :?>
|
114 |
+
<li>
|
115 |
+
<label>
|
116 |
+
<input type="checkbox" name="members_user_roles[]" value="<?php echo esc_attr( $role->name ); ?>" <?php checked( in_array( $role->name, $new_user_roles ) ); ?> />
|
117 |
+
<?php echo esc_html( $role->label ); ?>
|
118 |
+
</label>
|
119 |
+
</li>
|
120 |
+
<?php endif; ?>
|
121 |
+
|
122 |
+
<?php endforeach; ?>
|
123 |
+
</ul>
|
124 |
+
</div>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
|
128 |
+
</table>
|
129 |
+
<?php }
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Handles the new user's roles once the form has been submitted.
|
133 |
+
*
|
134 |
+
* @since 2.0.0
|
135 |
+
* @access public
|
136 |
+
* @param int $user_id
|
137 |
+
* @return void
|
138 |
+
*/
|
139 |
+
public function user_register( $user_id ) {
|
140 |
+
|
141 |
+
// If the current user can't promote users or edit this particular user, bail.
|
142 |
+
if ( ! current_user_can( 'promote_users' ) )
|
143 |
+
return;
|
144 |
+
|
145 |
+
// Is this a role change?
|
146 |
+
if ( ! isset( $_POST['members_new_user_roles_nonce'] ) || ! wp_verify_nonce( $_POST['members_new_user_roles_nonce'], 'new_user_roles' ) )
|
147 |
+
return;
|
148 |
+
|
149 |
+
// Create a new user object.
|
150 |
+
$user = new \WP_User( $user_id );
|
151 |
+
|
152 |
+
// If we have an array of roles.
|
153 |
+
if ( ! empty( $_POST['members_user_roles'] ) ) {
|
154 |
+
|
155 |
+
// Get the current user roles.
|
156 |
+
$old_roles = (array) $user->roles;
|
157 |
+
|
158 |
+
// Sanitize the posted roles.
|
159 |
+
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
160 |
+
|
161 |
+
// Loop through the posted roles.
|
162 |
+
foreach ( $new_roles as $new_role ) {
|
163 |
+
|
164 |
+
// If the user doesn't already have the role, add it.
|
165 |
+
if ( members_is_role_editable( $new_role ) && ! in_array( $new_role, (array) $user->roles ) )
|
166 |
+
$user->add_role( $new_role );
|
167 |
+
}
|
168 |
+
|
169 |
+
// Loop through the current user roles.
|
170 |
+
foreach ( $old_roles as $old_role ) {
|
171 |
+
|
172 |
+
// If the role is editable and not in the new roles array, remove it.
|
173 |
+
if ( members_is_role_editable( $old_role ) && ! in_array( $old_role, $new_roles ) )
|
174 |
+
$user->remove_role( $old_role );
|
175 |
+
}
|
176 |
+
|
177 |
+
// If the posted roles are empty.
|
178 |
+
} else {
|
179 |
+
|
180 |
+
// Loop through the current user roles.
|
181 |
+
foreach ( (array) $user->roles as $old_role ) {
|
182 |
+
|
183 |
+
// Remove the role if it is editable.
|
184 |
+
if ( members_is_role_editable( $old_role ) )
|
185 |
+
$user->remove_role( $old_role );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Enqueue scripts.
|
192 |
+
*
|
193 |
+
* @since 2.0.0
|
194 |
+
* @access public
|
195 |
+
* @return void
|
196 |
+
*/
|
197 |
+
public function enqueue() {
|
198 |
+
|
199 |
+
wp_enqueue_script( 'jquery' );
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Enqueue the plugin admin CSS.
|
204 |
+
*
|
205 |
+
* @since 2.0.0
|
206 |
+
* @access public
|
207 |
+
* @return void
|
208 |
+
*/
|
209 |
+
public function print_scripts() { ?>
|
210 |
+
|
211 |
+
<script>
|
212 |
+
jQuery( document ).ready( function() {
|
213 |
+
|
214 |
+
var roles_dropdown = jQuery('select#role');
|
215 |
+
roles_dropdown.closest( 'tr' ).remove();
|
216 |
+
} );
|
217 |
+
</script>
|
218 |
+
|
219 |
+
<?php }
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Returns the instance.
|
223 |
+
*
|
224 |
+
* @since 2.0.0
|
225 |
+
* @access public
|
226 |
+
* @return object
|
227 |
+
*/
|
228 |
+
public static function get_instance() {
|
229 |
+
|
230 |
+
if ( ! self::$instance ) {
|
231 |
+
self::$instance = new self;
|
232 |
+
|
233 |
+
self::$instance->setup_actions();
|
234 |
+
}
|
235 |
+
|
236 |
+
return self::$instance;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
User_New::get_instance();
|
admin/functions-addons.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Functions for handling add-on plugin registration and integration for the Add-Ons
|
4 |
+
* view on the settings screen.
|
5 |
+
*
|
6 |
+
* @package Members
|
7 |
+
* @subpackage Includes
|
8 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
9 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
10 |
+
* @link https://themehybrid.com/plugins/members
|
11 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
+
*/
|
13 |
+
|
14 |
+
# Register addons.
|
15 |
+
add_action( 'members_register_addons', 'members_register_default_addons', 5 );
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Registers any addons stored globally with WordPress.
|
19 |
+
*
|
20 |
+
* @since 2.0.0
|
21 |
+
* @access public
|
22 |
+
* @param object $wp_addons
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
function members_register_default_addons() {
|
26 |
+
|
27 |
+
// Get the transient where the Members addons are stored on-site.
|
28 |
+
$data = get_transient( 'members_addons' );
|
29 |
+
|
30 |
+
if ( ! $data || ! is_array( $data ) ) {
|
31 |
+
|
32 |
+
// `localhost` is the sandbox URL.
|
33 |
+
// $url = 'http://localhost/api/th/v1/plugins?addons=members';
|
34 |
+
$url = 'https://themehybrid.com/api/th/v1/plugins?addons=members';
|
35 |
+
|
36 |
+
// Get data from the remote URL.
|
37 |
+
$response = wp_remote_get( $url );
|
38 |
+
|
39 |
+
// Bail if we get no response.
|
40 |
+
if ( is_wp_error( $response ) )
|
41 |
+
return;
|
42 |
+
|
43 |
+
// Decode the data that we got.
|
44 |
+
$data = json_decode( wp_remote_retrieve_body( $response ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
// If we have an array of data, let's roll.
|
48 |
+
if ( ! empty( $data ) && is_array( $data ) ) {
|
49 |
+
|
50 |
+
// Set the transient with the new data.
|
51 |
+
set_transient( 'members_addons', $data, 7 * DAY_IN_SECONDS );
|
52 |
+
|
53 |
+
foreach ( $data as $addon ) {
|
54 |
+
|
55 |
+
$args = array(
|
56 |
+
'title' => $addon->title,
|
57 |
+
'excerpt' => $addon->excerpt,
|
58 |
+
'url' => $addon->url,
|
59 |
+
'purchase_url' => $addon->meta->purchase_url,
|
60 |
+
'download_url' => $addon->meta->download_url,
|
61 |
+
'rating' => $addon->meta->rating,
|
62 |
+
'rating_count' => $addon->meta->rating_count,
|
63 |
+
'install_count' => $addon->meta->install_count,
|
64 |
+
'icon_url' => $addon->media->icon->url,
|
65 |
+
'author_url' => $addon->author->url,
|
66 |
+
'author_name' => $addon->author->name
|
67 |
+
);
|
68 |
+
|
69 |
+
members_register_addon( $addon->slug, $args );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns the instance of the addon registry.
|
76 |
+
*
|
77 |
+
* @since 2.0.0
|
78 |
+
* @access public
|
79 |
+
* @return object
|
80 |
+
*/
|
81 |
+
function members_addon_registry() {
|
82 |
+
|
83 |
+
return \Members\Registry::get_instance( 'addon' );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Returns all registered addons.
|
88 |
+
*
|
89 |
+
* @since 2.0.0
|
90 |
+
* @access public
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
function members_get_addons() {
|
94 |
+
|
95 |
+
return members_addon_registry()->get_collection();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Registers a addon.
|
100 |
+
*
|
101 |
+
* @since 2.0.0
|
102 |
+
* @access public
|
103 |
+
* @param string $name
|
104 |
+
* @param array $args
|
105 |
+
* @return void
|
106 |
+
*/
|
107 |
+
function members_register_addon( $name, $args = array() ) {
|
108 |
+
|
109 |
+
members_addon_registry()->register( $name, new \Members\Addon( $name, $args ) );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Unregisters a addon.
|
114 |
+
*
|
115 |
+
* @since 2.0.0
|
116 |
+
* @access public
|
117 |
+
* @param string $name
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
function members_unregister_addon( $name ) {
|
121 |
+
|
122 |
+
members_addon_registry()->unregister( $name );
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Returns a addon object.
|
127 |
+
*
|
128 |
+
* @since 2.0.0
|
129 |
+
* @access public
|
130 |
+
* @param string $name
|
131 |
+
* @return object
|
132 |
+
*/
|
133 |
+
function members_get_addon( $name ) {
|
134 |
+
|
135 |
+
return members_addon_registry()->get( $name );
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Checks if a addon object exists.
|
140 |
+
*
|
141 |
+
* @since 2.0.0
|
142 |
+
* @access public
|
143 |
+
* @param string $name
|
144 |
+
* @return bool
|
145 |
+
*/
|
146 |
+
function members_addon_exists( $name ) {
|
147 |
+
|
148 |
+
return members_addon_registry()->exists( $name );
|
149 |
+
}
|
admin/functions-admin.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -14,10 +14,6 @@
|
|
14 |
add_action( 'admin_enqueue_scripts', 'members_admin_register_scripts', 0 );
|
15 |
add_action( 'admin_enqueue_scripts', 'members_admin_register_styles', 0 );
|
16 |
|
17 |
-
# Custom manage users columns.
|
18 |
-
add_filter( 'manage_users_columns', 'members_manage_users_columns' );
|
19 |
-
add_filter( 'manage_users_custom_column', 'members_manage_users_custom_column', 10, 3 );
|
20 |
-
|
21 |
/**
|
22 |
* Get an Underscore JS template.
|
23 |
*
|
@@ -27,7 +23,7 @@ add_filter( 'manage_users_custom_column', 'members_manage_users_custom_column',
|
|
27 |
* @return bool
|
28 |
*/
|
29 |
function members_get_underscore_template( $name ) {
|
30 |
-
require_once( members_plugin()->
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -41,8 +37,9 @@ function members_admin_register_scripts() {
|
|
41 |
|
42 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
43 |
|
44 |
-
wp_register_script( 'members-settings', members_plugin()->
|
45 |
-
wp_register_script( 'members-edit-
|
|
|
46 |
|
47 |
// Localize our script with some text we want to pass in.
|
48 |
$i18n = array(
|
@@ -67,7 +64,7 @@ function members_admin_register_styles() {
|
|
67 |
|
68 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
69 |
|
70 |
-
wp_register_style( 'members-admin', members_plugin()->
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -112,7 +109,7 @@ function members_delete_role( $role ) {
|
|
112 |
remove_role( $role );
|
113 |
|
114 |
// Remove the role from the role factory.
|
115 |
-
|
116 |
}
|
117 |
|
118 |
/**
|
@@ -128,68 +125,3 @@ function members_get_user_meta_keys() {
|
|
128 |
|
129 |
return $wpdb->get_col( "SELECT meta_key FROM $wpdb->usermeta GROUP BY meta_key ORDER BY meta_key" );
|
130 |
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Adds custom columns to the `users.php` screen.
|
134 |
-
*
|
135 |
-
* @since 1.0.0
|
136 |
-
* @access public
|
137 |
-
* @param array $columns
|
138 |
-
* @return array
|
139 |
-
*/
|
140 |
-
function members_manage_users_columns( $columns ) {
|
141 |
-
|
142 |
-
// If multiple roles per user is not enabled, bail.
|
143 |
-
if ( ! members_multiple_user_roles_enabled() )
|
144 |
-
return $columns;
|
145 |
-
|
146 |
-
// Unset the core WP `role` column.
|
147 |
-
if ( isset( $columns['role'] ) )
|
148 |
-
unset( $columns['role'] );
|
149 |
-
|
150 |
-
// Add our new roles column.
|
151 |
-
$columns['roles'] = esc_html__( 'Roles', 'members' );
|
152 |
-
|
153 |
-
// Move the core WP `posts` column to the end.
|
154 |
-
if ( isset( $columns['posts'] ) ) {
|
155 |
-
$p = $columns['posts'];
|
156 |
-
unset( $columns['posts'] );
|
157 |
-
$columns['posts'] = $p;
|
158 |
-
}
|
159 |
-
|
160 |
-
return $columns;
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Handles the output of the roles column on the `users.php` screen.
|
165 |
-
*
|
166 |
-
* @since 1.0.0
|
167 |
-
* @access public
|
168 |
-
* @param string $output
|
169 |
-
* @param string $column
|
170 |
-
* @param int $user_id
|
171 |
-
* @return string
|
172 |
-
*/
|
173 |
-
function members_manage_users_custom_column( $output, $column, $user_id ) {
|
174 |
-
|
175 |
-
if ( 'roles' === $column && members_multiple_user_roles_enabled() ) {
|
176 |
-
|
177 |
-
$user = new WP_User( $user_id );
|
178 |
-
|
179 |
-
$user_roles = array();
|
180 |
-
$output = esc_html__( 'None', 'members' );
|
181 |
-
|
182 |
-
if ( is_array( $user->roles ) ) {
|
183 |
-
|
184 |
-
foreach ( $user->roles as $role ) {
|
185 |
-
|
186 |
-
if ( members_role_exists( $role ) )
|
187 |
-
$user_roles[] = members_translate_role( $role );
|
188 |
-
}
|
189 |
-
|
190 |
-
$output = join( ', ', $user_roles );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return $output;
|
195 |
-
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
14 |
add_action( 'admin_enqueue_scripts', 'members_admin_register_scripts', 0 );
|
15 |
add_action( 'admin_enqueue_scripts', 'members_admin_register_styles', 0 );
|
16 |
|
|
|
|
|
|
|
|
|
17 |
/**
|
18 |
* Get an Underscore JS template.
|
19 |
*
|
23 |
* @return bool
|
24 |
*/
|
25 |
function members_get_underscore_template( $name ) {
|
26 |
+
require_once( members_plugin()->dir . "admin/tmpl/{$name}.php" );
|
27 |
}
|
28 |
|
29 |
/**
|
37 |
|
38 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
39 |
|
40 |
+
wp_register_script( 'members-settings', members_plugin()->uri . "js/settings{$min}.js", array( 'jquery' ), '', true );
|
41 |
+
wp_register_script( 'members-edit-post', members_plugin()->uri . "js/edit-post{$min}.js", array( 'jquery' ), '', true );
|
42 |
+
wp_register_script( 'members-edit-role', members_plugin()->uri . "js/edit-role{$min}.js", array( 'postbox', 'wp-util' ), '', true );
|
43 |
|
44 |
// Localize our script with some text we want to pass in.
|
45 |
$i18n = array(
|
64 |
|
65 |
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
66 |
|
67 |
+
wp_register_style( 'members-admin', members_plugin()->uri . "css/admin{$min}.css" );
|
68 |
}
|
69 |
|
70 |
/**
|
109 |
remove_role( $role );
|
110 |
|
111 |
// Remove the role from the role factory.
|
112 |
+
members_unregister_role( $role );
|
113 |
}
|
114 |
|
115 |
/**
|
125 |
|
126 |
return $wpdb->get_col( "SELECT meta_key FROM $wpdb->usermeta GROUP BY meta_key ORDER BY meta_key" );
|
127 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/functions-help.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -21,7 +21,7 @@ function members_get_help_sidebar_text() {
|
|
21 |
|
22 |
// Get docs and help links.
|
23 |
$docs_link = sprintf( '<li><a href="https://github.com/justintadlock/members/blob/master/readme.md">%s</a></li>', esc_html__( 'Documentation', 'members' ) );
|
24 |
-
$help_link = sprintf( '<li><a href="
|
25 |
|
26 |
// Return the text.
|
27 |
return sprintf(
|
@@ -108,6 +108,13 @@ function members_edit_role_help_overview_cb() { ?>
|
|
108 |
<p>
|
109 |
<?php esc_html_e( 'This screen allows you to edit an individual role and its capabilities.', 'members' ); ?>
|
110 |
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
<?php }
|
112 |
|
113 |
/**
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
21 |
|
22 |
// Get docs and help links.
|
23 |
$docs_link = sprintf( '<li><a href="https://github.com/justintadlock/members/blob/master/readme.md">%s</a></li>', esc_html__( 'Documentation', 'members' ) );
|
24 |
+
$help_link = sprintf( '<li><a href="https://themehybrid.com/board/topics">%s</a></li>', esc_html__( 'Support Forums', 'members' ) );
|
25 |
|
26 |
// Return the text.
|
27 |
return sprintf(
|
108 |
<p>
|
109 |
<?php esc_html_e( 'This screen allows you to edit an individual role and its capabilities.', 'members' ); ?>
|
110 |
<p>
|
111 |
+
|
112 |
+
<p>
|
113 |
+
<?php printf(
|
114 |
+
esc_html__( 'Visit the %s page in the WordPress Codex to see a complete list of roles, capabilities, and their definitions.', 'members' ),
|
115 |
+
'<a href="https://codex.wordpress.org/Roles_and_Capabilities">' . esc_html__( 'Roles and Capabilities', 'members' ) . '</a>'
|
116 |
+
); ?>
|
117 |
+
</p>
|
118 |
<?php }
|
119 |
|
120 |
/**
|
admin/functions-role-groups.php
DELETED
@@ -1,165 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Role groups API. Offers a standardized method for creating role groups.
|
4 |
-
*
|
5 |
-
* @package Members
|
6 |
-
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <justin@justintadlock.com>
|
8 |
-
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
|
9 |
-
* @link http://themehybrid.com/plugins/members
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
# Registers default groups.
|
14 |
-
add_action( 'init', 'members_register_role_groups', 15 );
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Returns the instance of the `Members_Role_Group_Factory` object. Use this function to access the object.
|
18 |
-
*
|
19 |
-
* @see Members_Role_Group_Factory
|
20 |
-
* @since 1.0.0
|
21 |
-
* @access public
|
22 |
-
* @return object
|
23 |
-
*/
|
24 |
-
function members_role_group_factory() {
|
25 |
-
return Members_Role_Group_Factory::get_instance();
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Function for registering a role group.
|
30 |
-
*
|
31 |
-
* @see Members_Role_Group_Factory::register_group()
|
32 |
-
* @since 1.0.0
|
33 |
-
* @access public
|
34 |
-
* @param string $name
|
35 |
-
* @param array $args
|
36 |
-
* @return void
|
37 |
-
*/
|
38 |
-
function members_register_role_group( $name, $args = array() ) {
|
39 |
-
members_role_group_factory()->register_group( $name, $args );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Unregisters a group.
|
44 |
-
*
|
45 |
-
* @see Members_Role_Group_Factory::unregister_group()
|
46 |
-
* @since 1.0.0
|
47 |
-
* @access public
|
48 |
-
* @param string $name
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
function members_unregister_role_group( $name ) {
|
52 |
-
members_role_group_factory()->unregister_group( $name );
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Checks if a group exists.
|
57 |
-
*
|
58 |
-
* @see Members_Role_Group_Factory::group_exists()
|
59 |
-
* @since 1.0.0
|
60 |
-
* @access public
|
61 |
-
* @param string $name
|
62 |
-
* @return bool
|
63 |
-
*/
|
64 |
-
function members_role_group_exists( $name ) {
|
65 |
-
return members_role_group_factory()->group_exists( $name );
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Returns an array of registered group objects.
|
70 |
-
*
|
71 |
-
* @see Members_Role_Group_Factory::group
|
72 |
-
* @since 1.0.0
|
73 |
-
* @access public
|
74 |
-
* @return array
|
75 |
-
*/
|
76 |
-
function members_get_role_groups() {
|
77 |
-
return members_role_group_factory()->groups;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Returns a group object if it exists. Otherwise, `FALSE`.
|
82 |
-
*
|
83 |
-
* @see Members_Role_Group_Factory::get_group()
|
84 |
-
* @see Members_Role_Group
|
85 |
-
* @since 1.0.0
|
86 |
-
* @access public
|
87 |
-
* @param string $name
|
88 |
-
* @return object|bool
|
89 |
-
*/
|
90 |
-
function members_get_role_group( $name ) {
|
91 |
-
return members_role_group_factory()->get_group( $name );
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Registers the default role groups.
|
96 |
-
*
|
97 |
-
* @since 1.0.0
|
98 |
-
* @access public
|
99 |
-
* @return void
|
100 |
-
*/
|
101 |
-
function members_register_role_groups() {
|
102 |
-
|
103 |
-
// Get the current user.
|
104 |
-
$current_user = wp_get_current_user();
|
105 |
-
|
106 |
-
if ( is_object( $current_user ) ) {
|
107 |
-
|
108 |
-
// Register the mine group.
|
109 |
-
members_register_role_group( 'mine',
|
110 |
-
array(
|
111 |
-
'label' => esc_html__( 'Mine', 'members' ),
|
112 |
-
'label_count' => _n_noop( 'Mine %s', 'Mine %s', 'members' ),
|
113 |
-
'roles' => $current_user->roles,
|
114 |
-
)
|
115 |
-
);
|
116 |
-
}
|
117 |
-
|
118 |
-
// Register the active group.
|
119 |
-
members_register_role_group( 'active',
|
120 |
-
array(
|
121 |
-
'label' => esc_html__( 'Has Users', 'members' ),
|
122 |
-
'label_count' => _n_noop( 'Has Users %s', 'Has Users %s', 'members' ),
|
123 |
-
'roles' => array(), // These will be updated on the fly b/c it requires counting users.
|
124 |
-
)
|
125 |
-
);
|
126 |
-
|
127 |
-
// Register the inactive group.
|
128 |
-
members_register_role_group( 'inactive',
|
129 |
-
array(
|
130 |
-
'label' => esc_html__( 'No Users', 'members' ),
|
131 |
-
'label_count' => _n_noop( 'No Users %s', 'No Users %s', 'members' ),
|
132 |
-
'roles' => array(), // These will be updated on the fly b/c it requires counting users.
|
133 |
-
)
|
134 |
-
);
|
135 |
-
|
136 |
-
// Register the editable group.
|
137 |
-
members_register_role_group( 'editable',
|
138 |
-
array(
|
139 |
-
'label' => esc_html__( 'Editable', 'members' ),
|
140 |
-
'label_count' => _n_noop( 'Editable %s', 'Editable %s', 'members' ),
|
141 |
-
'roles' => members_get_editable_role_slugs(),
|
142 |
-
)
|
143 |
-
);
|
144 |
-
|
145 |
-
// Register the uneditable group.
|
146 |
-
members_register_role_group( 'uneditable',
|
147 |
-
array(
|
148 |
-
'label' => esc_html__( 'Uneditable', 'members' ),
|
149 |
-
'label_count' => _n_noop( 'Uneditable %s', 'Uneditable %s', 'members' ),
|
150 |
-
'roles' => members_get_uneditable_role_slugs(),
|
151 |
-
)
|
152 |
-
);
|
153 |
-
|
154 |
-
// Register the WordPress group.
|
155 |
-
members_register_role_group( 'wordpress',
|
156 |
-
array(
|
157 |
-
'label' => esc_html__( 'WordPress', 'members' ),
|
158 |
-
'label_count' => _n_noop( 'WordPress %s', 'WordPress %s', 'members' ),
|
159 |
-
'roles' => members_get_wordpress_role_slugs(),
|
160 |
-
)
|
161 |
-
);
|
162 |
-
|
163 |
-
// Hook for registering role groups. Plugins should always register on this hook.
|
164 |
-
do_action( 'members_register_role_groups' );
|
165 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/functions-settings.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles settings functionality.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
# Register settings views.
|
14 |
+
add_action( 'members_register_settings_views', 'members_register_default_settings_views', 5 );
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Registers the plugin's built-in settings views.
|
18 |
+
*
|
19 |
+
* @since 2.0.0
|
20 |
+
* @access public
|
21 |
+
* @param object $manager
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
function members_register_default_settings_views( $manager ) {
|
25 |
+
|
26 |
+
// Bail if not on the settings screen.
|
27 |
+
if ( 'members-settings' !== $manager->name )
|
28 |
+
return;
|
29 |
+
|
30 |
+
// Register general settings view (default view).
|
31 |
+
$manager->register_view(
|
32 |
+
new \Members\Admin\View_General(
|
33 |
+
'general',
|
34 |
+
array(
|
35 |
+
'label' => esc_html__( 'General', 'members' ),
|
36 |
+
'priority' => 0
|
37 |
+
)
|
38 |
+
)
|
39 |
+
);
|
40 |
+
|
41 |
+
// Register add-ons view.
|
42 |
+
$manager->register_view(
|
43 |
+
new \Members\Admin\View_Addons(
|
44 |
+
'add-ons',
|
45 |
+
array(
|
46 |
+
'label' => esc_html__( 'Add-Ons', 'members' ),
|
47 |
+
'priority' => 95
|
48 |
+
)
|
49 |
+
)
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Conditional function to check if on the plugin's settings page.
|
55 |
+
*
|
56 |
+
* @since 2.0.0
|
57 |
+
* @access public
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
function members_is_settings_page() {
|
61 |
+
|
62 |
+
$screen = get_current_screen();
|
63 |
+
|
64 |
+
return is_object( $screen ) && 'settings_page_members-settings' === $screen->id;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Returns the URL to the settings page.
|
69 |
+
*
|
70 |
+
* @since 2.0.0
|
71 |
+
* @access public
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
function members_get_settings_page_url() {
|
75 |
+
|
76 |
+
return add_query_arg( array( 'page' => 'members-settings' ), admin_url( 'options-general.php' ) );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns the URL to a settings view page.
|
81 |
+
*
|
82 |
+
* @since 2.0.0
|
83 |
+
* @access public
|
84 |
+
* @param string $view
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
function members_get_settings_view_url( $view ) {
|
88 |
+
|
89 |
+
return add_query_arg( array( 'view' => sanitize_key( $view ) ), members_get_settings_page_url() );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Returns the current settings view name.
|
94 |
+
*
|
95 |
+
* @since 2.0.0
|
96 |
+
* @access public
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
function members_get_current_settings_view() {
|
100 |
+
|
101 |
+
if ( ! members_is_settings_page() )
|
102 |
+
return '';
|
103 |
+
|
104 |
+
return isset( $_GET['view'] ) ? sanitize_key( $_GET['view'] ) : 'general';
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Conditional function to check if on a specific settings view page.
|
109 |
+
*
|
110 |
+
* @since 2.0.0
|
111 |
+
* @access public
|
112 |
+
* @param string $view
|
113 |
+
* @return bool
|
114 |
+
*/
|
115 |
+
function members_is_settings_view( $view = '' ) {
|
116 |
+
|
117 |
+
return members_is_settings_page() && $view === members_get_current_settings_view();
|
118 |
+
}
|
admin/tmpl/cap-control.php
CHANGED
@@ -4,15 +4,15 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
?>
|
13 |
<tr class="members-cap-checklist">
|
14 |
<td class="column-cap">
|
15 |
-
<button type="button"><strong>{{ data.cap }}</strong></button>
|
16 |
<i class="dashicons <?php echo is_rtl() ? 'dashicons-arrow-left' : 'dashicons-arrow-right'; ?>"></i>
|
17 |
</td>
|
18 |
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
?>
|
13 |
<tr class="members-cap-checklist">
|
14 |
<td class="column-cap">
|
15 |
+
<button type="button"><strong>{{ data.label.cap }}</strong></button>
|
16 |
<i class="dashicons <?php echo is_rtl() ? 'dashicons-arrow-left' : 'dashicons-arrow-right'; ?>"></i>
|
17 |
</td>
|
18 |
|
admin/tmpl/cap-section.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
?>
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
?>
|
admin/tmpl/cp-control-message.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<label>
|
2 |
-
<# if ( data.label ) { #>
|
3 |
-
<span class="members-cp-label">{{ data.label }}</span>
|
4 |
-
<# } #>
|
5 |
-
|
6 |
-
<textarea name="members_access_error" class="widefat">{{{ data.value }}}</textarea>
|
7 |
-
|
8 |
-
<# if ( data.description ) { #>
|
9 |
-
<span class="members-cp-description">{{{ data.description }}}</span>
|
10 |
-
<# } #>
|
11 |
-
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/tmpl/cp-control-role.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<# if ( data.label ) { #>
|
2 |
-
<span class="members-cp-label">{{ data.label }}</span>
|
3 |
-
<# } #>
|
4 |
-
|
5 |
-
<# if ( data.desciption ) { #>
|
6 |
-
<span class="members-cp-description">{{{ data.description }}}</span>
|
7 |
-
<# } #>
|
8 |
-
|
9 |
-
<div class="members-cp-role-list-wrap">
|
10 |
-
|
11 |
-
<ul class="members-cp-role-list">
|
12 |
-
|
13 |
-
<# _.each( data.roles ), function( label, choice ) { #>
|
14 |
-
|
15 |
-
<li>
|
16 |
-
<label>
|
17 |
-
<input type="checkbox" name="members_access_role[]" value="{{ data.choice }}" <# if ( -1 !== _.indexOf( data.value, choice ) ) { #> checked="checked" <# } #> />
|
18 |
-
{{ label }}
|
19 |
-
</label>
|
20 |
-
</li>
|
21 |
-
|
22 |
-
<# } ); #>
|
23 |
-
|
24 |
-
</ul>
|
25 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/tmpl/cp-nav.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<a href="#members-cp-section-{{ data.name }}"><i class="{{ data.icon }}" aria-hidden="true"></i><span class="label">{{ data.label }}</span></a>
|
|
admin/tmpl/cp-section.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<# if ( data.desciption ) { #>
|
2 |
-
{{{ data.description }}}
|
3 |
-
<# } #>
|
|
|
|
|
|
admin/views/class-view-addons.php
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles the add-ons settings view.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Sets up and handles the add-ons settings view.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
class View_Addons extends View {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Renders the settings page.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
public function template() {
|
31 |
+
|
32 |
+
require_once( members_plugin()->dir . 'admin/class-addon.php' );
|
33 |
+
require_once( members_plugin()->dir . 'admin/functions-addons.php' );
|
34 |
+
|
35 |
+
do_action( 'members_register_addons' );
|
36 |
+
|
37 |
+
$addons = members_get_addons(); ?>
|
38 |
+
|
39 |
+
<div class="widefat">
|
40 |
+
|
41 |
+
<?php if ( $addons ) : ?>
|
42 |
+
|
43 |
+
<?php foreach ( $addons as $addon ) : ?>
|
44 |
+
|
45 |
+
<?php $this->addon_card( $addon ); ?>
|
46 |
+
|
47 |
+
<?php endforeach; ?>
|
48 |
+
|
49 |
+
<?php else : ?>
|
50 |
+
|
51 |
+
<div class="error notice">
|
52 |
+
<p>
|
53 |
+
<strong><?php esc_html_e( 'There are currently no add-ons to show. Please try again later.', 'members' ); ?></strong>
|
54 |
+
</p>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<?php endif; ?>
|
58 |
+
|
59 |
+
</div><!-- .widefat -->
|
60 |
+
<?php }
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Renders an individual add-on plugin card.
|
64 |
+
*
|
65 |
+
* @since 2.0.0
|
66 |
+
* @access public
|
67 |
+
* @return void
|
68 |
+
*/
|
69 |
+
public function addon_card( $addon ) { ?>
|
70 |
+
|
71 |
+
<div class="plugin-card plugin-card-<?php echo esc_attr( $addon->name ); ?>">
|
72 |
+
|
73 |
+
<div class="plugin-card-top">
|
74 |
+
|
75 |
+
<div class="name column-name">
|
76 |
+
<h3>
|
77 |
+
<a href="<?php echo esc_url( $addon->url ); ?>">
|
78 |
+
<?php echo esc_html( $addon->title ); ?>
|
79 |
+
|
80 |
+
<?php if ( file_exists( members_plugin()->dir . "img/icon-{$addon->name}.png" ) ) : ?>
|
81 |
+
|
82 |
+
<img class="plugin-icon" src="<?php echo esc_url( members_plugin()->uri . "img/icon-{$addon->name}.png" ); ?>" alt="" />
|
83 |
+
|
84 |
+
<?php elseif ( $addon->icon_url ) : ?>
|
85 |
+
|
86 |
+
<img class="plugin-icon" src="<?php echo esc_url( $addon->icon_url ); ?>" alt="" />
|
87 |
+
|
88 |
+
<?php endif; ?>
|
89 |
+
</a>
|
90 |
+
</h3>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<div class="action-links">
|
94 |
+
|
95 |
+
<ul class="plugin-action-buttons">
|
96 |
+
<li>
|
97 |
+
<?php if ( $addon->purchase_url ) : ?>
|
98 |
+
|
99 |
+
<a class="install-now button" href="<?php echo esc_url( $addon->purchase_url ); ?>"><?php esc_html_e( 'Purchase', 'members' ); ?></a>
|
100 |
+
|
101 |
+
<?php elseif ( $addon->download_url ) : ?>
|
102 |
+
|
103 |
+
<a class="install-now button" href="<?php echo esc_url( $addon->download_url ); ?>"><?php esc_html_e( 'Download', 'members' ); ?></a>
|
104 |
+
|
105 |
+
<?php else : ?>
|
106 |
+
|
107 |
+
<a class="install-now button" href="<?php echo esc_url( $addon->url ); ?>"><?php esc_html_e( 'Download', 'members' ); ?></a>
|
108 |
+
|
109 |
+
<?php endif; ?>
|
110 |
+
</li>
|
111 |
+
</ul>
|
112 |
+
</div>
|
113 |
+
|
114 |
+
<div class="desc column-description">
|
115 |
+
|
116 |
+
<?php echo wpautop( wp_strip_all_tags( $addon->excerpt ) ); ?>
|
117 |
+
|
118 |
+
<p class="authors">
|
119 |
+
<?php $author = sprintf( '<a href="%s">%s</a>', esc_url( $addon->author_url ), esc_html( $addon->author_name ) ); ?>
|
120 |
+
|
121 |
+
<cite><?php printf( esc_html__( 'By %s', 'members' ), $author ); ?></cite>
|
122 |
+
</p>
|
123 |
+
|
124 |
+
</div>
|
125 |
+
|
126 |
+
</div><!-- .plugin-card-top -->
|
127 |
+
|
128 |
+
<?php if ( ( $addon->rating && $addon->rating_count ) || $addon->install_count ) : ?>
|
129 |
+
|
130 |
+
<div class="plugin-card-bottom">
|
131 |
+
|
132 |
+
<?php if ( $addon->rating && $addon->rating_count ) : ?>
|
133 |
+
|
134 |
+
<div class="vers column-rating">
|
135 |
+
<?php wp_star_rating( array( 'type' => 'rating', 'rating' => floatval( $addon->rating ), 'number' => absint( $addon->rating_count ) ) ); ?>
|
136 |
+
<span class="num-ratings" aria-hidden="true">(<?php echo absint( $addon->rating_count ); ?>)</span>
|
137 |
+
</div>
|
138 |
+
|
139 |
+
<?php endif; ?>
|
140 |
+
|
141 |
+
<?php if ( $addon->install_count ) : ?>
|
142 |
+
|
143 |
+
<div class="column-downloaded">
|
144 |
+
<?php printf(
|
145 |
+
esc_html__( '%s+ Active Installs', 'members' ),
|
146 |
+
number_format_i18n( absint( $addon->install_count ) )
|
147 |
+
); ?>
|
148 |
+
</div>
|
149 |
+
|
150 |
+
<?php endif; ?>
|
151 |
+
|
152 |
+
</div><!-- .plugin-card-bottom -->
|
153 |
+
|
154 |
+
<?php endif; ?>
|
155 |
+
|
156 |
+
</div><!-- .plugin-card -->
|
157 |
+
|
158 |
+
<?php }
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Adds help tabs.
|
162 |
+
*
|
163 |
+
* @since 2.0.0
|
164 |
+
* @access public
|
165 |
+
* @return void
|
166 |
+
*/
|
167 |
+
public function add_help_tabs() {
|
168 |
+
|
169 |
+
// Get the current screen.
|
170 |
+
$screen = get_current_screen();
|
171 |
+
|
172 |
+
// Roles/Caps help tab.
|
173 |
+
$screen->add_help_tab(
|
174 |
+
array(
|
175 |
+
'id' => 'overview',
|
176 |
+
'title' => esc_html__( 'Overview', 'members' ),
|
177 |
+
'callback' => array( $this, 'help_tab_overview' )
|
178 |
+
)
|
179 |
+
);
|
180 |
+
|
181 |
+
// Roles/Caps help tab.
|
182 |
+
$screen->add_help_tab(
|
183 |
+
array(
|
184 |
+
'id' => 'download',
|
185 |
+
'title' => esc_html__( 'Download', 'members' ),
|
186 |
+
'callback' => array( $this, 'help_tab_download' )
|
187 |
+
)
|
188 |
+
);
|
189 |
+
|
190 |
+
// Roles/Caps help tab.
|
191 |
+
$screen->add_help_tab(
|
192 |
+
array(
|
193 |
+
'id' => 'purchase',
|
194 |
+
'title' => esc_html__( 'Purchase', 'members' ),
|
195 |
+
'callback' => array( $this, 'help_tab_purchase' )
|
196 |
+
)
|
197 |
+
);
|
198 |
+
|
199 |
+
// Set the help sidebar.
|
200 |
+
$screen->set_help_sidebar( members_get_help_sidebar_text() );
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Displays the overview help tab.
|
205 |
+
*
|
206 |
+
* @since 2.0.0
|
207 |
+
* @access public
|
208 |
+
* @return void
|
209 |
+
*/
|
210 |
+
public function help_tab_overview() { ?>
|
211 |
+
|
212 |
+
<p>
|
213 |
+
<?php esc_html_e( 'The Add-Ons screen allows you to view available add-ons for the Members plugin. You can download some plugins directly. Others may be available to purchase.', 'members' ); ?>
|
214 |
+
</p>
|
215 |
+
<?php }
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Displays the download help tab.
|
219 |
+
*
|
220 |
+
* @since 2.0.0
|
221 |
+
* @access public
|
222 |
+
* @return void
|
223 |
+
*/
|
224 |
+
public function help_tab_download() { ?>
|
225 |
+
|
226 |
+
<p>
|
227 |
+
<?php esc_html_e( 'Some plugins may be available for direct download. In such cases, you can click the download button to get a ZIP file of the plugin.', 'members' ); ?>
|
228 |
+
</p>
|
229 |
+
<?php }
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Displays the purchase help tab.
|
233 |
+
*
|
234 |
+
* @since 2.0.0
|
235 |
+
* @access public
|
236 |
+
* @return void
|
237 |
+
*/
|
238 |
+
public function help_tab_purchase() { ?>
|
239 |
+
|
240 |
+
<p>
|
241 |
+
<?php esc_html_e( 'Some add-ons may require purchase before downloading them. Clicking the purchase button will take you off-site to view the add-on in more detail.', 'members' ); ?>
|
242 |
+
</p>
|
243 |
+
<?php }
|
244 |
+
}
|
admin/views/class-view-general.php
ADDED
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles the general settings view.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Sets up and handles the general settings view.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
class View_General extends View {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Holds an array the plugin settings.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
public $settings = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Enqueue scripts/styles.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access public
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function enqueue() {
|
40 |
+
|
41 |
+
wp_enqueue_script( 'members-settings' );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Registers the plugin settings.
|
46 |
+
*
|
47 |
+
* @since 2.0.0
|
48 |
+
* @access public
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
function register_settings() {
|
52 |
+
|
53 |
+
// Get the current plugin settings w/o the defaults.
|
54 |
+
$this->settings = get_option( 'members_settings' );
|
55 |
+
|
56 |
+
// Register the setting.
|
57 |
+
register_setting( 'members_settings', 'members_settings', array( $this, 'validate_settings' ) );
|
58 |
+
|
59 |
+
/* === Settings Sections === */
|
60 |
+
|
61 |
+
// Add settings sections.
|
62 |
+
add_settings_section( 'roles_caps', esc_html__( 'Roles and Capabilities', 'members' ), array( $this, 'section_roles_caps' ), 'members-settings' );
|
63 |
+
add_settings_section( 'content_permissions', esc_html__( 'Content Permissions', 'members' ), '__return_false', 'members-settings' );
|
64 |
+
add_settings_section( 'sidebar_widgets', esc_html__( 'Sidebar Widgets', 'members' ), '__return_false', 'members-settings' );
|
65 |
+
add_settings_section( 'private_site', esc_html__( 'Private Site', 'members' ), '__return_false', 'members-settings' );
|
66 |
+
|
67 |
+
/* === Settings Fields === */
|
68 |
+
|
69 |
+
// Role manager fields.
|
70 |
+
add_settings_field( 'enable_role_manager', esc_html__( 'Role Manager', 'members' ), array( $this, 'field_enable_role_manager' ), 'members-settings', 'roles_caps' );
|
71 |
+
add_settings_field( 'enable_multi_roles', esc_html__( 'Multiple User Roles', 'members' ), array( $this, 'field_enable_multi_roles' ), 'members-settings', 'roles_caps' );
|
72 |
+
add_settings_field( 'explicit_denied_caps', esc_html__( 'Capabilities', 'members' ), array( $this, 'field_explicit_denied_caps' ), 'members-settings', 'roles_caps' );
|
73 |
+
|
74 |
+
// Content permissions fields.
|
75 |
+
add_settings_field( 'enable_content_permissions', esc_html__( 'Enable Permissions', 'members' ), array( $this, 'field_enable_content_permissions' ), 'members-settings', 'content_permissions' );
|
76 |
+
add_settings_field( 'content_permissions_error', esc_html__( 'Error Message', 'members' ), array( $this, 'field_content_permissions_error' ), 'members-settings', 'content_permissions' );
|
77 |
+
|
78 |
+
// Widgets fields.
|
79 |
+
add_settings_field( 'widget_login', esc_html__( 'Login Widget', 'members' ), array( $this, 'field_widget_login' ), 'members-settings', 'sidebar_widgets' );
|
80 |
+
add_settings_field( 'widget_users', esc_html__( 'Users Widget', 'members' ), array( $this, 'field_widget_users' ), 'members-settings', 'sidebar_widgets' );
|
81 |
+
|
82 |
+
// Private site fields.
|
83 |
+
add_settings_field( 'enable_private_site', esc_html__( 'Enable Private Site', 'members' ), array( $this, 'field_enable_private_site' ), 'members-settings', 'private_site' );
|
84 |
+
add_settings_field( 'private_rest_api', esc_html__( 'REST API', 'members' ), array( $this, 'field_private_rest_api' ), 'members-settings', 'private_site' );
|
85 |
+
add_settings_field( 'enable_private_feed', esc_html__( 'Disable Feed', 'members' ), array( $this, 'field_enable_private_feed' ), 'members-settings', 'private_site' );
|
86 |
+
add_settings_field( 'private_feed_error', esc_html__( 'Feed Error Message', 'members' ), array( $this, 'field_private_feed_error' ), 'members-settings', 'private_site' );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Validates the plugin settings.
|
91 |
+
*
|
92 |
+
* @since 2.0.0
|
93 |
+
* @access public
|
94 |
+
* @param array $input
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
function validate_settings( $settings ) {
|
98 |
+
|
99 |
+
// Validate true/false checkboxes.
|
100 |
+
$settings['role_manager'] = ! empty( $settings['role_manager'] ) ? true : false;
|
101 |
+
$settings['explicit_denied_caps'] = ! empty( $settings['explicit_denied_caps'] ) ? true : false;
|
102 |
+
$settings['multi_roles'] = ! empty( $settings['multi_roles'] ) ? true : false;
|
103 |
+
$settings['content_permissions'] = ! empty( $settings['content_permissions'] ) ? true : false;
|
104 |
+
$settings['login_form_widget'] = ! empty( $settings['login_form_widget'] ) ? true : false;
|
105 |
+
$settings['users_widget'] = ! empty( $settings['users_widget'] ) ? true : false;
|
106 |
+
$settings['private_blog'] = ! empty( $settings['private_blog'] ) ? true : false;
|
107 |
+
$settings['private_rest_api'] = ! empty( $settings['private_rest_api'] ) ? true : false;
|
108 |
+
$settings['private_feed'] = ! empty( $settings['private_feed'] ) ? true : false;
|
109 |
+
|
110 |
+
// Kill evil scripts.
|
111 |
+
$settings['content_permissions_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['content_permissions_error'] ) ) );
|
112 |
+
$settings['private_feed_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['private_feed_error'] ) ) );
|
113 |
+
|
114 |
+
// Return the validated/sanitized settings.
|
115 |
+
return $settings;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Role/Caps section callback.
|
120 |
+
*
|
121 |
+
* @since 2.0.0
|
122 |
+
* @access public
|
123 |
+
* @return void
|
124 |
+
*/
|
125 |
+
public function section_roles_caps() { ?>
|
126 |
+
|
127 |
+
<p class="description">
|
128 |
+
<?php esc_html_e( 'Your roles and capabilities will not revert back to their previous settings after deactivating or uninstalling this plugin, so use this feature wisely.', 'members' ); ?>
|
129 |
+
</p>
|
130 |
+
<?php }
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Role manager field callback.
|
134 |
+
*
|
135 |
+
* @since 2.0.0
|
136 |
+
* @access public
|
137 |
+
* @return void
|
138 |
+
*/
|
139 |
+
public function field_enable_role_manager() { ?>
|
140 |
+
|
141 |
+
<label>
|
142 |
+
<input type="checkbox" name="members_settings[role_manager]" value="true" <?php checked( members_role_manager_enabled() ); ?> />
|
143 |
+
<?php esc_html_e( 'Enable the role manager.', 'members' ); ?>
|
144 |
+
</label>
|
145 |
+
<?php }
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Explicit denied caps field callback.
|
149 |
+
*
|
150 |
+
* @since 2.0.0
|
151 |
+
* @access public
|
152 |
+
* @return void
|
153 |
+
*/
|
154 |
+
public function field_explicit_denied_caps() { ?>
|
155 |
+
|
156 |
+
<fieldset>
|
157 |
+
|
158 |
+
<p>
|
159 |
+
<label>
|
160 |
+
<input type="checkbox" name="members_settings[explicit_denied_caps]" value="true" <?php checked( members_explicitly_deny_caps() ); ?> />
|
161 |
+
<?php esc_html_e( 'Denied capabilities should always overrule granted capabilities.', 'members' ); ?>
|
162 |
+
</label>
|
163 |
+
</p>
|
164 |
+
|
165 |
+
<p>
|
166 |
+
<label>
|
167 |
+
<input type="checkbox" name="members_settings[show_human_caps]" value="true" <?php checked( members_show_human_caps() ); ?> />
|
168 |
+
<?php esc_html_e( 'Show human-readable capabilities when possible.', 'members' ); ?>
|
169 |
+
</label>
|
170 |
+
</p>
|
171 |
+
|
172 |
+
</fieldset>
|
173 |
+
<?php }
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Multiple roles field callback.
|
177 |
+
*
|
178 |
+
* @since 2.0.0
|
179 |
+
* @access public
|
180 |
+
* @return void
|
181 |
+
*/
|
182 |
+
public function field_enable_multi_roles() { ?>
|
183 |
+
|
184 |
+
<label>
|
185 |
+
<input type="checkbox" name="members_settings[multi_roles]" value="true" <?php checked( members_multiple_user_roles_enabled() ); ?> />
|
186 |
+
<?php esc_html_e( 'Allow users to be assigned more than a single role.', 'members' ); ?>
|
187 |
+
</label>
|
188 |
+
<?php }
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Enable content permissions field callback.
|
192 |
+
*
|
193 |
+
* @since 2.0.0
|
194 |
+
* @access public
|
195 |
+
* @return void
|
196 |
+
*/
|
197 |
+
public function field_enable_content_permissions() { ?>
|
198 |
+
|
199 |
+
<label>
|
200 |
+
<input type="checkbox" name="members_settings[content_permissions]" value="true" <?php checked( members_content_permissions_enabled() ); ?> />
|
201 |
+
<?php esc_html_e( 'Enable the content permissions feature.', 'members' ); ?>
|
202 |
+
</label>
|
203 |
+
<?php }
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Content permissions error message field callback.
|
207 |
+
*
|
208 |
+
* @since 2.0.0
|
209 |
+
* @access public
|
210 |
+
* @return void
|
211 |
+
*/
|
212 |
+
public function field_content_permissions_error() {
|
213 |
+
|
214 |
+
wp_editor(
|
215 |
+
members_get_setting( 'content_permissions_error' ),
|
216 |
+
'members_settings_content_permissions_error',
|
217 |
+
array(
|
218 |
+
'textarea_name' => 'members_settings[content_permissions_error]',
|
219 |
+
'drag_drop_upload' => true,
|
220 |
+
'editor_height' => 250
|
221 |
+
)
|
222 |
+
);
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Login widget field callback.
|
227 |
+
*
|
228 |
+
* @since 2.0.0
|
229 |
+
* @access public
|
230 |
+
* @return void
|
231 |
+
*/
|
232 |
+
public function field_widget_login() { ?>
|
233 |
+
|
234 |
+
<label>
|
235 |
+
<input type="checkbox" name="members_settings[login_form_widget]" value="true" <?php checked( members_login_widget_enabled() ); ?> />
|
236 |
+
<?php esc_html_e( 'Enable the login form widget.', 'members' ); ?>
|
237 |
+
</label>
|
238 |
+
<?php }
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Uers widget field callback.
|
242 |
+
*
|
243 |
+
* @since 2.0.0
|
244 |
+
* @access public
|
245 |
+
* @return void
|
246 |
+
*/
|
247 |
+
public function field_widget_users() { ?>
|
248 |
+
|
249 |
+
<label>
|
250 |
+
<input type="checkbox" name="members_settings[users_widget]" value="true" <?php checked( members_users_widget_enabled() ); ?> />
|
251 |
+
<?php esc_html_e( 'Enable the users widget.', 'members' ); ?>
|
252 |
+
</label>
|
253 |
+
<?php }
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Enable private site field callback.
|
257 |
+
*
|
258 |
+
* @since 2.0.0
|
259 |
+
* @access public
|
260 |
+
* @return void
|
261 |
+
*/
|
262 |
+
public function field_enable_private_site() { ?>
|
263 |
+
|
264 |
+
<label>
|
265 |
+
<input type="checkbox" name="members_settings[private_blog]" value="true" <?php checked( members_is_private_blog() ); ?> />
|
266 |
+
<?php esc_html_e( 'Redirect all logged-out users to the login page before allowing them to view the site.', 'members' ); ?>
|
267 |
+
</label>
|
268 |
+
<?php }
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Enable private REST API field callback.
|
272 |
+
*
|
273 |
+
* @since 2.0.0
|
274 |
+
* @access public
|
275 |
+
* @return void
|
276 |
+
*/
|
277 |
+
public function field_private_rest_api() { ?>
|
278 |
+
|
279 |
+
<label>
|
280 |
+
<input type="checkbox" name="members_settings[private_rest_api]" value="true" <?php checked( members_is_private_rest_api() ); ?> />
|
281 |
+
<?php esc_html_e( 'Require authentication for access to the REST API.', 'members' ); ?>
|
282 |
+
</label>
|
283 |
+
<?php }
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Enable private feed field callback.
|
287 |
+
*
|
288 |
+
* @since 2.0.0
|
289 |
+
* @access public
|
290 |
+
* @return void
|
291 |
+
*/
|
292 |
+
public function field_enable_private_feed() { ?>
|
293 |
+
|
294 |
+
<label>
|
295 |
+
<input type="checkbox" name="members_settings[private_feed]" value="true" <?php checked( members_is_private_feed() ); ?> />
|
296 |
+
<?php esc_html_e( 'Show error message for feed items.', 'members' ); ?>
|
297 |
+
</label>
|
298 |
+
<?php }
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Private feed error message field callback.
|
302 |
+
*
|
303 |
+
* @since 2.0.0
|
304 |
+
* @access public
|
305 |
+
* @return void
|
306 |
+
*/
|
307 |
+
public function field_private_feed_error() {
|
308 |
+
|
309 |
+
wp_editor(
|
310 |
+
members_get_setting( 'private_feed_error' ),
|
311 |
+
'members_settings_private_feed_error',
|
312 |
+
array(
|
313 |
+
'textarea_name' => 'members_settings[private_feed_error]',
|
314 |
+
'drag_drop_upload' => true,
|
315 |
+
'editor_height' => 250
|
316 |
+
)
|
317 |
+
);
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Renders the settings page.
|
322 |
+
*
|
323 |
+
* @since 2.0.0
|
324 |
+
* @access public
|
325 |
+
* @return void
|
326 |
+
*/
|
327 |
+
public function template() { ?>
|
328 |
+
|
329 |
+
<form method="post" action="options.php">
|
330 |
+
<?php settings_fields( 'members_settings' ); ?>
|
331 |
+
<?php do_settings_sections( 'members-settings' ); ?>
|
332 |
+
<?php submit_button( esc_attr__( 'Update Settings', 'members' ), 'primary' ); ?>
|
333 |
+
</form>
|
334 |
+
|
335 |
+
<?php }
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Adds help tabs.
|
339 |
+
*
|
340 |
+
* @since 2.0.0
|
341 |
+
* @access public
|
342 |
+
* @return void
|
343 |
+
*/
|
344 |
+
public function add_help_tabs() {
|
345 |
+
|
346 |
+
// Get the current screen.
|
347 |
+
$screen = get_current_screen();
|
348 |
+
|
349 |
+
// Roles/Caps help tab.
|
350 |
+
$screen->add_help_tab(
|
351 |
+
array(
|
352 |
+
'id' => 'roles-caps',
|
353 |
+
'title' => esc_html__( 'Role and Capabilities', 'members' ),
|
354 |
+
'callback' => array( $this, 'help_tab_roles_caps' )
|
355 |
+
)
|
356 |
+
);
|
357 |
+
|
358 |
+
// Content Permissions help tab.
|
359 |
+
$screen->add_help_tab(
|
360 |
+
array(
|
361 |
+
'id' => 'content-permissions',
|
362 |
+
'title' => esc_html__( 'Content Permissions', 'members' ),
|
363 |
+
'callback' => array( $this, 'help_tab_content_permissions' )
|
364 |
+
)
|
365 |
+
);
|
366 |
+
|
367 |
+
// Widgets help tab.
|
368 |
+
$screen->add_help_tab(
|
369 |
+
array(
|
370 |
+
'id' => 'sidebar-widgets',
|
371 |
+
'title' => esc_html__( 'Sidebar Widgets', 'members' ),
|
372 |
+
'callback' => array( $this, 'help_tab_sidebar_widgets' )
|
373 |
+
)
|
374 |
+
);
|
375 |
+
|
376 |
+
// Private Site help tab.
|
377 |
+
$screen->add_help_tab(
|
378 |
+
array(
|
379 |
+
'id' => 'private-site',
|
380 |
+
'title' => esc_html__( 'Private Site', 'members' ),
|
381 |
+
'callback' => array( $this, 'help_tab_private_site' )
|
382 |
+
)
|
383 |
+
);
|
384 |
+
|
385 |
+
// Set the help sidebar.
|
386 |
+
$screen->set_help_sidebar( members_get_help_sidebar_text() );
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Displays the roles/caps help tab.
|
391 |
+
*
|
392 |
+
* @since 2.0.0
|
393 |
+
* @access public
|
394 |
+
* @return void
|
395 |
+
*/
|
396 |
+
public function help_tab_roles_caps() { ?>
|
397 |
+
|
398 |
+
<p>
|
399 |
+
<?php esc_html_e( 'The role manager allows you to manage roles on your site by giving you the ability to create, edit, and delete any role. Note that changes to roles do not change settings for the Members plugin. You are literally changing data in your WordPress database. This plugin feature merely provides an interface for you to make these changes.', 'members' ); ?>
|
400 |
+
</p>
|
401 |
+
|
402 |
+
<p>
|
403 |
+
<?php esc_html_e( 'The multiple user roles feature allows you to assign more than one role to each user from the edit user screen.', 'members' ); ?>
|
404 |
+
</p>
|
405 |
+
|
406 |
+
<p>
|
407 |
+
<?php esc_html_e( 'Tick the checkbox for denied capabilities to always take precedence over granted capabilities when there is a conflict. This is only relevant when using multiple roles per user.', 'members' ); ?>
|
408 |
+
</p>
|
409 |
+
|
410 |
+
<p>
|
411 |
+
<?php esc_html_e( 'Tick the checkbox to show human-readable capabilities when possible. Note that custom capabilities and capabilities from third-party plugins will show the machine-readable capability name unless they are registered.', 'members' ); ?>
|
412 |
+
</p>
|
413 |
+
<?php }
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Displays the content permissions help tab.
|
417 |
+
*
|
418 |
+
* @since 2.0.0
|
419 |
+
* @access public
|
420 |
+
* @return void
|
421 |
+
*/
|
422 |
+
public function help_tab_content_permissions() { ?>
|
423 |
+
|
424 |
+
<p>
|
425 |
+
<?php printf( esc_html__( "The content permissions features adds a meta box to the edit post screen that allows you to grant permissions for who can read the post content based on the user's role. Only users of roles with the %s capability will be able to use this component.", 'members' ), '<code>restrict_content</code>' ); ?>
|
426 |
+
</p>
|
427 |
+
<?php }
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Displays the sidebar widgets help tab.
|
431 |
+
*
|
432 |
+
* @since 2.0.0
|
433 |
+
* @access public
|
434 |
+
* @return void
|
435 |
+
*/
|
436 |
+
public function help_tab_sidebar_widgets() { ?>
|
437 |
+
|
438 |
+
<p>
|
439 |
+
<?php esc_html_e( "The sidebar widgets feature adds additional widgets for use in your theme's sidebars.", 'members' ); ?>
|
440 |
+
</p>
|
441 |
+
<?php }
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Displays the private site help tab.
|
445 |
+
*
|
446 |
+
* @since 2.0.0
|
447 |
+
* @access public
|
448 |
+
* @return void
|
449 |
+
*/
|
450 |
+
public function help_tab_private_site() { ?>
|
451 |
+
|
452 |
+
<p>
|
453 |
+
<?php esc_html_e( 'The private site feature redirects all users who are not logged into the site to the login page, creating an entirely private site. You may also replace your feed content with a custom error message.', 'members' ); ?>
|
454 |
+
</p>
|
455 |
+
<?php }
|
456 |
+
}
|
admin/views/class-view.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Base class for creating custom settings views.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members\Admin;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Settings view base class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
abstract class View {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Name/ID for the group.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access protected
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $name = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Internationalized text label for the group.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access protected
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $label = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Priority (order) the control should be output.
|
43 |
+
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access public
|
46 |
+
* @var int
|
47 |
+
*/
|
48 |
+
public $priority = 10;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* A user role capability required to show the control.
|
52 |
+
*
|
53 |
+
* @since 2.0.0
|
54 |
+
* @access public
|
55 |
+
* @var string|array
|
56 |
+
*/
|
57 |
+
public $capability = 'manage_options';
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Magic method to use in case someone tries to output the object as a string.
|
61 |
+
* We'll just return the name.
|
62 |
+
*
|
63 |
+
* @since 2.0.0
|
64 |
+
* @access public
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function __toString() {
|
68 |
+
return $this->name;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Register a new object.
|
73 |
+
*
|
74 |
+
* @since 2.0.0
|
75 |
+
* @access public
|
76 |
+
* @param string $name
|
77 |
+
* @param array $args {
|
78 |
+
* @type string $label Internationalized text label.
|
79 |
+
* @type string $icon Dashicon icon in the form of `dashicons-icon-name`.
|
80 |
+
* @type string $callback Callback function for outputting the content for the view.
|
81 |
+
* }
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function __construct( $name, $args = array() ) {
|
85 |
+
|
86 |
+
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
87 |
+
|
88 |
+
if ( isset( $args[ $key ] ) )
|
89 |
+
$this->$key = $args[ $key ];
|
90 |
+
}
|
91 |
+
|
92 |
+
$this->name = sanitize_key( $name );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Runs on the `load-{$page}` hook
|
97 |
+
*
|
98 |
+
* @since 2.0.0
|
99 |
+
* @access public
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function load() {}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Enqueue scripts/styles for the control.
|
106 |
+
*
|
107 |
+
* @since 2.0.0
|
108 |
+
* @access public
|
109 |
+
* @return void
|
110 |
+
*/
|
111 |
+
public function enqueue() {}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Register settings for the view.
|
115 |
+
*
|
116 |
+
* @since 2.0.0
|
117 |
+
* @access public
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function register_settings() {}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Add help tabs for the view.
|
124 |
+
*
|
125 |
+
* @since 2.0.0
|
126 |
+
* @access public
|
127 |
+
* @return void
|
128 |
+
*/
|
129 |
+
public function add_help_tabs() {}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Output the content for the view.
|
133 |
+
*
|
134 |
+
* @since 2.0.0
|
135 |
+
* @access public
|
136 |
+
* @return void
|
137 |
+
*/
|
138 |
+
public function template() {}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Checks if the control should be allowed at all.
|
142 |
+
*
|
143 |
+
* @since 2.0.0
|
144 |
+
* @access public
|
145 |
+
* @return bool
|
146 |
+
*/
|
147 |
+
public function check_capabilities() {
|
148 |
+
|
149 |
+
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
|
150 |
+
return false;
|
151 |
+
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
}
|
changelog.md
CHANGED
@@ -1,6 +1,46 @@
|
|
1 |
# Change Log
|
2 |
|
3 |
-
## [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
### Fixed
|
6 |
|
1 |
# Change Log
|
2 |
|
3 |
+
## [2.0.0] - 2017-07-19
|
4 |
+
|
5 |
+
### Added
|
6 |
+
|
7 |
+
* Created a new admin view system, where there can be multiple views ("tabs", if you like) on the settings screen and other potential screens in the future.
|
8 |
+
* Added an "Add-Ons" view for the Members Settings page, which lists add-ons for the plugin. The default add-ons are pulled from Theme Hybrid.
|
9 |
+
* Created an add-ons API for other developers to list their own add-ons.
|
10 |
+
* Created a capability registration system and API for plugin developers to register their capabilities with Members. The major benefit of this is having internationalized labels for capabilities.
|
11 |
+
* Registered all of the core capabilities with human-readable, internationalized text labels so that users who do not speak English can benefit from capability translations.
|
12 |
+
* Added the `members_enable_{$post_type}_content_permissions` filter hook to allow developers to enable/disable content permissions per post type.
|
13 |
+
* Removed the core "Change Role" feature on the manage users screen and replaced it with an "Add Role" and "Remove Role" feature for bulk editing users. Note that this only appears when multiple roles is enabled.
|
14 |
+
* Add a multi-role checkbox on the Add User screen when multiple roles are enabled.
|
15 |
+
* Added a `members_has_post_roles()` conditional tag for checking if a post has content permissions roles assigned to it.
|
16 |
+
* Added the `operator` parameter, which accepts a value of `!`, for the `[members_access]` shortcode. This allows users to negate the role or cap they've passed in.
|
17 |
+
|
18 |
+
### Changed
|
19 |
+
|
20 |
+
* Roles states on the manage role screen now have array keys so they can more easily be overwritten.
|
21 |
+
* Created a `.wp-tab-panel` wrapper around the user roles checklist on the edit user screen. This is to prevent long lists of roles from taking up too much screen space.
|
22 |
+
* Moved the All capability tab to the bottom of the capability tabs list.
|
23 |
+
* Removed the All cap group, since it is not a true cap group.
|
24 |
+
* Removed the All, Mine, Active, Inactive, Editable, and Uneditable role groups. These are merely views for the role management screen. They are not true role groups.
|
25 |
+
* Created a new, internal registry class for storing various collections of data. Note that this does break back-compat for developers who were directly accessing factory classes in previous versions rather than using the wrapper functions.
|
26 |
+
* Old classes were added to the `Members` namespace or `Members\Admin` namespace. Again, this breaks back-compat for anyone not using the appropriate wrapper functions. This also bumps the requirement to PHP 5.3.0+.
|
27 |
+
* Changed the text in the Content Permissions meta box to not specifically use the term "post".
|
28 |
+
* Changed the Content Permissions meta box to have a tabbed UI so that it doesn't take up so much screen space.
|
29 |
+
* Replaced the basic textarea with the WP editor in the Content Permissions meta box.
|
30 |
+
|
31 |
+
### Fixed
|
32 |
+
|
33 |
+
* No longer save content permissions on autosave or for post revisions.
|
34 |
+
* Prevent users from adding the internal core WP `do_not_allow` capability to their role.
|
35 |
+
* On multisite with the private site feature enabled, block access to logged-in users who do not have access to the specific blog.
|
36 |
+
* Make sure comments show an error in the comments feed if they belong to a private post.
|
37 |
+
|
38 |
+
### Security
|
39 |
+
|
40 |
+
* General hardening and use of some better functions for escaping.
|
41 |
+
* Added a private REST API option for users who are utilizing the private site feature. Users will likely want to enable this. Otherwise, their "private site" is exposed via the REST API endpoints.
|
42 |
+
|
43 |
+
## [1.1.3] - 2017-02-06
|
44 |
|
45 |
### Fixed
|
46 |
|
composer.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "justintadlock/members",
|
3 |
+
"description" : "A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private.",
|
4 |
+
"keywords" : ["wordpress"],
|
5 |
+
"homepage" : "https://themehybrid.com/plugins/members",
|
6 |
+
"license" : "GPL-2.0+",
|
7 |
+
"type" : "wordpress-plugin",
|
8 |
+
"authors" : [
|
9 |
+
{
|
10 |
+
"name" : "Justin Tadlock",
|
11 |
+
"email" : "justintadlock@gmail.com",
|
12 |
+
"homepage" : "http://justintadlock.com"
|
13 |
+
}
|
14 |
+
],
|
15 |
+
"require" : {
|
16 |
+
"composer/installers" : "^1.0",
|
17 |
+
"php" : ">=5.3.0"
|
18 |
+
},
|
19 |
+
"support" : {
|
20 |
+
"issues": "https://github.com/justintadlock/members/issues",
|
21 |
+
"forum" : "https://themehybrid.com/board/topics"
|
22 |
+
}
|
23 |
+
}
|
css/admin.css
CHANGED
@@ -38,19 +38,21 @@
|
|
38 |
|
39 |
#tabcapsdiv { margin-top: 1em; }
|
40 |
|
41 |
-
#tabcapsdiv >
|
42 |
padding: 10px;
|
43 |
border-bottom: 1px solid #eee;
|
44 |
}
|
45 |
|
46 |
-
#tabcapsdiv .inside
|
|
|
47 |
margin: 0;
|
48 |
padding: 0;
|
49 |
}
|
50 |
|
51 |
/* Tabs wrapper. */
|
52 |
|
53 |
-
.members-cap-tabs
|
|
|
54 |
overflow: hidden;
|
55 |
background: #fff;
|
56 |
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 20%, #fff 20%, #fff 100% );
|
@@ -58,14 +60,16 @@
|
|
58 |
|
59 |
@media only screen and ( max-width: 782px ) {
|
60 |
|
61 |
-
.members-cap-tabs
|
|
|
62 |
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 48px, #fff 48px, #fff 100% );
|
63 |
}
|
64 |
}
|
65 |
|
66 |
/* Tab nav. */
|
67 |
|
68 |
-
.members-cap-tabs .members-tab-nav
|
|
|
69 |
position: relative;
|
70 |
float: left;
|
71 |
list-style: none;
|
@@ -78,7 +82,8 @@
|
|
78 |
box-sizing: border-box;
|
79 |
}
|
80 |
|
81 |
-
.members-cap-tabs .members-tab-nav li
|
|
|
82 |
display: block;
|
83 |
position: relative;
|
84 |
margin: 0;
|
@@ -86,7 +91,8 @@
|
|
86 |
line-height: 20px;
|
87 |
}
|
88 |
|
89 |
-
.members-cap-tabs .members-tab-nav li a
|
|
|
90 |
display: block;
|
91 |
margin: 0;
|
92 |
padding: 10px;
|
@@ -96,12 +102,14 @@
|
|
96 |
box-shadow: none;
|
97 |
}
|
98 |
|
99 |
-
.members-cap-tabs .members-tab-nav li a .dashicons
|
|
|
100 |
line-height: 20px;
|
101 |
margin-right: 3px;
|
102 |
}
|
103 |
|
104 |
-
.members-cap-tabs .members-tab-nav li[aria-selected="true"] a
|
|
|
105 |
position: relative;
|
106 |
font-weight: bold;
|
107 |
color: #555;
|
@@ -110,15 +118,18 @@
|
|
110 |
|
111 |
@media only screen and ( max-width: 782px ) {
|
112 |
|
113 |
-
.members-cap-tabs .members-tab-nav
|
|
|
114 |
|
115 |
-
.members-cap-tabs .members-tab-nav li a .dashicons
|
|
|
116 |
width: 24px;
|
117 |
height: 24px;
|
118 |
font-size: 24px;
|
119 |
line-height: 24px;
|
120 |
}
|
121 |
|
|
|
122 |
.members-tab-nav li .dashicons::before {
|
123 |
width: 24px;
|
124 |
height: 24px;
|
@@ -136,7 +147,8 @@
|
|
136 |
|
137 |
/* Tab content wrapper */
|
138 |
|
139 |
-
.members-cap-tabs .members-tab-wrap
|
|
|
140 |
float: left;
|
141 |
width: 80%;
|
142 |
margin-left: -1px;
|
@@ -144,11 +156,87 @@
|
|
144 |
|
145 |
@media only screen and ( max-width: 782px ) {
|
146 |
|
147 |
-
.members-cap-tabs .members-tab-wrap
|
|
|
148 |
width: calc( 100% - 48px );
|
149 |
}
|
150 |
}
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
/* Tab tables. */
|
153 |
|
154 |
#tabcapsdiv table {
|
38 |
|
39 |
#tabcapsdiv { margin-top: 1em; }
|
40 |
|
41 |
+
#tabcapsdiv > .hndle {
|
42 |
padding: 10px;
|
43 |
border-bottom: 1px solid #eee;
|
44 |
}
|
45 |
|
46 |
+
#tabcapsdiv .inside,
|
47 |
+
#members-cp .inside {
|
48 |
margin: 0;
|
49 |
padding: 0;
|
50 |
}
|
51 |
|
52 |
/* Tabs wrapper. */
|
53 |
|
54 |
+
.members-cap-tabs,
|
55 |
+
.members-tabs {
|
56 |
overflow: hidden;
|
57 |
background: #fff;
|
58 |
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 20%, #fff 20%, #fff 100% );
|
60 |
|
61 |
@media only screen and ( max-width: 782px ) {
|
62 |
|
63 |
+
.members-cap-tabs,
|
64 |
+
.members-tabs {
|
65 |
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 48px, #fff 48px, #fff 100% );
|
66 |
}
|
67 |
}
|
68 |
|
69 |
/* Tab nav. */
|
70 |
|
71 |
+
.members-cap-tabs .members-tab-nav,
|
72 |
+
.members-tabs .members-tab-nav {
|
73 |
position: relative;
|
74 |
float: left;
|
75 |
list-style: none;
|
82 |
box-sizing: border-box;
|
83 |
}
|
84 |
|
85 |
+
.members-cap-tabs .members-tab-nav li,
|
86 |
+
.members-tabs .members-tab-nav li {
|
87 |
display: block;
|
88 |
position: relative;
|
89 |
margin: 0;
|
91 |
line-height: 20px;
|
92 |
}
|
93 |
|
94 |
+
.members-cap-tabs .members-tab-nav li a,
|
95 |
+
.members-tabs .members-tab-nav li a {
|
96 |
display: block;
|
97 |
margin: 0;
|
98 |
padding: 10px;
|
102 |
box-shadow: none;
|
103 |
}
|
104 |
|
105 |
+
.members-cap-tabs .members-tab-nav li a .dashicons,
|
106 |
+
.members-tabs .members-tab-nav li a .dashicons {
|
107 |
line-height: 20px;
|
108 |
margin-right: 3px;
|
109 |
}
|
110 |
|
111 |
+
.members-cap-tabs .members-tab-nav li[aria-selected="true"] a,
|
112 |
+
.members-tabs .members-tab-nav li[aria-selected="true"] a {
|
113 |
position: relative;
|
114 |
font-weight: bold;
|
115 |
color: #555;
|
118 |
|
119 |
@media only screen and ( max-width: 782px ) {
|
120 |
|
121 |
+
.members-cap-tabs .members-tab-nav,
|
122 |
+
.members-tabs .members-tab-nav { width: 48px; }
|
123 |
|
124 |
+
.members-cap-tabs .members-tab-nav li a .dashicons,
|
125 |
+
.members-tabs .members-tab-nav li a .dashicons {
|
126 |
width: 24px;
|
127 |
height: 24px;
|
128 |
font-size: 24px;
|
129 |
line-height: 24px;
|
130 |
}
|
131 |
|
132 |
+
.members-tab-nav li .dashicons::before,
|
133 |
.members-tab-nav li .dashicons::before {
|
134 |
width: 24px;
|
135 |
height: 24px;
|
147 |
|
148 |
/* Tab content wrapper */
|
149 |
|
150 |
+
.members-cap-tabs .members-tab-wrap,
|
151 |
+
.members-tabs .members-tab-wrap {
|
152 |
float: left;
|
153 |
width: 80%;
|
154 |
margin-left: -1px;
|
156 |
|
157 |
@media only screen and ( max-width: 782px ) {
|
158 |
|
159 |
+
.members-cap-tabs .members-tab-wrap,
|
160 |
+
.members-tabs .members-tab-wrap {
|
161 |
width: calc( 100% - 48px );
|
162 |
}
|
163 |
}
|
164 |
|
165 |
+
#members-cp .members-tab-content {
|
166 |
+
padding: 10px;
|
167 |
+
border-left: 1px solid #e5e5e5;
|
168 |
+
}
|
169 |
+
|
170 |
+
/* === Manager when in the side meta box. === */
|
171 |
+
|
172 |
+
@media only screen and ( min-width: 850px ) {
|
173 |
+
|
174 |
+
#side-sortables .members-tabs { background: #fff; }
|
175 |
+
|
176 |
+
#side-sortables .members-tabs .members-tab-wrap { width: 100%; }
|
177 |
+
|
178 |
+
#side-sortables .members-tabs .members-tab-nav {
|
179 |
+
display: table;
|
180 |
+
width: 100%;
|
181 |
+
}
|
182 |
+
|
183 |
+
#side-sortables .members-tabs .members-tab-nav li {
|
184 |
+
display: table-cell;
|
185 |
+
text-align: center;
|
186 |
+
border-right: 1px solid #eee;
|
187 |
+
}
|
188 |
+
|
189 |
+
#side-sortables .members-tabs .members-tab-nav li:last-of-type { border-right: none; }
|
190 |
+
|
191 |
+
#side-sortables .members-tabs .members-tab-nav li a {
|
192 |
+
padding: 10px 0;
|
193 |
+
}
|
194 |
+
|
195 |
+
#side-sortables .members-tabs .members-tab-nav .dashicons {
|
196 |
+
width: 24px;
|
197 |
+
height: 24px;
|
198 |
+
font-size: 24px;
|
199 |
+
line-height: 24px;
|
200 |
+
}
|
201 |
+
|
202 |
+
#side-sortables .members-tabs .members-tab-nav .dashicons::before {
|
203 |
+
width: 24px;
|
204 |
+
height: 24px;
|
205 |
+
}
|
206 |
+
|
207 |
+
#side-sortables .members-tabs .members-tab-nav .label {
|
208 |
+
overflow: hidden;
|
209 |
+
position: absolute;
|
210 |
+
top: -1000em;
|
211 |
+
left: -1000em;
|
212 |
+
width: 1px;
|
213 |
+
height: 1px;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
.members-tabs .members-tabs-label {
|
219 |
+
display : block !important;
|
220 |
+
font-weight : bold;
|
221 |
+
display : inline-block;
|
222 |
+
margin-bottom : 4px;
|
223 |
+
}
|
224 |
+
|
225 |
+
.members-tabs .butterbean-control-checkbox .members-tabs-label {
|
226 |
+
display: inline !important;
|
227 |
+
}
|
228 |
+
|
229 |
+
.members-tabs .members-tabs-description {
|
230 |
+
display : block;
|
231 |
+
font-style : italic;
|
232 |
+
margin-top : 4px;
|
233 |
+
}
|
234 |
+
|
235 |
+
.members-tabs .members-tabs-label + .members-tabs-description {
|
236 |
+
margin-top : 0;
|
237 |
+
margin-bottom : 4px;
|
238 |
+
}
|
239 |
+
|
240 |
/* Tab tables. */
|
241 |
|
242 |
#tabcapsdiv table {
|
css/admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
@media only screen and (min-width:783px){.users_page_roles .column-
|
1 |
+
@media only screen and (min-width:783px){.users_page_roles .column-denied_caps,.users_page_roles .column-granted_caps,.users_page_roles .column-users{width:100px;text-align:center}}.members-title-div #titlewrap input{padding:0 8px;font-size:1.7em;line-height:normal;height:1.7em;width:100%;outline:0;margin:0 0 3px;background-color:#fff}.members-title-div input[name=role]{font-size:13px;height:22px;margin:0;width:16em}#tabcapsdiv{margin-top:1em}#tabcapsdiv>.hndle{padding:10px;border-bottom:1px solid #eee}#members-cp .inside,#tabcapsdiv .inside{margin:0;padding:0}.members-cap-tabs,.members-tabs{overflow:hidden;background:#fff;background:linear-gradient(90deg,#fafafa 0,#fafafa 20%,#fff 20%,#fff 100%)}@media only screen and (max-width:782px){.members-cap-tabs,.members-tabs{background:linear-gradient(90deg,#fafafa 0,#fafafa 48px,#fff 48px,#fff 100%)}}.members-cap-tabs .members-tab-nav,.members-tabs .members-tab-nav{position:relative;float:left;list-style:none;width:20%;line-height:1em;margin:0 0 -1px 0;padding:0;background-color:#fafafa;border-right:1px solid #eee;box-sizing:border-box}.members-cap-tabs .members-tab-nav li,.members-tabs .members-tab-nav li{display:block;position:relative;margin:0;padding:0;line-height:20px}.members-cap-tabs .members-tab-nav li a,.members-tabs .members-tab-nav li a{display:block;margin:0;padding:10px;line-height:20px!important;text-decoration:none;border-bottom:1px solid #eee;box-shadow:none}.members-cap-tabs .members-tab-nav li a .dashicons,.members-tabs .members-tab-nav li a .dashicons{line-height:20px;margin-right:3px}.members-cap-tabs .members-tab-nav li[aria-selected=true] a,.members-tabs .members-tab-nav li[aria-selected=true] a{position:relative;font-weight:700;color:#555;background-color:#e0e0e0}@media only screen and (max-width:782px){.members-cap-tabs .members-tab-nav,.members-tabs .members-tab-nav{width:48px}.members-cap-tabs .members-tab-nav li a .dashicons,.members-tabs .members-tab-nav li a .dashicons{width:24px;height:24px;font-size:24px;line-height:24px}.members-tab-nav li .dashicons::before{width:24px;height:24px}.members-tab-nav li .label{overflow:hidden;position:absolute;top:-1000em;left:-1000em;width:1px;height:1px}}.members-cap-tabs .members-tab-wrap,.members-tabs .members-tab-wrap{float:left;width:80%;margin-left:-1px}@media only screen and (max-width:782px){.members-cap-tabs .members-tab-wrap,.members-tabs .members-tab-wrap{width:calc(100% - 48px)}}#members-cp .members-tab-content{padding:10px;border-left:1px solid #e5e5e5}@media only screen and (min-width:850px){#side-sortables .members-tabs{background:#fff}#side-sortables .members-tabs .members-tab-wrap{width:100%}#side-sortables .members-tabs .members-tab-nav{display:table;width:100%}#side-sortables .members-tabs .members-tab-nav li{display:table-cell;text-align:center;border-right:1px solid #eee}#side-sortables .members-tabs .members-tab-nav li:last-of-type{border-right:none}#side-sortables .members-tabs .members-tab-nav li a{padding:10px 0}#side-sortables .members-tabs .members-tab-nav .dashicons{width:24px;height:24px;font-size:24px;line-height:24px}#side-sortables .members-tabs .members-tab-nav .dashicons::before{width:24px;height:24px}#side-sortables .members-tabs .members-tab-nav .label{overflow:hidden;position:absolute;top:-1000em;left:-1000em;width:1px;height:1px}}.members-tabs .members-tabs-label{display:block!important;font-weight:700;display:inline-block;margin-bottom:4px}.members-tabs .butterbean-control-checkbox .members-tabs-label{display:inline!important}.members-tabs .members-tabs-description{display:block;font-style:italic;margin-top:4px}.members-tabs .members-tabs-label+.members-tabs-description{margin-top:0;margin-bottom:4px}#tabcapsdiv table{border-right:none;border-top:none;border-bottom:none}#tabcapsdiv table td,#tabcapsdiv table th{padding:10px;padding-bottom:10px;border-bottom:1px solid #eee;font-size:13px;line-height:20px}#tabcapsdiv table td{padding:9px}#tabcapsdiv tbody tr:last-of-type td{border-bottom:none}#tabcapsdiv tfoot th{border-color:#eee}@media only screen and (max-width:782px){#tabcapsdiv table td,#tabcapsdiv table th{line-height:24px}}.members-roles-select .column-deny,.members-roles-select .column-grant{width:70px!important;text-align:center;display:table-cell!important;clear:none!important}.members-cap-tabs button{display:inline;margin:-4px;line-height:inherit;padding:4px 8px;border:1px solid transparent;background:0 0;border-radius:0;outline:0;-webkit-transition:all .25s ease-out;-moz-transition:all .25s ease-out;-o-transition:all .25s ease-out;transition:all .25s ease-out}.members-cap-tabs button:focus,.members-cap-tabs button:hover{border-color:#eee;background:#fafafa;cursor:pointer}.members-cap-tabs button:active{color:#0073aa;border-color:#0073aa}.members-cap-tabs button+.dashicons{display:none;margin-top:1px;margin-bottom:-1px;line-height:inherit}.members-cap-tabs button:focus+.dashicons,.members-cap-tabs button:hover+.dashicons{display:inline-block}.members-tab-content .members-highlight{background-color:rgba(0,115,170,.05)}.members-tab-content tbody{-webkit-transition:all 2s ease-in-out;-moz-transition:all 2s ease-in-out;-o-transition:all 2s ease-in-out;transition:all 2s ease-in-out}.members-cp-role-list-wrap{overflow:auto;min-height:42px;max-height:200px;padding:0 .9em;border:solid 1px #dfdfdf;background-color:#fdfdfd}
|
img/icon-addon.png
ADDED
Binary file
|
img/icon-members-role-hierarchy.png
ADDED
Binary file
|
img/icon-members-role-levels.png
ADDED
Binary file
|
{admin → inc}/class-cap-group.php
RENAMED
@@ -4,25 +4,27 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Capability group object class.
|
15 |
*
|
16 |
-
* @since
|
17 |
* @access public
|
18 |
*/
|
19 |
-
final class
|
20 |
|
21 |
/**
|
22 |
* Name/ID for the group.
|
23 |
*
|
24 |
-
* @since
|
25 |
-
* @access
|
26 |
* @var string
|
27 |
*/
|
28 |
public $name = '';
|
@@ -30,8 +32,8 @@ final class Members_Cap_Group {
|
|
30 |
/**
|
31 |
* Internationalized text label for the group.
|
32 |
*
|
33 |
-
* @since
|
34 |
-
* @access
|
35 |
* @var string
|
36 |
*/
|
37 |
public $label = '';
|
@@ -39,8 +41,8 @@ final class Members_Cap_Group {
|
|
39 |
/**
|
40 |
* Icon for the group. This can be a dashicons class or a custom class.
|
41 |
*
|
42 |
-
* @since
|
43 |
-
* @access
|
44 |
* @var string
|
45 |
*/
|
46 |
public $icon = 'dashicons-admin-generic';
|
@@ -48,26 +50,26 @@ final class Members_Cap_Group {
|
|
48 |
/**
|
49 |
* Capabilities for the group.
|
50 |
*
|
51 |
-
* @since
|
52 |
-
* @access
|
53 |
* @var array
|
54 |
*/
|
55 |
-
public $caps = array(
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
-
* @since
|
61 |
-
* @access
|
62 |
-
* @var
|
63 |
*/
|
64 |
-
public $
|
65 |
|
66 |
/**
|
67 |
* Whether to remove previously-added caps from this group's caps.
|
68 |
*
|
69 |
-
* @since
|
70 |
-
* @access
|
71 |
* @var bool
|
72 |
*/
|
73 |
public $diff_added = false;
|
@@ -76,7 +78,7 @@ final class Members_Cap_Group {
|
|
76 |
* Magic method to use in case someone tries to output the object as a string.
|
77 |
* We'll just return the name.
|
78 |
*
|
79 |
-
* @since
|
80 |
* @access public
|
81 |
* @return string
|
82 |
*/
|
@@ -87,7 +89,7 @@ final class Members_Cap_Group {
|
|
87 |
/**
|
88 |
* Register a new object.
|
89 |
*
|
90 |
-
* @since
|
91 |
* @access public
|
92 |
* @param string $name
|
93 |
* @param array $args {
|
@@ -109,6 +111,10 @@ final class Members_Cap_Group {
|
|
109 |
|
110 |
$this->name = sanitize_key( $name );
|
111 |
|
|
|
|
|
|
|
|
|
112 |
$this->caps = members_remove_hidden_caps( $this->caps );
|
113 |
}
|
114 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
/**
|
16 |
* Capability group object class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
final class Cap_Group {
|
22 |
|
23 |
/**
|
24 |
* Name/ID for the group.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
* @var string
|
29 |
*/
|
30 |
public $name = '';
|
32 |
/**
|
33 |
* Internationalized text label for the group.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access public
|
37 |
* @var string
|
38 |
*/
|
39 |
public $label = '';
|
41 |
/**
|
42 |
* Icon for the group. This can be a dashicons class or a custom class.
|
43 |
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access public
|
46 |
* @var string
|
47 |
*/
|
48 |
public $icon = 'dashicons-admin-generic';
|
50 |
/**
|
51 |
* Capabilities for the group.
|
52 |
*
|
53 |
+
* @since 2.0.0
|
54 |
+
* @access public
|
55 |
* @var array
|
56 |
*/
|
57 |
+
public $caps = array();
|
58 |
|
59 |
/**
|
60 |
+
* Sort order priority.
|
61 |
*
|
62 |
+
* @since 2.0.0
|
63 |
+
* @access public
|
64 |
+
* @var int
|
65 |
*/
|
66 |
+
public $priority = 10;
|
67 |
|
68 |
/**
|
69 |
* Whether to remove previously-added caps from this group's caps.
|
70 |
*
|
71 |
+
* @since 2.0.0
|
72 |
+
* @access public
|
73 |
* @var bool
|
74 |
*/
|
75 |
public $diff_added = false;
|
78 |
* Magic method to use in case someone tries to output the object as a string.
|
79 |
* We'll just return the name.
|
80 |
*
|
81 |
+
* @since 2.0.0
|
82 |
* @access public
|
83 |
* @return string
|
84 |
*/
|
89 |
/**
|
90 |
* Register a new object.
|
91 |
*
|
92 |
+
* @since 2.0.0
|
93 |
* @access public
|
94 |
* @param string $name
|
95 |
* @param array $args {
|
111 |
|
112 |
$this->name = sanitize_key( $name );
|
113 |
|
114 |
+
$registered_caps = array_keys( wp_list_filter( members_get_caps(), array( 'group' => $this->name ) ) );
|
115 |
+
|
116 |
+
$this->caps = array_unique( array_merge( $this->caps, $registered_caps ) );
|
117 |
+
|
118 |
$this->caps = members_remove_hidden_caps( $this->caps );
|
119 |
}
|
120 |
}
|
inc/class-capability.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Creates a new capability object.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Capability class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
class Capability {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* The capability name.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $name = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* The capability label.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access public
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $label = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The group the capability belongs to.
|
43 |
+
*
|
44 |
+
* @see Members_Cap_Group
|
45 |
+
* @since 2.0.0
|
46 |
+
* @access public
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
public $group = '';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Return the role string in attempts to use the object as a string.
|
53 |
+
*
|
54 |
+
* @since 2.0.0
|
55 |
+
* @access public
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function __toString() {
|
59 |
+
return $this->name;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Creates a new role object.
|
64 |
+
*
|
65 |
+
* @since 2.0.0
|
66 |
+
* @access public
|
67 |
+
* @global object $wp_roles
|
68 |
+
* @param string $role
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function __construct( $name, $args = array() ) {
|
72 |
+
|
73 |
+
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
74 |
+
|
75 |
+
if ( isset( $args[ $key ] ) )
|
76 |
+
$this->$key = $args[ $key ];
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->name = sanitize_key( $name );
|
80 |
+
}
|
81 |
+
}
|
inc/class-registry.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Registry class for storing collections of data.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Base registry class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
class Registry {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Registry instances.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access private
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
private static $instances = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Array of items in the collection.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access protected
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
protected $collection = array();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor method.
|
43 |
+
*
|
44 |
+
* @since 2.0.0
|
45 |
+
* @access protected
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
protected function __construct() {}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Lock down `__clone()`.
|
52 |
+
*
|
53 |
+
* @since 2.0.0
|
54 |
+
* @access private
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
private function __clone() {}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Lock down `__wakeup()`.
|
61 |
+
*
|
62 |
+
* @since 2.0.0
|
63 |
+
* @access private
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
private function __wakeup() {}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Register an item.
|
70 |
+
*
|
71 |
+
* @since 2.0.0
|
72 |
+
* @access public
|
73 |
+
* @param string $name
|
74 |
+
* @param mixed $value
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function register( $name, $value ) {
|
78 |
+
|
79 |
+
if ( ! $this->exists( $name ) )
|
80 |
+
$this->collection[ $name ] = $value;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Unregisters an item.
|
85 |
+
*
|
86 |
+
* @since 2.0.0
|
87 |
+
* @access public
|
88 |
+
* @param string $name
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
+
public function unregister( $name ) {
|
92 |
+
|
93 |
+
if ( $this->exists( $name ) )
|
94 |
+
unset( $this->collection[ $name ] );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Checks if an item exists.
|
99 |
+
*
|
100 |
+
* @since 2.0.0
|
101 |
+
* @access public
|
102 |
+
* @param string $name
|
103 |
+
* @return bool
|
104 |
+
*/
|
105 |
+
public function exists( $name ) {
|
106 |
+
|
107 |
+
return isset( $this->collection[ $name ] );
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Returns an item.
|
112 |
+
*
|
113 |
+
* @since 2.0.0
|
114 |
+
* @access public
|
115 |
+
* @param string $name
|
116 |
+
* @return mixed
|
117 |
+
*/
|
118 |
+
public function get( $name ) {
|
119 |
+
|
120 |
+
return $this->exists( $name ) ? $this->collection[ $name ] : false;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Returns the entire collection.
|
125 |
+
*
|
126 |
+
* @since 2.0.0
|
127 |
+
* @access public
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
public function get_collection() {
|
131 |
+
|
132 |
+
return $this->collection;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Returns the instance.
|
137 |
+
*
|
138 |
+
* @since 2.0.0
|
139 |
+
* @access public
|
140 |
+
* @return object
|
141 |
+
*/
|
142 |
+
final public static function get_instance( $name = '' ) {
|
143 |
+
|
144 |
+
if ( ! isset( self::$instances[ $name ] ) )
|
145 |
+
self::$instances[ $name ] = new static();
|
146 |
+
|
147 |
+
return self::$instances[ $name ];
|
148 |
+
}
|
149 |
+
}
|
inc/class-role-factory.php
DELETED
@@ -1,165 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WordPress' `WP_Roles` and the global `$wp_roles` array don't really cut it. So, this is a
|
4 |
-
* singleton factory class for storing role objects and information that we need.
|
5 |
-
*
|
6 |
-
* @package Members
|
7 |
-
* @subpackage Includes
|
8 |
-
* @author Justin Tadlock <justin@justintadlock.com>
|
9 |
-
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
|
10 |
-
* @link http://themehybrid.com/plugins/members
|
11 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
-
*/
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Role factory class.
|
16 |
-
*
|
17 |
-
* @since 1.0.0
|
18 |
-
* @access public
|
19 |
-
*/
|
20 |
-
final class Members_Role_Factory {
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Array of roles added.
|
24 |
-
*
|
25 |
-
* @since 1.0.0
|
26 |
-
* @access public
|
27 |
-
* @var array
|
28 |
-
*/
|
29 |
-
public $roles = array();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Array of editable roles.
|
33 |
-
*
|
34 |
-
* @since 1.0.0
|
35 |
-
* @access public
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
public $editable = array();
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Array of uneditable roles.
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
* @access public
|
45 |
-
* @var array
|
46 |
-
*/
|
47 |
-
public $uneditable = array();
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Array of core WordPress roles.
|
51 |
-
*
|
52 |
-
* @since 1.0.0
|
53 |
-
* @access public
|
54 |
-
* @var array
|
55 |
-
*/
|
56 |
-
public $wordpress = array();
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Private constructor method to prevent a new instance of the object.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @access public
|
63 |
-
* @return void
|
64 |
-
*/
|
65 |
-
private function __construct() {}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Adds a role object.
|
69 |
-
*
|
70 |
-
* @since 1.0.0
|
71 |
-
* @access public
|
72 |
-
* @param string $role
|
73 |
-
* @return object
|
74 |
-
*/
|
75 |
-
public function add_role( $role ) {
|
76 |
-
|
77 |
-
// If the role exists with WP but hasn't been added.
|
78 |
-
if ( members_role_exists( $role ) ) {
|
79 |
-
|
80 |
-
// Get the role object.
|
81 |
-
$this->roles[ $role ] = new Members_Role( $role );
|
82 |
-
|
83 |
-
// Check if role is editable.
|
84 |
-
if ( $this->roles[ $role ]->is_editable )
|
85 |
-
$this->editable[ $role ] = $this->roles[ $role ];
|
86 |
-
else
|
87 |
-
$this->uneditable[ $role ] = $this->roles[ $role ];
|
88 |
-
|
89 |
-
// Is WP role?
|
90 |
-
if ( members_is_wordpress_role( $role ) )
|
91 |
-
$this->wordpress[ $role ] = $this->roles[ $role ];
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Returns a single role object.
|
97 |
-
*
|
98 |
-
* @since 1.0.0
|
99 |
-
* @access public
|
100 |
-
* @param string $role
|
101 |
-
* @return object
|
102 |
-
*/
|
103 |
-
public function get_role( $role ) {
|
104 |
-
|
105 |
-
return isset( $this->roles[ $role ] ) ? $this->roles[ $role ] : false;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Removes a role object (doesn't remove from DB).
|
110 |
-
*
|
111 |
-
* @since 1.1.0
|
112 |
-
* @access public
|
113 |
-
* @param string $role
|
114 |
-
* @return void
|
115 |
-
*/
|
116 |
-
public function remove_role( $role ) {
|
117 |
-
|
118 |
-
if ( isset( $this->roles[ $role ] ) )
|
119 |
-
unset( $this->roles[ $role ] );
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Returns an array of role objects.
|
124 |
-
*
|
125 |
-
* @since 1.0.0
|
126 |
-
* @access public
|
127 |
-
* @return array
|
128 |
-
*/
|
129 |
-
public function get_roles() {
|
130 |
-
return $this->roles;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Adds all the WP roles as role objects. Rather than running this elsewhere, we're just
|
135 |
-
* going to call this directly within the class when it is first constructed.
|
136 |
-
*
|
137 |
-
* @since 1.0.0
|
138 |
-
* @access public
|
139 |
-
* @return void
|
140 |
-
*/
|
141 |
-
protected function setup_roles() {
|
142 |
-
|
143 |
-
foreach ( $GLOBALS['wp_roles']->role_names as $role => $name )
|
144 |
-
$this->add_role( $role );
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Returns the instance.
|
149 |
-
*
|
150 |
-
* @since 3.0.0
|
151 |
-
* @access public
|
152 |
-
* @return object
|
153 |
-
*/
|
154 |
-
public static function get_instance() {
|
155 |
-
|
156 |
-
static $instance = null;
|
157 |
-
|
158 |
-
if ( is_null( $instance ) ) {
|
159 |
-
$instance = new Members_Role_Factory;
|
160 |
-
$instance->setup_roles();
|
161 |
-
}
|
162 |
-
|
163 |
-
return $instance;
|
164 |
-
}
|
165 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/class-role-group.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for handling a role group object.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Role group object class.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @access public
|
20 |
+
*/
|
21 |
+
final class Role_Group {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Name/ID for the group.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access public
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $name = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Internationalized text label for the group.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
* @access public
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $label = '';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Internationalized text label for the group + the count in the form of
|
43 |
+
* `_n_noop( 'Singular Name %s', 'Plural Name %s', $textdomain )`
|
44 |
+
*
|
45 |
+
* @since 2.0.0
|
46 |
+
* @access public
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
public $label_count = '';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Array of roles that belong to the group.
|
53 |
+
*
|
54 |
+
* @since 2.0.0
|
55 |
+
* @access public
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
public $roles = array();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Whether to create a view for the group on the Manage Roles screen.
|
62 |
+
*
|
63 |
+
* @since 2.0.0
|
64 |
+
* @access public
|
65 |
+
* @var bool
|
66 |
+
*/
|
67 |
+
public $show_in_view_list = true;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Magic method to use in case someone tries to output the object as a string.
|
71 |
+
* We'll just return the name.
|
72 |
+
*
|
73 |
+
* @since 2.0.0
|
74 |
+
* @access public
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function __toString() {
|
78 |
+
return $this->name;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Register a new object.
|
83 |
+
*
|
84 |
+
* @since 2.0.0
|
85 |
+
* @access public
|
86 |
+
* @param string $name
|
87 |
+
* @param array $args
|
88 |
+
* @return void
|
89 |
+
*/
|
90 |
+
public function __construct( $name, $args = array() ) {
|
91 |
+
|
92 |
+
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
93 |
+
|
94 |
+
if ( isset( $args[ $key ] ) )
|
95 |
+
$this->$key = $args[ $key ];
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->name = sanitize_key( $name );
|
99 |
+
|
100 |
+
$registered_roles = array_keys( wp_list_filter( members_get_roles(), array( 'group' => $this->name ) ) );
|
101 |
+
|
102 |
+
$this->roles = array_unique( array_merge( $this->roles, $registered_roles ) );
|
103 |
+
}
|
104 |
+
}
|
inc/class-role.php
CHANGED
@@ -5,60 +5,54 @@
|
|
5 |
*
|
6 |
* @package Members
|
7 |
* @subpackage Includes
|
8 |
-
* @author Justin Tadlock <
|
9 |
-
* @copyright Copyright (c) 2009 -
|
10 |
-
* @link
|
11 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
*/
|
13 |
|
|
|
|
|
14 |
/**
|
15 |
* Role class.
|
16 |
*
|
17 |
-
* @since
|
18 |
* @access public
|
19 |
*/
|
20 |
-
class
|
21 |
-
|
22 |
-
/**
|
23 |
-
* The role/slug.
|
24 |
-
*
|
25 |
-
* @since 1.0.0
|
26 |
-
* @access public
|
27 |
-
* @var string
|
28 |
-
*/
|
29 |
-
public $slug = '';
|
30 |
|
31 |
/**
|
32 |
* The role name.
|
33 |
*
|
34 |
-
* @since
|
35 |
* @access public
|
36 |
* @var string
|
37 |
*/
|
38 |
public $name = '';
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
*
|
43 |
-
* @since
|
44 |
* @access public
|
45 |
-
* @var
|
46 |
*/
|
47 |
-
public $
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
*
|
52 |
-
* @
|
|
|
53 |
* @access public
|
54 |
-
* @var
|
55 |
*/
|
56 |
-
public $
|
57 |
|
58 |
/**
|
59 |
* Whether the role has caps (granted).
|
60 |
*
|
61 |
-
* @since
|
62 |
* @access public
|
63 |
* @var bool
|
64 |
*/
|
@@ -67,7 +61,7 @@ class Members_Role {
|
|
67 |
/**
|
68 |
* Capability count for the role.
|
69 |
*
|
70 |
-
* @since
|
71 |
* @access public
|
72 |
* @var int
|
73 |
*/
|
@@ -76,16 +70,16 @@ class Members_Role {
|
|
76 |
/**
|
77 |
* Capability count for the role.
|
78 |
*
|
79 |
-
* @since
|
80 |
* @access public
|
81 |
* @var int
|
82 |
*/
|
83 |
public $denied_cap_count = 0;
|
84 |
|
85 |
/**
|
86 |
-
* Array of capabilities that the role has
|
87 |
*
|
88 |
-
* @since
|
89 |
* @access public
|
90 |
* @var array
|
91 |
*/
|
@@ -94,7 +88,7 @@ class Members_Role {
|
|
94 |
/**
|
95 |
* Array of granted capabilities that the role has.
|
96 |
*
|
97 |
-
* @since
|
98 |
* @access public
|
99 |
* @var array
|
100 |
*/
|
@@ -103,7 +97,7 @@ class Members_Role {
|
|
103 |
/**
|
104 |
* Array of denied capabilities that the role has.
|
105 |
*
|
106 |
-
* @since
|
107 |
* @access public
|
108 |
* @var array
|
109 |
*/
|
@@ -112,71 +106,56 @@ class Members_Role {
|
|
112 |
/**
|
113 |
* Return the role string in attempts to use the object as a string.
|
114 |
*
|
115 |
-
* @since
|
116 |
* @access public
|
117 |
* @return string
|
118 |
*/
|
119 |
public function __toString() {
|
120 |
-
return $this->
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
* Creates a new role object.
|
125 |
*
|
126 |
-
* @since
|
127 |
* @access public
|
128 |
-
* @global object $wp_roles
|
129 |
* @param string $role
|
|
|
130 |
* @return void
|
131 |
*/
|
132 |
-
public function __construct( $
|
133 |
-
global $wp_roles;
|
134 |
-
|
135 |
-
// Get the WP role object.
|
136 |
-
$_role = get_role( $role );
|
137 |
-
|
138 |
-
// Set the slug.
|
139 |
-
$this->slug = $_role->name;
|
140 |
|
141 |
-
|
142 |
-
if ( isset( $wp_roles->role_names[ $role ] ) )
|
143 |
-
$this->name = members_translate_role( $role );
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
// Loop through the role's caps.
|
150 |
-
foreach ( (array) $_role->capabilities as $cap => $grant ) {
|
151 |
|
152 |
-
|
153 |
-
$grant = members_validate_boolean( $grant );
|
154 |
|
155 |
-
|
156 |
-
$this->caps[ $cap ] = $grant;
|
157 |
|
158 |
-
//
|
159 |
-
|
160 |
-
$this->granted_caps[] = $cap;
|
161 |
|
162 |
-
//
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
-
|
|
|
181 |
}
|
182 |
}
|
5 |
*
|
6 |
* @package Members
|
7 |
* @subpackage Includes
|
8 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
9 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
10 |
+
* @link https://themehybrid.com/plugins/members
|
11 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
12 |
*/
|
13 |
|
14 |
+
namespace Members;
|
15 |
+
|
16 |
/**
|
17 |
* Role class.
|
18 |
*
|
19 |
+
* @since 2.0.0
|
20 |
* @access public
|
21 |
*/
|
22 |
+
class Role {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
/**
|
25 |
* The role name.
|
26 |
*
|
27 |
+
* @since 2.0.0
|
28 |
* @access public
|
29 |
* @var string
|
30 |
*/
|
31 |
public $name = '';
|
32 |
|
33 |
/**
|
34 |
+
* The role label.
|
35 |
*
|
36 |
+
* @since 2.0.0
|
37 |
* @access public
|
38 |
+
* @var string
|
39 |
*/
|
40 |
+
public $label = '';
|
41 |
|
42 |
/**
|
43 |
+
* The group the role belongs to.
|
44 |
*
|
45 |
+
* @see Members\Role_Group
|
46 |
+
* @since 2.0.0
|
47 |
* @access public
|
48 |
+
* @var string
|
49 |
*/
|
50 |
+
public $group = '';
|
51 |
|
52 |
/**
|
53 |
* Whether the role has caps (granted).
|
54 |
*
|
55 |
+
* @since 2.0.0
|
56 |
* @access public
|
57 |
* @var bool
|
58 |
*/
|
61 |
/**
|
62 |
* Capability count for the role.
|
63 |
*
|
64 |
+
* @since 2.0.0
|
65 |
* @access public
|
66 |
* @var int
|
67 |
*/
|
70 |
/**
|
71 |
* Capability count for the role.
|
72 |
*
|
73 |
+
* @since 2.0.0
|
74 |
* @access public
|
75 |
* @var int
|
76 |
*/
|
77 |
public $denied_cap_count = 0;
|
78 |
|
79 |
/**
|
80 |
+
* Array of capabilities that the role has in the form of `array( $cap => $bool )`.
|
81 |
*
|
82 |
+
* @since 2.0.0
|
83 |
* @access public
|
84 |
* @var array
|
85 |
*/
|
88 |
/**
|
89 |
* Array of granted capabilities that the role has.
|
90 |
*
|
91 |
+
* @since 2.0.0
|
92 |
* @access public
|
93 |
* @var array
|
94 |
*/
|
97 |
/**
|
98 |
* Array of denied capabilities that the role has.
|
99 |
*
|
100 |
+
* @since 2.0.0
|
101 |
* @access public
|
102 |
* @var array
|
103 |
*/
|
106 |
/**
|
107 |
* Return the role string in attempts to use the object as a string.
|
108 |
*
|
109 |
+
* @since 2.0.0
|
110 |
* @access public
|
111 |
* @return string
|
112 |
*/
|
113 |
public function __toString() {
|
114 |
+
return $this->name;
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
* Creates a new role object.
|
119 |
*
|
120 |
+
* @since 2.0.0
|
121 |
* @access public
|
|
|
122 |
* @param string $role
|
123 |
+
* @param array $args
|
124 |
* @return void
|
125 |
*/
|
126 |
+
public function __construct( $name, $args = array() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
|
|
|
|
129 |
|
130 |
+
if ( isset( $args[ $key ] ) )
|
131 |
+
$this->$key = $args[ $key ];
|
132 |
+
}
|
|
|
|
|
|
|
133 |
|
134 |
+
$this->name = members_sanitize_role( $name );
|
|
|
135 |
|
136 |
+
if ( $this->caps ) {
|
|
|
137 |
|
138 |
+
// Validate cap values as booleans in case they are stored as strings.
|
139 |
+
$this->caps = array_map( 'members_validate_boolean', $this->caps );
|
|
|
140 |
|
141 |
+
// Get granted and denied caps.
|
142 |
+
$this->granted_caps = array_keys( $this->caps, true );
|
143 |
+
$this->denied_caps = array_keys( $this->caps, false );
|
|
|
144 |
|
145 |
+
// Remove user levels from granted/denied caps.
|
146 |
+
$this->granted_caps = members_remove_old_levels( $this->granted_caps );
|
147 |
+
$this->denied_caps = members_remove_old_levels( $this->denied_caps );
|
148 |
|
149 |
+
// Remove hidden caps from granted/denied caps.
|
150 |
+
$this->granted_caps = members_remove_hidden_caps( $this->granted_caps );
|
151 |
+
$this->denied_caps = members_remove_hidden_caps( $this->denied_caps );
|
152 |
|
153 |
+
// Set the cap count.
|
154 |
+
$this->granted_cap_count = count( $this->granted_caps );
|
155 |
+
$this->denied_cap_count = count( $this->denied_caps );
|
156 |
|
157 |
+
// Check if we have caps.
|
158 |
+
$this->has_caps = 0 < $this->granted_cap_count;
|
159 |
+
}
|
160 |
}
|
161 |
}
|
inc/class-widget-login.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Login form widget class.
|
15 |
*
|
16 |
-
* @since 0.
|
17 |
* @access public
|
18 |
*/
|
19 |
-
class
|
20 |
|
21 |
/**
|
22 |
* Default arguments for the widget settings.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access public
|
26 |
* @var array
|
27 |
*/
|
@@ -30,7 +32,7 @@ class Members_Widget_Login extends WP_Widget {
|
|
30 |
/**
|
31 |
* Set up the widget's unique name, ID, class, description, and other options.
|
32 |
*
|
33 |
-
* @since 0.
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
@@ -54,11 +56,11 @@ class Members_Widget_Login extends WP_Widget {
|
|
54 |
|
55 |
// Set up the defaults.
|
56 |
$this->defaults = array(
|
57 |
-
'title' => esc_attr__( 'Log In',
|
58 |
-
'label_username' => esc_attr__( 'Username',
|
59 |
-
'label_password' => esc_attr__( 'Password',
|
60 |
-
'label_log_in' => esc_attr__( 'Log In',
|
61 |
-
'label_remember' => esc_attr__('Remember Me', 'members' ),
|
62 |
'form_id' => 'loginform',
|
63 |
'id_username' => 'user_login',
|
64 |
'id_password' => 'user_pass',
|
@@ -76,7 +78,7 @@ class Members_Widget_Login extends WP_Widget {
|
|
76 |
/**
|
77 |
* Outputs the widget based on the arguments input through the widget controls.
|
78 |
*
|
79 |
-
* @since 0.
|
80 |
* @access public
|
81 |
* @param array $sidebar
|
82 |
* @param array $instance
|
@@ -97,8 +99,8 @@ class Members_Widget_Login extends WP_Widget {
|
|
97 |
'label_log_in' => esc_html( $instance['label_log_in'] ),
|
98 |
'id_username' => esc_attr( $instance['id_username'] ),
|
99 |
'id_password' => esc_attr( $instance['id_password'] ),
|
100 |
-
'id_remember' => esc_attr( $instance['
|
101 |
-
'id_submit' => esc_attr( $instance['
|
102 |
'value_username' => esc_attr( $instance['value_username'] ),
|
103 |
|
104 |
'remember' => ! empty( $instance['remember'] ) ? true : false,
|
@@ -154,7 +156,7 @@ class Members_Widget_Login extends WP_Widget {
|
|
154 |
/**
|
155 |
* Sanitizes/Validates widget options before being saved.
|
156 |
*
|
157 |
-
* @since 0.
|
158 |
* @access public
|
159 |
* @param array $new_instance
|
160 |
* @param array $old_instance
|
@@ -191,7 +193,7 @@ class Members_Widget_Login extends WP_Widget {
|
|
191 |
/**
|
192 |
* Displays the widget control options in the Widgets admin screen.
|
193 |
*
|
194 |
-
* @since
|
195 |
* @access public
|
196 |
* @param array $instance
|
197 |
* @return void
|
@@ -255,13 +257,13 @@ class Members_Widget_Login extends WP_Widget {
|
|
255 |
<p>
|
256 |
<label>
|
257 |
<input class="checkbox" type="checkbox" <?php checked( $instance['remember'] ); ?> name="<?php echo $this->get_field_name( 'remember' ); ?>" />
|
258 |
-
<?php
|
259 |
</label>
|
260 |
</p>
|
261 |
<p>
|
262 |
<label>
|
263 |
<input class="checkbox" type="checkbox" <?php checked( $instance['value_remember'] ); ?> name="<?php echo $this->get_field_name( 'value_remember' ); ?>" />
|
264 |
-
<?php
|
265 |
</label>
|
266 |
</p>
|
267 |
<p>
|
@@ -271,12 +273,12 @@ class Members_Widget_Login extends WP_Widget {
|
|
271 |
</label>
|
272 |
</p>
|
273 |
<p>
|
274 |
-
<label for="<?php echo $this->get_field_id( 'logged_out_text' ); ?>"><?php
|
275 |
<textarea class="widefat" rows="4" cols="20" id="<?php echo $this->get_field_id( 'logged_out_text' ); ?>" name="<?php echo $this->get_field_name( 'logged_out_text' ); ?>" style="width:100%;"><?php echo esc_textarea( $instance['logged_out_text'] ); ?></textarea>
|
276 |
</p>
|
277 |
|
278 |
<p>
|
279 |
-
<label for="<?php echo $this->get_field_id( 'logged_in_text' ); ?>"><?php
|
280 |
<textarea class="widefat" rows="4" cols="20" id="<?php echo $this->get_field_id( 'logged_in_text' ); ?>" name="<?php echo $this->get_field_name( 'logged_in_text' ); ?>" style="width:100%;"><?php echo esc_textarea( $instance['logged_in_text'] ); ?></textarea>
|
281 |
</p>
|
282 |
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
/**
|
16 |
* Login form widget class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
class Widget_Login extends \WP_Widget {
|
22 |
|
23 |
/**
|
24 |
* Default arguments for the widget settings.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access public
|
28 |
* @var array
|
29 |
*/
|
32 |
/**
|
33 |
* Set up the widget's unique name, ID, class, description, and other options.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @return void
|
38 |
*/
|
56 |
|
57 |
// Set up the defaults.
|
58 |
$this->defaults = array(
|
59 |
+
'title' => esc_attr__( 'Log In', 'members' ),
|
60 |
+
'label_username' => esc_attr__( 'Username', 'members' ),
|
61 |
+
'label_password' => esc_attr__( 'Password', 'members' ),
|
62 |
+
'label_log_in' => esc_attr__( 'Log In', 'members' ),
|
63 |
+
'label_remember' => esc_attr__( 'Remember Me', 'members' ),
|
64 |
'form_id' => 'loginform',
|
65 |
'id_username' => 'user_login',
|
66 |
'id_password' => 'user_pass',
|
78 |
/**
|
79 |
* Outputs the widget based on the arguments input through the widget controls.
|
80 |
*
|
81 |
+
* @since 2.0.0
|
82 |
* @access public
|
83 |
* @param array $sidebar
|
84 |
* @param array $instance
|
99 |
'label_log_in' => esc_html( $instance['label_log_in'] ),
|
100 |
'id_username' => esc_attr( $instance['id_username'] ),
|
101 |
'id_password' => esc_attr( $instance['id_password'] ),
|
102 |
+
'id_remember' => esc_attr( $instance['id_remember'] ),
|
103 |
+
'id_submit' => esc_attr( $instance['id_submit'] ),
|
104 |
'value_username' => esc_attr( $instance['value_username'] ),
|
105 |
|
106 |
'remember' => ! empty( $instance['remember'] ) ? true : false,
|
156 |
/**
|
157 |
* Sanitizes/Validates widget options before being saved.
|
158 |
*
|
159 |
+
* @since 2.0.0
|
160 |
* @access public
|
161 |
* @param array $new_instance
|
162 |
* @param array $old_instance
|
193 |
/**
|
194 |
* Displays the widget control options in the Widgets admin screen.
|
195 |
*
|
196 |
+
* @since 2.0.0
|
197 |
* @access public
|
198 |
* @param array $instance
|
199 |
* @return void
|
257 |
<p>
|
258 |
<label>
|
259 |
<input class="checkbox" type="checkbox" <?php checked( $instance['remember'] ); ?> name="<?php echo $this->get_field_name( 'remember' ); ?>" />
|
260 |
+
<?php esc_html_e( '"Remember me" checkbox?', 'members' ); ?>
|
261 |
</label>
|
262 |
</p>
|
263 |
<p>
|
264 |
<label>
|
265 |
<input class="checkbox" type="checkbox" <?php checked( $instance['value_remember'] ); ?> name="<?php echo $this->get_field_name( 'value_remember' ); ?>" />
|
266 |
+
<?php esc_html_e( 'Check "remember me"?', 'members' ); ?>
|
267 |
</label>
|
268 |
</p>
|
269 |
<p>
|
273 |
</label>
|
274 |
</p>
|
275 |
<p>
|
276 |
+
<label for="<?php echo $this->get_field_id( 'logged_out_text' ); ?>"><?php esc_html_e( 'Logged out text:', 'members' ); ?></label>
|
277 |
<textarea class="widefat" rows="4" cols="20" id="<?php echo $this->get_field_id( 'logged_out_text' ); ?>" name="<?php echo $this->get_field_name( 'logged_out_text' ); ?>" style="width:100%;"><?php echo esc_textarea( $instance['logged_out_text'] ); ?></textarea>
|
278 |
</p>
|
279 |
|
280 |
<p>
|
281 |
+
<label for="<?php echo $this->get_field_id( 'logged_in_text' ); ?>"><?php esc_html_e( 'Logged in text:', 'members' ); ?></label>
|
282 |
<textarea class="widefat" rows="4" cols="20" id="<?php echo $this->get_field_id( 'logged_in_text' ); ?>" name="<?php echo $this->get_field_name( 'logged_in_text' ); ?>" style="width:100%;"><?php echo esc_textarea( $instance['logged_in_text'] ); ?></textarea>
|
283 |
</p>
|
284 |
|
inc/class-widget-users.php
CHANGED
@@ -4,24 +4,26 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Users widget archive class.
|
15 |
*
|
16 |
-
* @since 0.
|
17 |
* @access public
|
18 |
*/
|
19 |
-
class
|
20 |
|
21 |
/**
|
22 |
* Default arguments for the widget settings.
|
23 |
*
|
24 |
-
* @since
|
25 |
* @access public
|
26 |
* @var array
|
27 |
*/
|
@@ -30,7 +32,7 @@ class Members_Widget_Users extends WP_Widget {
|
|
30 |
/**
|
31 |
* Set up the widget's unique name, ID, class, description, and other options.
|
32 |
*
|
33 |
-
* @since 0.
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
@@ -71,7 +73,7 @@ class Members_Widget_Users extends WP_Widget {
|
|
71 |
/**
|
72 |
* Outputs the widget based on the arguments input through the widget controls.
|
73 |
*
|
74 |
-
* @since 0.
|
75 |
* @access public
|
76 |
* @param array $sidebar
|
77 |
* @param array $instance
|
@@ -136,7 +138,7 @@ class Members_Widget_Users extends WP_Widget {
|
|
136 |
/**
|
137 |
* Sanitizes/Validates widget options before being saved.
|
138 |
*
|
139 |
-
* @since 0.
|
140 |
* @access public
|
141 |
* @param array $new_instance
|
142 |
* @param array $old_instance
|
@@ -169,7 +171,7 @@ class Members_Widget_Users extends WP_Widget {
|
|
169 |
/**
|
170 |
* Displays the widget control options in the Widgets admin screen.
|
171 |
*
|
172 |
-
* @since
|
173 |
* @access public
|
174 |
* @param array $instance
|
175 |
* @return void
|
@@ -197,9 +199,8 @@ class Members_Widget_Users extends WP_Widget {
|
|
197 |
|
198 |
$meta_key = array_merge( array( '' ), (array) members_get_user_meta_keys() );
|
199 |
|
200 |
-
$roles =
|
201 |
-
asort( $roles );
|
202 |
-
$roles = array_merge( array( '' => '' ), $roles ); ?>
|
203 |
|
204 |
<div style="float: left;width: 48%;">
|
205 |
|
@@ -226,8 +227,9 @@ class Members_Widget_Users extends WP_Widget {
|
|
226 |
<p>
|
227 |
<label for="<?php echo $this->get_field_id( 'role' ); ?>"><?php esc_html_e( 'Role:', 'members' ); ?></label>
|
228 |
<select class="widefat" id="<?php echo $this->get_field_id( 'role' ); ?>" name="<?php echo $this->get_field_name( 'role' ); ?>">
|
229 |
-
<?php
|
230 |
-
|
|
|
231 |
<?php endforeach; ?>
|
232 |
</select>
|
233 |
</p>
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
namespace Members;
|
14 |
+
|
15 |
/**
|
16 |
* Users widget archive class.
|
17 |
*
|
18 |
+
* @since 2.0.0
|
19 |
* @access public
|
20 |
*/
|
21 |
+
class Widget_Users extends \WP_Widget {
|
22 |
|
23 |
/**
|
24 |
* Default arguments for the widget settings.
|
25 |
*
|
26 |
+
* @since 2.0.0
|
27 |
* @access public
|
28 |
* @var array
|
29 |
*/
|
32 |
/**
|
33 |
* Set up the widget's unique name, ID, class, description, and other options.
|
34 |
*
|
35 |
+
* @since 2.0.0
|
36 |
* @access public
|
37 |
* @return void
|
38 |
*/
|
73 |
/**
|
74 |
* Outputs the widget based on the arguments input through the widget controls.
|
75 |
*
|
76 |
+
* @since 2.0.0
|
77 |
* @access public
|
78 |
* @param array $sidebar
|
79 |
* @param array $instance
|
138 |
/**
|
139 |
* Sanitizes/Validates widget options before being saved.
|
140 |
*
|
141 |
+
* @since 2.0.0
|
142 |
* @access public
|
143 |
* @param array $new_instance
|
144 |
* @param array $old_instance
|
171 |
/**
|
172 |
* Displays the widget control options in the Widgets admin screen.
|
173 |
*
|
174 |
+
* @since 2.0.0
|
175 |
* @access public
|
176 |
* @param array $instance
|
177 |
* @return void
|
199 |
|
200 |
$meta_key = array_merge( array( '' ), (array) members_get_user_meta_keys() );
|
201 |
|
202 |
+
$roles = members_get_roles();
|
203 |
+
asort( $roles ); ?>
|
|
|
204 |
|
205 |
<div style="float: left;width: 48%;">
|
206 |
|
227 |
<p>
|
228 |
<label for="<?php echo $this->get_field_id( 'role' ); ?>"><?php esc_html_e( 'Role:', 'members' ); ?></label>
|
229 |
<select class="widefat" id="<?php echo $this->get_field_id( 'role' ); ?>" name="<?php echo $this->get_field_name( 'role' ); ?>">
|
230 |
+
<option value="" <?php selected( $instance['role'], '' ); ?>></option>
|
231 |
+
<?php foreach ( $roles as $name => $role ) : ?>
|
232 |
+
<option value="<?php echo esc_attr( $name ); ?>" <?php selected( $instance['role'], $name ); ?>><?php echo esc_html( $role->label ); ?></option>
|
233 |
<?php endforeach; ?>
|
234 |
</select>
|
235 |
</p>
|
inc/functions-admin-bar.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
{admin → inc}/functions-cap-groups.php
RENAMED
@@ -4,118 +4,44 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
# Registers default groups.
|
14 |
-
add_action( 'init',
|
|
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
*
|
19 |
-
* @see Members_Cap_Group_Factory
|
20 |
* @since 1.0.0
|
21 |
* @access public
|
22 |
-
* @return object
|
23 |
-
*/
|
24 |
-
function members_cap_group_factory() {
|
25 |
-
return Members_Cap_Group_Factory::get_instance();
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Function for registering a cap group.
|
30 |
-
*
|
31 |
-
* @see Members_Cap_Group_Factory::register_group()
|
32 |
-
* @since 1.0.0
|
33 |
-
* @access public
|
34 |
-
* @param string $name
|
35 |
-
* @param array $args
|
36 |
-
* @return void
|
37 |
-
*/
|
38 |
-
function members_register_cap_group( $name, $args = array() ) {
|
39 |
-
members_cap_group_factory()->register_group( $name, $args );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Unregisters a group.
|
44 |
-
*
|
45 |
-
* @see Members_Cap_Group_Factory::unregister_group()
|
46 |
-
* @since 1.0.0
|
47 |
-
* @access public
|
48 |
-
* @param string $name
|
49 |
* @return void
|
50 |
*/
|
51 |
-
function
|
52 |
-
members_cap_group_factory()->unregister_group( $name );
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Checks if a group exists.
|
57 |
-
*
|
58 |
-
* @see Members_Cap_Group_Factory::group_exists()
|
59 |
-
* @since 1.0.0
|
60 |
-
* @access public
|
61 |
-
* @param string $name
|
62 |
-
* @return bool
|
63 |
-
*/
|
64 |
-
function members_cap_group_exists( $name ) {
|
65 |
-
return members_cap_group_factory()->group_exists( $name );
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Returns an array of registered group objects.
|
70 |
-
*
|
71 |
-
* @see Members_Cap_Group_Factory::group
|
72 |
-
* @since 1.0.0
|
73 |
-
* @access public
|
74 |
-
* @return array
|
75 |
-
*/
|
76 |
-
function members_get_cap_groups() {
|
77 |
-
return members_cap_group_factory()->groups;
|
78 |
-
}
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
*
|
83 |
-
* @see Members_Cap_Group_Factory::get_group()
|
84 |
-
* @see Members_Cap_Group
|
85 |
-
* @since 1.0.0
|
86 |
-
* @access public
|
87 |
-
* @param string $name
|
88 |
-
* @return object|bool
|
89 |
-
*/
|
90 |
-
function members_get_cap_group( $name ) {
|
91 |
-
return members_cap_group_factory()->get_group( $name );
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
* Registers the default cap groups.
|
96 |
*
|
97 |
-
* @since
|
98 |
* @access public
|
99 |
* @return void
|
100 |
*/
|
101 |
-
function
|
102 |
-
|
103 |
-
// Register the all group.
|
104 |
-
members_register_cap_group( 'all',
|
105 |
-
array(
|
106 |
-
'label' => esc_html__( 'All', 'members' ),
|
107 |
-
'caps' => members_get_all_group_caps(),
|
108 |
-
'icon' => 'dashicons-plus',
|
109 |
-
'merge_added' => false
|
110 |
-
)
|
111 |
-
);
|
112 |
|
113 |
// Registers the general group.
|
114 |
members_register_cap_group( 'general',
|
115 |
array(
|
116 |
-
'label'
|
117 |
-
'
|
118 |
-
'
|
119 |
)
|
120 |
);
|
121 |
|
@@ -152,9 +78,10 @@ function members_register_cap_groups() {
|
|
152 |
// Register the post type cap group.
|
153 |
members_register_cap_group( "type-{$type->name}",
|
154 |
array(
|
155 |
-
'label'
|
156 |
-
'caps'
|
157 |
-
'icon'
|
|
|
158 |
)
|
159 |
);
|
160 |
}
|
@@ -165,34 +92,35 @@ function members_register_cap_groups() {
|
|
165 |
'label' => esc_html__( 'Taxonomies', 'members' ),
|
166 |
'caps' => members_get_taxonomy_group_caps(),
|
167 |
'icon' => 'dashicons-tag',
|
168 |
-
'diff_added' => true
|
|
|
169 |
)
|
170 |
);
|
171 |
|
172 |
// Register the theme group.
|
173 |
members_register_cap_group( 'theme',
|
174 |
array(
|
175 |
-
'label'
|
176 |
-
'
|
177 |
-
'
|
178 |
)
|
179 |
);
|
180 |
|
181 |
// Register the plugin group.
|
182 |
members_register_cap_group( 'plugin',
|
183 |
array(
|
184 |
-
'label'
|
185 |
-
'
|
186 |
-
'
|
187 |
)
|
188 |
);
|
189 |
|
190 |
// Register the user group.
|
191 |
members_register_cap_group( 'user',
|
192 |
array(
|
193 |
-
'label'
|
194 |
-
'
|
195 |
-
'
|
196 |
)
|
197 |
);
|
198 |
|
@@ -202,78 +130,87 @@ function members_register_cap_groups() {
|
|
202 |
'label' => esc_html__( 'Custom', 'members' ),
|
203 |
'caps' => members_get_capabilities(),
|
204 |
'icon' => 'dashicons-admin-generic',
|
205 |
-
'diff_added' => true
|
|
|
206 |
)
|
207 |
);
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
$_group = members_get_cap_group( 'all' );
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
$caps = array_merge( $caps, $group->caps );
|
222 |
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
}
|
229 |
|
230 |
-
|
231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
-
|
234 |
-
|
235 |
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
-
|
240 |
-
members_cap_group_factory()->groups[ 'custom' ] = $custom;
|
241 |
-
}
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
-
* Returns
|
246 |
*
|
247 |
* @since 1.0.0
|
248 |
* @access public
|
249 |
* @return array
|
250 |
*/
|
251 |
-
function
|
252 |
|
253 |
-
return
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
-
* Returns
|
258 |
*
|
259 |
* @since 1.0.0
|
260 |
* @access public
|
261 |
-
* @
|
|
|
262 |
*/
|
263 |
-
function
|
264 |
-
|
265 |
-
return
|
266 |
-
'edit_dashboard',
|
267 |
-
'edit_files',
|
268 |
-
'export',
|
269 |
-
'import',
|
270 |
-
'manage_links',
|
271 |
-
'manage_options',
|
272 |
-
'moderate_comments',
|
273 |
-
'read',
|
274 |
-
'unfiltered_html',
|
275 |
-
'update_core',
|
276 |
-
);
|
277 |
}
|
278 |
|
279 |
/**
|
@@ -311,6 +248,11 @@ function members_get_post_type_group_caps( $post_type = 'post' ) {
|
|
311 |
if ( 'attachment' === $post_type )
|
312 |
$caps[] = 'unfiltered_upload';
|
313 |
|
|
|
|
|
|
|
|
|
|
|
314 |
// Make sure there are no duplicates and return.
|
315 |
return array_unique( $caps );
|
316 |
}
|
@@ -324,6 +266,16 @@ function members_get_post_type_group_caps( $post_type = 'post' ) {
|
|
324 |
*/
|
325 |
function members_get_taxonomy_group_caps() {
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
$taxi = get_taxonomies( array(), 'objects' );
|
328 |
|
329 |
$caps = array();
|
@@ -331,68 +283,12 @@ function members_get_taxonomy_group_caps() {
|
|
331 |
foreach ( $taxi as $tax )
|
332 |
$caps = array_merge( $caps, array_values( (array) $tax->cap ) );
|
333 |
|
334 |
-
|
335 |
-
}
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
*
|
340 |
-
* @since 1.0.0
|
341 |
-
* @access public
|
342 |
-
* @return array
|
343 |
-
*/
|
344 |
-
function members_get_theme_group_caps() {
|
345 |
-
|
346 |
-
return array(
|
347 |
-
'delete_themes',
|
348 |
-
'edit_theme_options',
|
349 |
-
'edit_themes',
|
350 |
-
'install_themes',
|
351 |
-
'switch_themes',
|
352 |
-
'update_themes',
|
353 |
-
);
|
354 |
-
}
|
355 |
|
356 |
-
|
357 |
-
* Returns the caps for the plugin capability group.
|
358 |
-
*
|
359 |
-
* @since 1.0.0
|
360 |
-
* @access public
|
361 |
-
* @return array
|
362 |
-
*/
|
363 |
-
function members_get_plugin_group_caps() {
|
364 |
-
|
365 |
-
return array(
|
366 |
-
'activate_plugins',
|
367 |
-
'delete_plugins',
|
368 |
-
'edit_plugins',
|
369 |
-
'install_plugins',
|
370 |
-
'update_plugins',
|
371 |
-
);
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Returns the caps for the user capability group.
|
376 |
-
*
|
377 |
-
* @since 1.0.0
|
378 |
-
* @access public
|
379 |
-
* @return array
|
380 |
-
*/
|
381 |
-
function members_get_user_group_caps() {
|
382 |
-
|
383 |
-
return array(
|
384 |
-
'add_users',
|
385 |
-
'create_roles',
|
386 |
-
'create_users',
|
387 |
-
'delete_roles',
|
388 |
-
'delete_users',
|
389 |
-
'edit_roles',
|
390 |
-
'edit_users',
|
391 |
-
'list_roles',
|
392 |
-
'list_users',
|
393 |
-
'promote_users',
|
394 |
-
'remove_users',
|
395 |
-
);
|
396 |
}
|
397 |
|
398 |
/**
|
@@ -404,5 +300,12 @@ function members_get_user_group_caps() {
|
|
404 |
*/
|
405 |
function members_get_custom_group_caps() {
|
406 |
|
407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
# Registers default groups.
|
14 |
+
add_action( 'init', 'members_register_cap_groups', 95 );
|
15 |
+
add_action( 'members_register_cap_groups', 'members_register_default_cap_groups', 5 );
|
16 |
|
17 |
/**
|
18 |
+
* Fires the cap group registration action hook.
|
19 |
*
|
|
|
20 |
* @since 1.0.0
|
21 |
* @access public
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
* @return void
|
23 |
*/
|
24 |
+
function members_register_cap_groups() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
// Hook for registering cap groups. Plugins should always register on this hook.
|
27 |
+
do_action( 'members_register_cap_groups' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
* Registers the default cap groups.
|
32 |
*
|
33 |
+
* @since 2.0.0
|
34 |
* @access public
|
35 |
* @return void
|
36 |
*/
|
37 |
+
function members_register_default_cap_groups() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
// Registers the general group.
|
40 |
members_register_cap_group( 'general',
|
41 |
array(
|
42 |
+
'label' => esc_html__( 'General', 'members' ),
|
43 |
+
'icon' => 'dashicons-wordpress',
|
44 |
+
'priority' => 5
|
45 |
)
|
46 |
);
|
47 |
|
78 |
// Register the post type cap group.
|
79 |
members_register_cap_group( "type-{$type->name}",
|
80 |
array(
|
81 |
+
'label' => $type->labels->name,
|
82 |
+
'caps' => $has_caps,
|
83 |
+
'icon' => $icon,
|
84 |
+
'priority' => 5
|
85 |
)
|
86 |
);
|
87 |
}
|
92 |
'label' => esc_html__( 'Taxonomies', 'members' ),
|
93 |
'caps' => members_get_taxonomy_group_caps(),
|
94 |
'icon' => 'dashicons-tag',
|
95 |
+
'diff_added' => true,
|
96 |
+
'priority' => 10
|
97 |
)
|
98 |
);
|
99 |
|
100 |
// Register the theme group.
|
101 |
members_register_cap_group( 'theme',
|
102 |
array(
|
103 |
+
'label' => esc_html__( 'Appearance', 'members' ),
|
104 |
+
'icon' => 'dashicons-admin-appearance',
|
105 |
+
'priority' => 15
|
106 |
)
|
107 |
);
|
108 |
|
109 |
// Register the plugin group.
|
110 |
members_register_cap_group( 'plugin',
|
111 |
array(
|
112 |
+
'label' => esc_html__( 'Plugins', 'members' ),
|
113 |
+
'icon' => 'dashicons-admin-plugins',
|
114 |
+
'priority' => 20
|
115 |
)
|
116 |
);
|
117 |
|
118 |
// Register the user group.
|
119 |
members_register_cap_group( 'user',
|
120 |
array(
|
121 |
+
'label' => esc_html__( 'Users', 'members' ),
|
122 |
+
'icon' => 'dashicons-admin-users',
|
123 |
+
'priority' => 25
|
124 |
)
|
125 |
);
|
126 |
|
130 |
'label' => esc_html__( 'Custom', 'members' ),
|
131 |
'caps' => members_get_capabilities(),
|
132 |
'icon' => 'dashicons-admin-generic',
|
133 |
+
'diff_added' => true,
|
134 |
+
'priority' => 995
|
135 |
)
|
136 |
);
|
137 |
+
}
|
138 |
|
139 |
+
/**
|
140 |
+
* Returns the instance of cap group registry.
|
141 |
+
*
|
142 |
+
* @since 2.0.0
|
143 |
+
* @access public
|
144 |
+
* @return object
|
145 |
+
*/
|
146 |
+
function members_cap_group_registry() {
|
|
|
147 |
|
148 |
+
return \Members\Registry::get_instance( 'cap_group' );
|
149 |
+
}
|
|
|
150 |
|
151 |
+
/**
|
152 |
+
* Function for registering a cap group.
|
153 |
+
*
|
154 |
+
* @since 1.0.0
|
155 |
+
* @access public
|
156 |
+
* @param string $name
|
157 |
+
* @param array $args
|
158 |
+
* @return void
|
159 |
+
*/
|
160 |
+
function members_register_cap_group( $name, $args = array() ) {
|
161 |
|
162 |
+
members_cap_group_registry()->register( $name, new \Members\Cap_Group( $name, $args ) );
|
163 |
+
}
|
|
|
164 |
|
165 |
+
/**
|
166 |
+
* Unregisters a group.
|
167 |
+
*
|
168 |
+
* @since 1.0.0
|
169 |
+
* @access public
|
170 |
+
* @param string $name
|
171 |
+
* @return void
|
172 |
+
*/
|
173 |
+
function members_unregister_cap_group( $name ) {
|
174 |
|
175 |
+
members_cap_group_registry()->unregister( $name );
|
176 |
+
}
|
177 |
|
178 |
+
/**
|
179 |
+
* Checks if a group exists.
|
180 |
+
*
|
181 |
+
* @since 1.0.0
|
182 |
+
* @access public
|
183 |
+
* @param string $name
|
184 |
+
* @return bool
|
185 |
+
*/
|
186 |
+
function members_cap_group_exists( $name ) {
|
187 |
|
188 |
+
return members_cap_group_registry()->exists( $name );
|
|
|
|
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
+
* Returns an array of registered group objects.
|
193 |
*
|
194 |
* @since 1.0.0
|
195 |
* @access public
|
196 |
* @return array
|
197 |
*/
|
198 |
+
function members_get_cap_groups() {
|
199 |
|
200 |
+
return members_cap_group_registry()->get_collection();
|
201 |
}
|
202 |
|
203 |
/**
|
204 |
+
* Returns a group object if it exists. Otherwise, `FALSE`.
|
205 |
*
|
206 |
* @since 1.0.0
|
207 |
* @access public
|
208 |
+
* @param string $name
|
209 |
+
* @return object|bool
|
210 |
*/
|
211 |
+
function members_get_cap_group( $name ) {
|
212 |
+
|
213 |
+
return members_cap_group_registry()->get( $name );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
248 |
if ( 'attachment' === $post_type )
|
249 |
$caps[] = 'unfiltered_upload';
|
250 |
|
251 |
+
$registered_caps = array_keys( wp_list_filter( members_get_caps(), array( 'group' => "type-{$post_type}" ) ) );
|
252 |
+
|
253 |
+
if ( $registered_caps )
|
254 |
+
array_merge( $caps, $registered_caps );
|
255 |
+
|
256 |
// Make sure there are no duplicates and return.
|
257 |
return array_unique( $caps );
|
258 |
}
|
266 |
*/
|
267 |
function members_get_taxonomy_group_caps() {
|
268 |
|
269 |
+
$do_not_add = array(
|
270 |
+
'assign_categories',
|
271 |
+
'edit_categories',
|
272 |
+
'delete_categories',
|
273 |
+
'assign_post_tags',
|
274 |
+
'edit_post_tags',
|
275 |
+
'delete_post_tags',
|
276 |
+
'manage_post_tags'
|
277 |
+
);
|
278 |
+
|
279 |
$taxi = get_taxonomies( array(), 'objects' );
|
280 |
|
281 |
$caps = array();
|
283 |
foreach ( $taxi as $tax )
|
284 |
$caps = array_merge( $caps, array_values( (array) $tax->cap ) );
|
285 |
|
286 |
+
$registered_caps = array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'taxonomy' ) ) );
|
|
|
287 |
|
288 |
+
if ( $registered_caps )
|
289 |
+
array_merge( $caps, $registered_caps );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
+
return array_diff( array_unique( $caps ), $do_not_add );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
|
294 |
/**
|
300 |
*/
|
301 |
function members_get_custom_group_caps() {
|
302 |
|
303 |
+
$caps = members_get_capabilities();
|
304 |
+
|
305 |
+
$registered_caps = array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'custom' ) ) );
|
306 |
+
|
307 |
+
if ( $registered_caps )
|
308 |
+
array_merge( $caps, $registered_caps );
|
309 |
+
|
310 |
+
return array_unique( $caps );
|
311 |
}
|
inc/functions-capabilities.php
CHANGED
@@ -4,38 +4,245 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
# Disables the old user levels from capabilities array.
|
14 |
add_filter( 'members_get_capabilities', 'members_remove_old_levels' );
|
15 |
add_filter( 'members_get_capabilities', 'members_remove_hidden_caps' );
|
16 |
|
17 |
/**
|
18 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
*
|
20 |
* @since 1.0.0
|
21 |
* @access public
|
22 |
-
* @param string $
|
23 |
-
* @return
|
24 |
*/
|
25 |
-
function
|
26 |
-
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
*
|
31 |
*
|
32 |
* @since 1.0.0
|
33 |
* @access public
|
34 |
* @param string $cap
|
35 |
-
* @return
|
36 |
*/
|
37 |
-
function
|
38 |
-
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -49,7 +256,7 @@ function members_cap_exists( $cap ) {
|
|
49 |
*/
|
50 |
function members_is_cap_editable( $cap ) {
|
51 |
|
52 |
-
$uneditable = array_keys(
|
53 |
|
54 |
return ! in_array( $cap, members_get_wp_capabilities() ) && ! array_intersect( $uneditable, members_get_cap_roles( $cap ) );
|
55 |
}
|
@@ -88,15 +295,8 @@ function members_get_cap_roles( $cap ) {
|
|
88 |
*/
|
89 |
function members_get_capabilities() {
|
90 |
|
91 |
-
// Merge the default WP, role, and plugin caps together.
|
92 |
-
$capabilities = array_merge(
|
93 |
-
members_get_wp_capabilities(),
|
94 |
-
members_get_role_capabilities(),
|
95 |
-
members_get_plugin_capabilities()
|
96 |
-
);
|
97 |
-
|
98 |
// Apply filters to the array of capabilities.
|
99 |
-
$capabilities = apply_filters( 'members_get_capabilities',
|
100 |
|
101 |
// Sort the capabilities alphabetically.
|
102 |
sort( $capabilities );
|
@@ -139,97 +339,6 @@ function members_get_role_capabilities() {
|
|
139 |
return array_unique( $capabilities );
|
140 |
}
|
141 |
|
142 |
-
/**
|
143 |
-
* Additional capabilities provided by the Members plugin that gives users permissions to handle
|
144 |
-
* certain features of the plugin.
|
145 |
-
*
|
146 |
-
* @since 1.0.0
|
147 |
-
* @access public
|
148 |
-
* @return array
|
149 |
-
*/
|
150 |
-
function members_get_plugin_capabilities() {
|
151 |
-
|
152 |
-
return array(
|
153 |
-
'list_roles', // View roles list.
|
154 |
-
'create_roles', // Create new roles.
|
155 |
-
'delete_roles', // Delete roles.
|
156 |
-
'edit_roles', // Edit a role's caps.
|
157 |
-
'restrict_content' // Restrict content (content permissions component).
|
158 |
-
);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Make sure we keep the default capabilities in case users screw 'em up. A user could easily
|
163 |
-
* remove a useful WordPress capability from all roles. When this happens, the capability is no
|
164 |
-
* longer stored in any of the roles, so it basically doesn't exist. This function will house
|
165 |
-
* all of the default WordPress capabilities in case this scenario comes into play.
|
166 |
-
*
|
167 |
-
* For those reading this note, yes, I did "accidentally" remove all capabilities from my
|
168 |
-
* administrator account when developing this plugin. And yes, that was fun putting back
|
169 |
-
* together. ;)
|
170 |
-
*
|
171 |
-
* @link http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
|
172 |
-
* @since 1.0.0
|
173 |
-
* @access public
|
174 |
-
* @return array
|
175 |
-
*/
|
176 |
-
function members_get_wp_capabilities() {
|
177 |
-
|
178 |
-
return array(
|
179 |
-
'activate_plugins',
|
180 |
-
'add_users',
|
181 |
-
'create_users',
|
182 |
-
'delete_others_pages',
|
183 |
-
'delete_others_posts',
|
184 |
-
'delete_pages',
|
185 |
-
'delete_plugins',
|
186 |
-
'delete_posts',
|
187 |
-
'delete_private_pages',
|
188 |
-
'delete_private_posts',
|
189 |
-
'delete_published_pages',
|
190 |
-
'delete_published_posts',
|
191 |
-
'delete_themes',
|
192 |
-
'delete_users',
|
193 |
-
'edit_dashboard',
|
194 |
-
'edit_files',
|
195 |
-
'edit_others_pages',
|
196 |
-
'edit_others_posts',
|
197 |
-
'edit_pages',
|
198 |
-
'edit_plugins',
|
199 |
-
'edit_posts',
|
200 |
-
'edit_private_pages',
|
201 |
-
'edit_private_posts',
|
202 |
-
'edit_published_pages',
|
203 |
-
'edit_published_posts',
|
204 |
-
'edit_theme_options',
|
205 |
-
'edit_themes',
|
206 |
-
'edit_users',
|
207 |
-
'export',
|
208 |
-
'import',
|
209 |
-
'install_plugins',
|
210 |
-
'install_themes',
|
211 |
-
'list_users',
|
212 |
-
'manage_categories',
|
213 |
-
'manage_links',
|
214 |
-
'manage_options',
|
215 |
-
'moderate_comments',
|
216 |
-
'promote_users',
|
217 |
-
'publish_pages',
|
218 |
-
'publish_posts',
|
219 |
-
'read',
|
220 |
-
'read_private_pages',
|
221 |
-
'read_private_posts',
|
222 |
-
'remove_users',
|
223 |
-
'switch_themes',
|
224 |
-
'unfiltered_html',
|
225 |
-
'unfiltered_upload',
|
226 |
-
'update_core',
|
227 |
-
'update_plugins',
|
228 |
-
'update_themes',
|
229 |
-
'upload_files'
|
230 |
-
);
|
231 |
-
}
|
232 |
-
|
233 |
/**
|
234 |
* Checks if a specific capability has been given to at least one role. If it has, return true.
|
235 |
* Else, return false.
|
@@ -260,6 +369,9 @@ function members_get_hidden_caps() {
|
|
260 |
|
261 |
$caps = array();
|
262 |
|
|
|
|
|
|
|
263 |
// Unfiltered uploads.
|
264 |
if ( is_multisite() || ! defined( 'ALLOW_UNFILTERED_UPLOADS' ) || ! ALLOW_UNFILTERED_UPLOADS )
|
265 |
$caps[] = 'unfiltered_upload';
|
@@ -303,6 +415,7 @@ function members_get_hidden_caps() {
|
|
303 |
* @return array
|
304 |
*/
|
305 |
function members_remove_hidden_caps( $caps ) {
|
|
|
306 |
return apply_filters( 'members_remove_hidden_caps', true ) ? array_diff( $caps, members_get_hidden_caps() ) : $caps;
|
307 |
}
|
308 |
|
@@ -342,6 +455,7 @@ function members_get_old_levels() {
|
|
342 |
* @return array
|
343 |
*/
|
344 |
function members_remove_old_levels( $caps ) {
|
|
|
345 |
return apply_filters( 'members_remove_old_levels', true ) ? array_diff( $caps, members_get_old_levels() ) : $caps;
|
346 |
}
|
347 |
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
# Register capabilities.
|
14 |
+
add_action( 'init', 'members_register_caps', 95 );
|
15 |
+
add_action( 'members_register_caps', 'members_register_default_caps', 5 );
|
16 |
+
|
17 |
# Disables the old user levels from capabilities array.
|
18 |
add_filter( 'members_get_capabilities', 'members_remove_old_levels' );
|
19 |
add_filter( 'members_get_capabilities', 'members_remove_hidden_caps' );
|
20 |
|
21 |
/**
|
22 |
+
* Fires the action hook for registering capabilities.
|
23 |
+
*
|
24 |
+
* @since 2.0.0
|
25 |
+
* @access public
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
function members_register_caps() {
|
29 |
+
|
30 |
+
do_action( 'members_register_caps' );
|
31 |
+
|
32 |
+
// The following is a quick way to register capabilities that technically
|
33 |
+
// exist (i.e., caps that have been added to a role). These are caps that
|
34 |
+
// we don't know about because they haven't been registered.
|
35 |
+
|
36 |
+
$role_caps = array_values( members_get_role_capabilities() );
|
37 |
+
$unregistered = array_diff( $role_caps, array_keys( members_get_caps() ) );
|
38 |
+
|
39 |
+
foreach ( $unregistered as $cap )
|
40 |
+
members_register_cap( $cap, array( 'label' => $cap ) );
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Registers all of our default caps. In particular, the plugin registers its own caps plus core
|
46 |
+
* WP's caps.
|
47 |
+
*
|
48 |
+
* @since 2.0.0
|
49 |
+
* @access public
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
function members_register_default_caps() {
|
53 |
+
|
54 |
+
$caps = array();
|
55 |
+
|
56 |
+
// General caps.
|
57 |
+
$caps['edit_dashboard'] = array( 'label' => __( 'Edit Dashboard', 'members' ), 'group' => 'general' );
|
58 |
+
$caps['edit_files'] = array( 'label' => __( 'Edit Files', 'members' ), 'group' => 'general' );
|
59 |
+
$caps['export'] = array( 'label' => __( 'Export', 'members' ), 'group' => 'general' );
|
60 |
+
$caps['import'] = array( 'label' => __( 'Import', 'members' ), 'group' => 'general' );
|
61 |
+
$caps['manage_links'] = array( 'label' => __( 'Manage Links', 'members' ), 'group' => 'general' );
|
62 |
+
$caps['manage_options'] = array( 'label' => __( 'Manage Options', 'members' ), 'group' => 'general' );
|
63 |
+
$caps['moderate_comments'] = array( 'label' => __( 'Moderate Comments', 'members' ), 'group' => 'general' );
|
64 |
+
$caps['read'] = array( 'label' => __( 'Read', 'members' ), 'group' => 'general' );
|
65 |
+
$caps['unfiltered_html'] = array( 'label' => __( 'Unfiltered HTML', 'members' ), 'group' => 'general' );
|
66 |
+
$caps['update_core'] = array( 'label' => __( 'Update Core', 'members' ), 'group' => 'general' );
|
67 |
+
|
68 |
+
// Post caps.
|
69 |
+
$caps['delete_others_posts'] = array( 'label' => __( "Delete Others' Posts", 'members' ), 'group' => 'type-post' );
|
70 |
+
$caps['delete_posts'] = array( 'label' => __( 'Delete Posts', 'members' ), 'group' => 'type-post' );
|
71 |
+
$caps['delete_private_posts'] = array( 'label' => __( 'Delete Private Posts', 'members' ), 'group' => 'type-post' );
|
72 |
+
$caps['delete_published_posts'] = array( 'label' => __( 'Delete Published Posts', 'members' ), 'group' => 'type-post' );
|
73 |
+
$caps['edit_others_posts'] = array( 'label' => __( "Edit Others' Posts", 'members' ), 'group' => 'type-post' );
|
74 |
+
$caps['edit_posts'] = array( 'label' => __( 'Edit Posts', 'members' ), 'group' => 'type-post' );
|
75 |
+
$caps['edit_private_posts'] = array( 'label' => __( 'Edit Private Posts', 'members' ), 'group' => 'type-post' );
|
76 |
+
$caps['edit_published_posts'] = array( 'label' => __( 'Edit Published Posts', 'members' ), 'group' => 'type-post' );
|
77 |
+
$caps['publish_posts'] = array( 'label' => __( 'Publish Posts', 'members' ), 'group' => 'type-post' );
|
78 |
+
$caps['read_private_posts'] = array( 'label' => __( 'Read Private Posts', 'members' ), 'group' => 'type-post' );
|
79 |
+
|
80 |
+
// Page caps.
|
81 |
+
$caps['delete_others_pages'] = array( 'label' => __( "Delete Others' Pages", 'members' ), 'group' => 'type-page' );
|
82 |
+
$caps['delete_pages'] = array( 'label' => __( 'Delete Pages', 'members' ), 'group' => 'type-page' );
|
83 |
+
$caps['delete_private_pages'] = array( 'label' => __( 'Delete Private Pages', 'members' ), 'group' => 'type-page' );
|
84 |
+
$caps['delete_published_pages'] = array( 'label' => __( 'Delete Published Pages', 'members' ), 'group' => 'type-page' );
|
85 |
+
$caps['edit_others_pages'] = array( 'label' => __( "Edit Others' Pages", 'members' ), 'group' => 'type-page' );
|
86 |
+
$caps['edit_pages'] = array( 'label' => __( 'Edit Pages', 'members' ), 'group' => 'type-page' );
|
87 |
+
$caps['edit_private_pages'] = array( 'label' => __( 'Edit Private Pages', 'members' ), 'group' => 'type-page' );
|
88 |
+
$caps['edit_published_pages'] = array( 'label' => __( 'Edit Published Pages', 'members' ), 'group' => 'type-page' );
|
89 |
+
$caps['publish_pages'] = array( 'label' => __( 'Publish Pages', 'members' ), 'group' => 'type-page' );
|
90 |
+
$caps['read_private_pages'] = array( 'label' => __( 'Read Private Pages', 'members' ), 'group' => 'type-page' );
|
91 |
+
|
92 |
+
// Attachment caps.
|
93 |
+
$caps['upload_files'] = array( 'label' => __( 'Upload Files', 'members' ), 'group' => 'type-attachment' );
|
94 |
+
|
95 |
+
// Taxonomy caps.
|
96 |
+
$caps['manage_categories'] = array( 'label' => __( 'Manage Categories', 'members' ), 'group' => 'taxonomy' );
|
97 |
+
|
98 |
+
// Theme caps.
|
99 |
+
$caps['delete_themes'] = array( 'label' => __( 'Delete Themes', 'members' ), 'group' => 'theme' );
|
100 |
+
$caps['edit_theme_options'] = array( 'label' => __( 'Edit Theme Options', 'members' ), 'group' => 'theme' );
|
101 |
+
$caps['edit_themes'] = array( 'label' => __( 'Edit Themes', 'members' ), 'group' => 'theme' );
|
102 |
+
$caps['install_themes'] = array( 'label' => __( 'Install Themes', 'members' ), 'group' => 'theme' );
|
103 |
+
$caps['switch_themes'] = array( 'label' => __( 'Switch Themes', 'members' ), 'group' => 'theme' );
|
104 |
+
$caps['update_themes'] = array( 'label' => __( 'Update Themes', 'members' ), 'group' => 'theme' );
|
105 |
+
|
106 |
+
// Plugin caps.
|
107 |
+
$caps['activate_plugins'] = array( 'label' => __( 'Activate Plugins', 'members' ), 'group' => 'plugin' );
|
108 |
+
$caps['delete_plugins'] = array( 'label' => __( 'Delete Plugins', 'members' ), 'group' => 'plugin' );
|
109 |
+
$caps['edit_plugins'] = array( 'label' => __( 'Edit Plugins', 'members' ), 'group' => 'plugin' );
|
110 |
+
$caps['install_plugins'] = array( 'label' => __( 'Install Plugins', 'members' ), 'group' => 'plugin' );
|
111 |
+
$caps['update_plugins'] = array( 'label' => __( 'Update Plugins', 'members' ), 'group' => 'plugin' );
|
112 |
+
|
113 |
+
// User caps.
|
114 |
+
$caps['create_roles'] = array( 'label' => __( 'Create Roles', 'members' ), 'group' => 'user' );
|
115 |
+
$caps['create_users'] = array( 'label' => __( 'Create Users', 'members' ), 'group' => 'user' );
|
116 |
+
$caps['delete_roles'] = array( 'label' => __( 'Delete Roles', 'members' ), 'group' => 'user' );
|
117 |
+
$caps['delete_users'] = array( 'label' => __( 'Delete Users', 'members' ), 'group' => 'user' );
|
118 |
+
$caps['edit_roles'] = array( 'label' => __( 'Edit Roles', 'members' ), 'group' => 'user' );
|
119 |
+
$caps['edit_users'] = array( 'label' => __( 'Edit Users', 'members' ), 'group' => 'user' );
|
120 |
+
$caps['list_roles'] = array( 'label' => __( 'List Roles', 'members' ), 'group' => 'user' );
|
121 |
+
$caps['list_users'] = array( 'label' => __( 'List Users', 'members' ), 'group' => 'user' );
|
122 |
+
$caps['promote_users'] = array( 'label' => __( 'Promote Users', 'members' ), 'group' => 'user' );
|
123 |
+
$caps['remove_users'] = array( 'label' => __( 'Remove Users', 'members' ), 'group' => 'user' );
|
124 |
+
|
125 |
+
// Custom caps.
|
126 |
+
$caps['restrict_content'] = array( 'label' => __( 'Restrict Content', 'members' ), 'group' => 'custom' );
|
127 |
+
|
128 |
+
// Register each of the capabilities.
|
129 |
+
foreach ( $caps as $name => $args )
|
130 |
+
members_register_cap( $name, $args );
|
131 |
+
|
132 |
+
// === Category and Tag caps. ===
|
133 |
+
// These are mapped to `manage_categories` in a default WP install. However, it's possible
|
134 |
+
// for another plugin to map these differently and handle them correctly. So, we're only
|
135 |
+
// going to register the caps if they've been assigned to a role. There's no other way
|
136 |
+
// to reliably detect if they've been mapped.
|
137 |
+
|
138 |
+
$role_caps = array_values( members_get_role_capabilities() );
|
139 |
+
$tax_caps = array();
|
140 |
+
|
141 |
+
$tax_caps['assign_categories'] = array( 'label' => __( 'Assign Categories', 'members' ), 'group' => 'taxonomy' );
|
142 |
+
$tax_caps['edit_categories'] = array( 'label' => __( 'Edit Categories', 'members' ), 'group' => 'taxonomy' );
|
143 |
+
$tax_caps['delete_categories'] = array( 'label' => __( 'Delete Categories', 'members' ), 'group' => 'taxonomy' );
|
144 |
+
$tax_caps['assign_post_tags'] = array( 'label' => __( 'Assign Post Tags', 'members' ), 'group' => 'taxonomy' );
|
145 |
+
$tax_caps['edit_post_tags'] = array( 'label' => __( 'Edit Post Tags', 'members' ), 'group' => 'taxonomy' );
|
146 |
+
$tax_caps['delete_post_tags'] = array( 'label' => __( 'Delete Post Tags', 'members' ), 'group' => 'taxonomy' );
|
147 |
+
$tax_caps['manage_post_tags'] = array( 'label' => __( 'Manage Post Tags', 'members' ), 'group' => 'taxonomy' );
|
148 |
+
|
149 |
+
foreach ( $tax_caps as $tax_cap => $args ) {
|
150 |
+
|
151 |
+
if ( in_array( $tax_cap, $role_caps ) )
|
152 |
+
members_register_cap( $tax_cap, $args );
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Returns the instance of the capability registry.
|
158 |
+
*
|
159 |
+
* @since 2.0.0
|
160 |
+
* @access public
|
161 |
+
* @return object
|
162 |
+
*/
|
163 |
+
function members_capability_registry() {
|
164 |
+
|
165 |
+
return \Members\Registry::get_instance( 'cap' );
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Returns all registered caps.
|
170 |
+
*
|
171 |
+
* @since 2.0.0
|
172 |
+
* @access public
|
173 |
+
* @return array
|
174 |
+
*/
|
175 |
+
function members_get_caps() {
|
176 |
+
|
177 |
+
return members_capability_registry()->get_collection();
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Registers a capability.
|
182 |
+
*
|
183 |
+
* @since 2.0.0
|
184 |
+
* @access public
|
185 |
+
* @param string $name
|
186 |
+
* @param array $args
|
187 |
+
* @return void
|
188 |
+
*/
|
189 |
+
function members_register_cap( $name, $args = array() ) {
|
190 |
+
|
191 |
+
members_capability_registry()->register( $name, new \Members\Capability( $name, $args ) );
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Unregisters a capability.
|
196 |
+
*
|
197 |
+
* @since 2.0.0
|
198 |
+
* @access public
|
199 |
+
* @param string $name
|
200 |
+
* @return void
|
201 |
+
*/
|
202 |
+
function members_unregister_cap( $name ) {
|
203 |
+
|
204 |
+
members_capability_registry()->unregister( $name );
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Returns a capability object.
|
209 |
+
*
|
210 |
+
* @since 2.0.0
|
211 |
+
* @access public
|
212 |
+
* @param string $name
|
213 |
+
* @return object
|
214 |
+
*/
|
215 |
+
function members_get_cap( $name ) {
|
216 |
+
|
217 |
+
return members_capability_registry()->get( $name );
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Checks if a capability object exists.
|
222 |
+
*
|
223 |
+
* @note In 2.0.0, the function was changed to only check from registered caps.
|
224 |
*
|
225 |
* @since 1.0.0
|
226 |
* @access public
|
227 |
+
* @param string $name
|
228 |
+
* @return bool
|
229 |
*/
|
230 |
+
function members_cap_exists( $name ) {
|
231 |
+
|
232 |
+
return members_capability_registry()->exists( $name );
|
233 |
}
|
234 |
|
235 |
/**
|
236 |
+
* Function for sanitizing a capability.
|
237 |
*
|
238 |
* @since 1.0.0
|
239 |
* @access public
|
240 |
* @param string $cap
|
241 |
+
* @return string
|
242 |
*/
|
243 |
+
function members_sanitize_cap( $cap ) {
|
244 |
+
|
245 |
+
return apply_filters( 'members_sanitize_cap', sanitize_key( $cap ) );
|
246 |
}
|
247 |
|
248 |
/**
|
256 |
*/
|
257 |
function members_is_cap_editable( $cap ) {
|
258 |
|
259 |
+
$uneditable = array_keys( members_get_uneditable_roles() );
|
260 |
|
261 |
return ! in_array( $cap, members_get_wp_capabilities() ) && ! array_intersect( $uneditable, members_get_cap_roles( $cap ) );
|
262 |
}
|
295 |
*/
|
296 |
function members_get_capabilities() {
|
297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
// Apply filters to the array of capabilities.
|
299 |
+
$capabilities = apply_filters( 'members_get_capabilities', array_keys( members_get_caps() ) );
|
300 |
|
301 |
// Sort the capabilities alphabetically.
|
302 |
sort( $capabilities );
|
339 |
return array_unique( $capabilities );
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
/**
|
343 |
* Checks if a specific capability has been given to at least one role. If it has, return true.
|
344 |
* Else, return false.
|
369 |
|
370 |
$caps = array();
|
371 |
|
372 |
+
// This is always a hidden cap and should never be added to the caps list.
|
373 |
+
$caps[] = 'do_not_allow';
|
374 |
+
|
375 |
// Unfiltered uploads.
|
376 |
if ( is_multisite() || ! defined( 'ALLOW_UNFILTERED_UPLOADS' ) || ! ALLOW_UNFILTERED_UPLOADS )
|
377 |
$caps[] = 'unfiltered_upload';
|
415 |
* @return array
|
416 |
*/
|
417 |
function members_remove_hidden_caps( $caps ) {
|
418 |
+
|
419 |
return apply_filters( 'members_remove_hidden_caps', true ) ? array_diff( $caps, members_get_hidden_caps() ) : $caps;
|
420 |
}
|
421 |
|
455 |
* @return array
|
456 |
*/
|
457 |
function members_remove_old_levels( $caps ) {
|
458 |
+
|
459 |
return apply_filters( 'members_remove_old_levels', true ) ? array_diff( $caps, members_get_old_levels() ) : $caps;
|
460 |
}
|
461 |
|
inc/functions-content-permissions.php
CHANGED
@@ -10,6 +10,20 @@
|
|
10 |
# Enable the content permissions features.
|
11 |
add_action( 'after_setup_theme', 'members_enable_content_permissions', 0 );
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Returns an array of the roles for a given post.
|
15 |
*
|
@@ -22,6 +36,24 @@ function members_get_post_roles( $post_id ) {
|
|
22 |
return get_post_meta( $post_id, '_members_access_role', false );
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* Adds a single role to a post's access roles.
|
27 |
*
|
@@ -32,6 +64,7 @@ function members_get_post_roles( $post_id ) {
|
|
32 |
* @return int|false
|
33 |
*/
|
34 |
function members_add_post_role( $post_id, $role ) {
|
|
|
35 |
return add_post_meta( $post_id, '_members_access_role', $role, false );
|
36 |
}
|
37 |
|
@@ -45,6 +78,7 @@ function members_add_post_role( $post_id, $role ) {
|
|
45 |
* @return bool
|
46 |
*/
|
47 |
function members_remove_post_role( $post_id, $role ) {
|
|
|
48 |
return delete_post_meta( $post_id, '_members_access_role', $role );
|
49 |
}
|
50 |
|
@@ -90,6 +124,7 @@ function members_set_post_roles( $post_id, $roles ) {
|
|
90 |
* @return bool
|
91 |
*/
|
92 |
function members_delete_post_roles( $post_id ) {
|
|
|
93 |
return delete_post_meta( $post_id, '_members_access_role' );
|
94 |
}
|
95 |
|
@@ -112,7 +147,7 @@ function members_enable_content_permissions() {
|
|
112 |
add_filter( 'get_the_excerpt', 'members_content_permissions_protect', 95 );
|
113 |
add_filter( 'the_excerpt', 'members_content_permissions_protect', 95 );
|
114 |
add_filter( 'the_content_feed', 'members_content_permissions_protect', 95 );
|
115 |
-
add_filter( '
|
116 |
|
117 |
// Filter the comments template to make sure comments aren't shown to users without access.
|
118 |
add_filter( 'comments_template', 'members_content_permissions_comments', 95 );
|
@@ -162,7 +197,7 @@ function members_content_permissions_comments( $template ) {
|
|
162 |
$has_template = locate_template( array( 'comments-no-access.php' ) );
|
163 |
|
164 |
// If the template was found, use it. Otherwise, fall back to the Members comments.php template.
|
165 |
-
$template = $has_template ? $has_template : members_plugin()->
|
166 |
|
167 |
// Allow devs to overwrite the comments template.
|
168 |
$template = apply_filters( 'members_comments_template', $template );
|
@@ -204,6 +239,7 @@ function members_get_post_error_message( $post_id ) {
|
|
204 |
* @return string
|
205 |
*/
|
206 |
function members_get_post_access_message( $post_id ) {
|
|
|
207 |
return get_post_meta( $post_id, '_members_access_error', true );
|
208 |
}
|
209 |
|
@@ -217,6 +253,7 @@ function members_get_post_access_message( $post_id ) {
|
|
217 |
* @return bool
|
218 |
*/
|
219 |
function members_set_post_access_message( $post_id, $message ) {
|
|
|
220 |
return update_post_meta( $post_id, '_members_access_error', $message );
|
221 |
}
|
222 |
|
@@ -229,6 +266,7 @@ function members_set_post_access_message( $post_id, $message ) {
|
|
229 |
* @return bool
|
230 |
*/
|
231 |
function members_delete_post_access_message( $post_id ) {
|
|
|
232 |
return delete_post_meta( $post_id, '_members_access_error' );
|
233 |
}
|
234 |
|
10 |
# Enable the content permissions features.
|
11 |
add_action( 'after_setup_theme', 'members_enable_content_permissions', 0 );
|
12 |
|
13 |
+
/**
|
14 |
+
* Conditional check to determine if a post any permissions rules assigned
|
15 |
+
* to it.
|
16 |
+
*
|
17 |
+
* @since 2.0.0
|
18 |
+
* @access public
|
19 |
+
* @param $post_id
|
20 |
+
* @return bool
|
21 |
+
*/
|
22 |
+
function members_has_post_permissions( $post_id = '' ) {
|
23 |
+
|
24 |
+
return members_has_post_roles( $post_id );
|
25 |
+
}
|
26 |
+
|
27 |
/**
|
28 |
* Returns an array of the roles for a given post.
|
29 |
*
|
36 |
return get_post_meta( $post_id, '_members_access_role', false );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Conditional check to determine if a post has roles assigned to it.
|
41 |
+
*
|
42 |
+
* @since 2.0.0
|
43 |
+
* @access public
|
44 |
+
* @param int $post_id
|
45 |
+
* @return bool
|
46 |
+
*/
|
47 |
+
function members_has_post_roles( $post_id = '' ) {
|
48 |
+
|
49 |
+
if ( ! $post_id )
|
50 |
+
$post_id = get_the_ID();
|
51 |
+
|
52 |
+
$roles = members_get_post_roles( $post_id );
|
53 |
+
|
54 |
+
return ! empty( $roles );
|
55 |
+
}
|
56 |
+
|
57 |
/**
|
58 |
* Adds a single role to a post's access roles.
|
59 |
*
|
64 |
* @return int|false
|
65 |
*/
|
66 |
function members_add_post_role( $post_id, $role ) {
|
67 |
+
|
68 |
return add_post_meta( $post_id, '_members_access_role', $role, false );
|
69 |
}
|
70 |
|
78 |
* @return bool
|
79 |
*/
|
80 |
function members_remove_post_role( $post_id, $role ) {
|
81 |
+
|
82 |
return delete_post_meta( $post_id, '_members_access_role', $role );
|
83 |
}
|
84 |
|
124 |
* @return bool
|
125 |
*/
|
126 |
function members_delete_post_roles( $post_id ) {
|
127 |
+
|
128 |
return delete_post_meta( $post_id, '_members_access_role' );
|
129 |
}
|
130 |
|
147 |
add_filter( 'get_the_excerpt', 'members_content_permissions_protect', 95 );
|
148 |
add_filter( 'the_excerpt', 'members_content_permissions_protect', 95 );
|
149 |
add_filter( 'the_content_feed', 'members_content_permissions_protect', 95 );
|
150 |
+
add_filter( 'get_comment_text', 'members_content_permissions_protect', 95 );
|
151 |
|
152 |
// Filter the comments template to make sure comments aren't shown to users without access.
|
153 |
add_filter( 'comments_template', 'members_content_permissions_comments', 95 );
|
197 |
$has_template = locate_template( array( 'comments-no-access.php' ) );
|
198 |
|
199 |
// If the template was found, use it. Otherwise, fall back to the Members comments.php template.
|
200 |
+
$template = $has_template ? $has_template : members_plugin()->dir . 'templates/comments.php';
|
201 |
|
202 |
// Allow devs to overwrite the comments template.
|
203 |
$template = apply_filters( 'members_comments_template', $template );
|
239 |
* @return string
|
240 |
*/
|
241 |
function members_get_post_access_message( $post_id ) {
|
242 |
+
|
243 |
return get_post_meta( $post_id, '_members_access_error', true );
|
244 |
}
|
245 |
|
253 |
* @return bool
|
254 |
*/
|
255 |
function members_set_post_access_message( $post_id, $message ) {
|
256 |
+
|
257 |
return update_post_meta( $post_id, '_members_access_error', $message );
|
258 |
}
|
259 |
|
266 |
* @return bool
|
267 |
*/
|
268 |
function members_delete_post_access_message( $post_id ) {
|
269 |
+
|
270 |
return delete_post_meta( $post_id, '_members_access_error' );
|
271 |
}
|
272 |
|
inc/functions-deprecated.php
CHANGED
@@ -4,29 +4,397 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* @since 0.2.0
|
15 |
* @deprecated 1.0.0
|
16 |
*/
|
17 |
-
function members_get_active_roles() {
|
18 |
-
_deprecated_function( __FUNCTION__, '1.0.0', 'members_get_active_role_names' );
|
19 |
-
return members_get_active_role_names();
|
20 |
-
}
|
21 |
|
22 |
/**
|
23 |
* @since 0.2.0
|
24 |
* @deprecated 1.0.0
|
25 |
*/
|
26 |
-
function members_get_inactive_roles() {
|
27 |
-
_deprecated_function( __FUNCTION__, '1.0.0', 'members_get_inactive_role_names' );
|
28 |
-
return members_get_inactive_role_names();
|
29 |
-
}
|
30 |
|
31 |
/**
|
32 |
* @since 0.2.0
|
@@ -55,6 +423,14 @@ function members_get_additional_capabilities() {
|
|
55 |
return members_get_plugin_capabilities();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/* ====== Functions removed in the 1.0 branch. ====== */
|
59 |
|
60 |
if ( ! function_exists( 'has_role' ) ) { function has_role() {} }
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
/**
|
14 |
+
* Returns an array of role names.
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
* @access public
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
function members_get_role_names() {
|
21 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
22 |
+
|
23 |
+
$roles = array();
|
24 |
+
|
25 |
+
foreach ( members_get_roles() as $role )
|
26 |
+
$roles[ $role->name ] = $role->name;
|
27 |
+
|
28 |
+
return $roles;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns an array of the role names of roles that have users.
|
33 |
+
*
|
34 |
+
* @since 1.0.0
|
35 |
+
* @access public
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
function members_get_active_role_names() {
|
39 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
40 |
+
|
41 |
+
$has_users = array();
|
42 |
+
|
43 |
+
foreach ( members_get_active_roles() as $role )
|
44 |
+
$has_users[ $role ] = members_get_role( $role )->label;
|
45 |
+
|
46 |
+
return $has_users;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Returns an array of the role names of roles that do not have users.
|
51 |
+
*
|
52 |
+
* @since 1.0.0
|
53 |
+
* @access public
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
function members_get_inactive_role_names() {
|
57 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
58 |
+
|
59 |
+
return array_diff( members_get_role_names(), members_get_active_role_names() );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns an array of editable role names.
|
64 |
+
*
|
65 |
+
* @since 1.0.0
|
66 |
+
* @access public
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
function members_get_editable_role_names() {
|
70 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
71 |
+
|
72 |
+
$editable = array();
|
73 |
+
|
74 |
+
foreach ( members_role_registry()->editable as $role )
|
75 |
+
$editable[ $role->slug ] = $role->name;
|
76 |
+
|
77 |
+
return $editable;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Returns an array of editable roles.
|
82 |
+
*
|
83 |
+
* @since 1.0.0
|
84 |
+
* @access public
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
function members_get_editable_role_slugs() {
|
88 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
89 |
+
|
90 |
+
return array_keys( members_role_registry()->editable );
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Returns an array of uneditable role names.
|
95 |
+
*
|
96 |
+
* @since 1.0.0
|
97 |
+
* @access public
|
98 |
+
* @return array
|
99 |
+
*/
|
100 |
+
function members_get_uneditable_role_names() {
|
101 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
102 |
+
|
103 |
+
$uneditable = array();
|
104 |
+
|
105 |
+
foreach ( members_role_registry()->uneditable as $role )
|
106 |
+
$uneditable[ $role->slug ] = $role->name;
|
107 |
+
|
108 |
+
return $uneditable;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Returns an array of uneditable roles.
|
113 |
+
*
|
114 |
+
* @since 1.0.0
|
115 |
+
* @access public
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
function members_get_uneditable_role_slugs() {
|
119 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
120 |
+
|
121 |
+
return array_keys( members_role_registry()->uneditable );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Returns an array of core WordPress role names.
|
126 |
+
*
|
127 |
+
* @since 1.0.0
|
128 |
+
* @access public
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
function members_get_wordpress_role_names() {
|
132 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
133 |
+
|
134 |
+
$names = array();
|
135 |
+
|
136 |
+
foreach ( members_role_registry()->wordpress as $role )
|
137 |
+
$names[ $role->slug ] = $role->name;
|
138 |
+
|
139 |
+
return $names;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Returns an array of core WP roles.
|
144 |
+
*
|
145 |
+
* @since 1.0.0
|
146 |
+
* @access public
|
147 |
+
* @return array
|
148 |
+
*/
|
149 |
+
function members_get_wordpress_role_slugs() {
|
150 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
151 |
+
|
152 |
+
return array_keys( members_role_registry()->wordpress );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns the human-readable role name.
|
157 |
+
*
|
158 |
+
* @since 1.0.0
|
159 |
+
* @access public
|
160 |
+
* @param string $role
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
function members_get_role_name( $role ) {
|
164 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
165 |
+
|
166 |
+
return members_role_registry()->get( $role )->name;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Returns an array of roles.
|
171 |
+
*
|
172 |
+
* @since 1.0.0
|
173 |
+
* @access public
|
174 |
+
* @return array
|
175 |
+
*/
|
176 |
+
function members_get_role_slugs() {
|
177 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
178 |
+
|
179 |
+
return array_keys( members_get_roles() );
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Returns an array of the roles that have users.
|
184 |
+
*
|
185 |
+
* @since 1.0.0
|
186 |
+
* @access public
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
function members_get_active_role_slugs() {
|
190 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
191 |
+
|
192 |
+
$has_users = array();
|
193 |
+
|
194 |
+
foreach ( members_get_role_user_count() as $role => $count ) {
|
195 |
+
|
196 |
+
if ( 0 < $count )
|
197 |
+
$has_users[] = $role;
|
198 |
+
}
|
199 |
+
|
200 |
+
return $has_users;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Returns an array of the roles that have no users.
|
205 |
+
*
|
206 |
+
* @since 1.0.0
|
207 |
+
* @access public
|
208 |
+
* @return array
|
209 |
+
*/
|
210 |
+
function members_get_inactive_role_slugs() {
|
211 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
212 |
+
|
213 |
+
return array_diff( array_keys( members_get_roles() ), members_get_active_roles() );
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Returns the caps for the all capability group.
|
218 |
+
*
|
219 |
+
* @since 1.0.0
|
220 |
+
* @access public
|
221 |
+
* @return array
|
222 |
+
*/
|
223 |
+
function members_get_all_group_caps() {
|
224 |
+
_deprecated_function( __FUNCTION__, '2.0.0', '' );
|
225 |
+
|
226 |
+
return members_get_capabilities();
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Returns the caps for the general capability group.
|
231 |
+
*
|
232 |
+
* @since 1.0.0
|
233 |
+
* @deprecated 2.0.0
|
234 |
+
* @access public
|
235 |
+
* @return array
|
236 |
+
*/
|
237 |
+
function members_get_general_group_caps() {
|
238 |
+
|
239 |
+
return array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'general' ) ) );
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Returns the caps for the theme capability group.
|
244 |
+
*
|
245 |
+
* @since 1.0.0
|
246 |
+
* @deprecated 2.0.0
|
247 |
+
* @access public
|
248 |
+
* @return array
|
249 |
+
*/
|
250 |
+
function members_get_theme_group_caps() {
|
251 |
+
|
252 |
+
return array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'theme' ) ) );
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Returns the caps for the plugin capability group.
|
257 |
+
*
|
258 |
+
* @since 1.0.0
|
259 |
+
* @deprecated 2.0.0
|
260 |
+
* @access public
|
261 |
+
* @return array
|
262 |
+
*/
|
263 |
+
function members_get_plugin_group_caps() {
|
264 |
+
|
265 |
+
return array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'plugin' ) ) );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Returns the caps for the user capability group.
|
270 |
+
*
|
271 |
+
* @since 1.0.0
|
272 |
+
* @deprecated 2.0.0
|
273 |
+
* @access public
|
274 |
+
* @return array
|
275 |
+
*/
|
276 |
+
function members_get_user_group_caps() {
|
277 |
+
|
278 |
+
return array_keys( wp_list_filter( members_get_caps(), array( 'group' => 'user' ) ) );
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Additional capabilities provided by the Members plugin that gives users permissions to handle
|
283 |
+
* certain features of the plugin.
|
284 |
+
*
|
285 |
+
* @since 1.0.0
|
286 |
+
* @deprecated 2.0.0
|
287 |
+
* @access public
|
288 |
+
* @return array
|
289 |
+
*/
|
290 |
+
function members_get_plugin_capabilities() {
|
291 |
+
|
292 |
+
return array(
|
293 |
+
'list_roles', // View roles list.
|
294 |
+
'create_roles', // Create new roles.
|
295 |
+
'delete_roles', // Delete roles.
|
296 |
+
'edit_roles', // Edit a role's caps.
|
297 |
+
'restrict_content' // Restrict content (content permissions component).
|
298 |
+
);
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Make sure we keep the default capabilities in case users screw 'em up. A user could easily
|
303 |
+
* remove a useful WordPress capability from all roles. When this happens, the capability is no
|
304 |
+
* longer stored in any of the roles, so it basically doesn't exist. This function will house
|
305 |
+
* all of the default WordPress capabilities in case this scenario comes into play.
|
306 |
+
*
|
307 |
+
* For those reading this note, yes, I did "accidentally" remove all capabilities from my
|
308 |
+
* administrator account when developing this plugin. And yes, that was fun putting back
|
309 |
+
* together. ;)
|
310 |
+
*
|
311 |
+
* @link http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
|
312 |
+
* @since 1.0.0
|
313 |
+
* @deprecated 2.0.0
|
314 |
+
* @access public
|
315 |
+
* @return array
|
316 |
+
*/
|
317 |
+
function members_get_wp_capabilities() {
|
318 |
+
|
319 |
+
return array(
|
320 |
+
'activate_plugins',
|
321 |
+
'add_users',
|
322 |
+
'assign_categories',
|
323 |
+
'assign_post_tags',
|
324 |
+
'create_users',
|
325 |
+
'delete_categories',
|
326 |
+
'delete_others_pages',
|
327 |
+
'delete_others_posts',
|
328 |
+
'delete_pages',
|
329 |
+
'delete_plugins',
|
330 |
+
'delete_posts',
|
331 |
+
'delete_post_tags',
|
332 |
+
'delete_private_pages',
|
333 |
+
'delete_private_posts',
|
334 |
+
'delete_published_pages',
|
335 |
+
'delete_published_posts',
|
336 |
+
'delete_themes',
|
337 |
+
'delete_users',
|
338 |
+
'edit_categories',
|
339 |
+
'edit_dashboard',
|
340 |
+
'edit_files',
|
341 |
+
'edit_others_pages',
|
342 |
+
'edit_others_posts',
|
343 |
+
'edit_pages',
|
344 |
+
'edit_plugins',
|
345 |
+
'edit_posts',
|
346 |
+
'edit_post_tags',
|
347 |
+
'edit_private_pages',
|
348 |
+
'edit_private_posts',
|
349 |
+
'edit_published_pages',
|
350 |
+
'edit_published_posts',
|
351 |
+
'edit_theme_options',
|
352 |
+
'edit_themes',
|
353 |
+
'edit_users',
|
354 |
+
'export',
|
355 |
+
'import',
|
356 |
+
'install_plugins',
|
357 |
+
'install_themes',
|
358 |
+
'list_users',
|
359 |
+
'manage_categories',
|
360 |
+
'manage_links',
|
361 |
+
'manage_options',
|
362 |
+
'manage_post_tags',
|
363 |
+
'moderate_comments',
|
364 |
+
'promote_users',
|
365 |
+
'publish_pages',
|
366 |
+
'publish_posts',
|
367 |
+
'read',
|
368 |
+
'read_private_pages',
|
369 |
+
'read_private_posts',
|
370 |
+
'remove_users',
|
371 |
+
'switch_themes',
|
372 |
+
'unfiltered_html',
|
373 |
+
'unfiltered_upload',
|
374 |
+
'update_core',
|
375 |
+
'update_plugins',
|
376 |
+
'update_themes',
|
377 |
+
'upload_files'
|
378 |
+
);
|
379 |
+
}
|
380 |
+
|
381 |
/**
|
382 |
* @since 0.2.0
|
383 |
* @deprecated 1.0.0
|
384 |
*/
|
385 |
+
//function members_get_active_roles() {
|
386 |
+
// _deprecated_function( __FUNCTION__, '1.0.0', 'members_get_active_role_names' );
|
387 |
+
// return members_get_active_role_names();
|
388 |
+
//}
|
389 |
|
390 |
/**
|
391 |
* @since 0.2.0
|
392 |
* @deprecated 1.0.0
|
393 |
*/
|
394 |
+
//function members_get_inactive_roles() {
|
395 |
+
// _deprecated_function( __FUNCTION__, '1.0.0', 'members_get_inactive_role_names' );
|
396 |
+
// return members_get_inactive_role_names();
|
397 |
+
//}
|
398 |
|
399 |
/**
|
400 |
* @since 0.2.0
|
423 |
return members_get_plugin_capabilities();
|
424 |
}
|
425 |
|
426 |
+
/* ====== Functions removed in the 2.0 branch. ====== */
|
427 |
+
|
428 |
+
function members_role_factory() {}
|
429 |
+
function members_role_group_factory() {}
|
430 |
+
function members_cap_group_factory() {}
|
431 |
+
function members_manage_users_columns() {}
|
432 |
+
function members_manage_users_custom_column() {}
|
433 |
+
|
434 |
/* ====== Functions removed in the 1.0 branch. ====== */
|
435 |
|
436 |
if ( ! function_exists( 'has_role' ) ) { function has_role() {} }
|
inc/functions-options.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -18,6 +18,7 @@
|
|
18 |
* @return bool
|
19 |
*/
|
20 |
function members_role_manager_enabled() {
|
|
|
21 |
return apply_filters( 'members_role_manager_enabled', members_get_setting( 'role_manager' ) );
|
22 |
}
|
23 |
|
@@ -30,9 +31,22 @@ function members_role_manager_enabled() {
|
|
30 |
* @return bool
|
31 |
*/
|
32 |
function members_explicitly_deny_caps() {
|
|
|
33 |
return apply_filters( 'members_explicitly_deny_caps', members_get_setting( 'explicit_denied_caps' ) );
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* Conditional check to see if the role manager is enabled.
|
38 |
*
|
@@ -41,6 +55,7 @@ function members_explicitly_deny_caps() {
|
|
41 |
* @return bool
|
42 |
*/
|
43 |
function members_multiple_user_roles_enabled() {
|
|
|
44 |
return apply_filters( 'members_multiple_roles_enabled', members_get_setting( 'multi_roles' ) );
|
45 |
}
|
46 |
|
@@ -52,6 +67,7 @@ function members_multiple_user_roles_enabled() {
|
|
52 |
* @return bool
|
53 |
*/
|
54 |
function members_content_permissions_enabled() {
|
|
|
55 |
return apply_filters( 'members_content_permissions_enabled', members_get_setting( 'content_permissions' ) );
|
56 |
}
|
57 |
|
@@ -63,6 +79,7 @@ function members_content_permissions_enabled() {
|
|
63 |
* @return bool
|
64 |
*/
|
65 |
function members_login_widget_enabled() {
|
|
|
66 |
return apply_filters( 'members_login_widget_enabled', members_get_setting( 'login_form_widget' ) );
|
67 |
}
|
68 |
|
@@ -74,6 +91,7 @@ function members_login_widget_enabled() {
|
|
74 |
* @return bool
|
75 |
*/
|
76 |
function members_users_widget_enabled() {
|
|
|
77 |
return apply_filters( 'members_users_widget_enabled', members_get_setting( 'users_widget' ) );
|
78 |
}
|
79 |
|
@@ -119,5 +137,9 @@ function members_get_default_settings() {
|
|
119 |
// @since 1.0.0
|
120 |
'explicit_denied_caps' => true,
|
121 |
'multi_roles' => true,
|
|
|
|
|
|
|
|
|
122 |
);
|
123 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
18 |
* @return bool
|
19 |
*/
|
20 |
function members_role_manager_enabled() {
|
21 |
+
|
22 |
return apply_filters( 'members_role_manager_enabled', members_get_setting( 'role_manager' ) );
|
23 |
}
|
24 |
|
31 |
* @return bool
|
32 |
*/
|
33 |
function members_explicitly_deny_caps() {
|
34 |
+
|
35 |
return apply_filters( 'members_explicitly_deny_caps', members_get_setting( 'explicit_denied_caps' ) );
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Whether to show human-readable caps.
|
40 |
+
*
|
41 |
+
* @since 2.0.0
|
42 |
+
* @access public
|
43 |
+
* @return bool
|
44 |
+
*/
|
45 |
+
function members_show_human_caps() {
|
46 |
+
|
47 |
+
return apply_filters( 'members_show_human_caps', members_get_setting( 'show_human_caps' ) );
|
48 |
+
}
|
49 |
+
|
50 |
/**
|
51 |
* Conditional check to see if the role manager is enabled.
|
52 |
*
|
55 |
* @return bool
|
56 |
*/
|
57 |
function members_multiple_user_roles_enabled() {
|
58 |
+
|
59 |
return apply_filters( 'members_multiple_roles_enabled', members_get_setting( 'multi_roles' ) );
|
60 |
}
|
61 |
|
67 |
* @return bool
|
68 |
*/
|
69 |
function members_content_permissions_enabled() {
|
70 |
+
|
71 |
return apply_filters( 'members_content_permissions_enabled', members_get_setting( 'content_permissions' ) );
|
72 |
}
|
73 |
|
79 |
* @return bool
|
80 |
*/
|
81 |
function members_login_widget_enabled() {
|
82 |
+
|
83 |
return apply_filters( 'members_login_widget_enabled', members_get_setting( 'login_form_widget' ) );
|
84 |
}
|
85 |
|
91 |
* @return bool
|
92 |
*/
|
93 |
function members_users_widget_enabled() {
|
94 |
+
|
95 |
return apply_filters( 'members_users_widget_enabled', members_get_setting( 'users_widget' ) );
|
96 |
}
|
97 |
|
137 |
// @since 1.0.0
|
138 |
'explicit_denied_caps' => true,
|
139 |
'multi_roles' => true,
|
140 |
+
|
141 |
+
// @since 2.0.0
|
142 |
+
'show_human_caps' => true,
|
143 |
+
'private_rest_api' => false,
|
144 |
);
|
145 |
}
|
inc/functions-private-site.php
CHANGED
@@ -6,9 +6,9 @@
|
|
6 |
*
|
7 |
* @package Members
|
8 |
* @subpackage Includes
|
9 |
-
* @author Justin Tadlock <
|
10 |
-
* @copyright Copyright (c) 2009 -
|
11 |
-
* @link
|
12 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
13 |
*/
|
14 |
|
@@ -30,6 +30,9 @@ add_filter( 'members_feed_error_message', 'wpautop'
|
|
30 |
add_filter( 'members_feed_error_message', 'do_shortcode', 30 );
|
31 |
add_filter( 'members_feed_error_message', 'shortcode_unautop', 35 );
|
32 |
|
|
|
|
|
|
|
33 |
/**
|
34 |
* Conditional tag to see if we have a private blog.
|
35 |
*
|
@@ -38,7 +41,8 @@ add_filter( 'members_feed_error_message', 'shortcod
|
|
38 |
* @return bool
|
39 |
*/
|
40 |
function members_is_private_blog() {
|
41 |
-
|
|
|
42 |
}
|
43 |
|
44 |
/**
|
@@ -49,7 +53,20 @@ function members_is_private_blog() {
|
|
49 |
* @return bool
|
50 |
*/
|
51 |
function members_is_private_feed() {
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -61,19 +78,45 @@ function members_is_private_feed() {
|
|
61 |
*/
|
62 |
function members_please_log_in() {
|
63 |
|
64 |
-
//
|
65 |
-
if ( members_is_private_blog() &&
|
|
|
|
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
return;
|
70 |
|
71 |
-
// Redirect to the login page.
|
72 |
auth_redirect();
|
73 |
exit;
|
74 |
}
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* Blocks feed items if the user has selected the private feed feature.
|
79 |
*
|
@@ -98,3 +141,64 @@ function members_get_private_feed_message() {
|
|
98 |
|
99 |
return apply_filters( 'members_feed_error_message', members_get_setting( 'private_feed_error' ) );
|
100 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*
|
7 |
* @package Members
|
8 |
* @subpackage Includes
|
9 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
10 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
11 |
+
* @link https://themehybrid.com/plugins/members
|
12 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
13 |
*/
|
14 |
|
30 |
add_filter( 'members_feed_error_message', 'do_shortcode', 30 );
|
31 |
add_filter( 'members_feed_error_message', 'shortcode_unautop', 35 );
|
32 |
|
33 |
+
# Authenticate when accessing the REST API.
|
34 |
+
add_filter( 'rest_authentication_errors', 'members_private_rest_api', 95 );
|
35 |
+
|
36 |
/**
|
37 |
* Conditional tag to see if we have a private blog.
|
38 |
*
|
41 |
* @return bool
|
42 |
*/
|
43 |
function members_is_private_blog() {
|
44 |
+
|
45 |
+
return apply_filters( 'members_is_private_blog', members_get_setting( 'private_blog' ) );
|
46 |
}
|
47 |
|
48 |
/**
|
53 |
* @return bool
|
54 |
*/
|
55 |
function members_is_private_feed() {
|
56 |
+
|
57 |
+
return apply_filters( 'members_is_private_feed', members_get_setting( 'private_feed' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Conditional tag to see if we have a private REST API
|
62 |
+
*
|
63 |
+
* @since 2.0.0
|
64 |
+
* @access public
|
65 |
+
* @return bool
|
66 |
+
*/
|
67 |
+
function members_is_private_rest_api() {
|
68 |
+
|
69 |
+
return apply_filters( 'members_is_private_rest_api', members_get_setting( 'private_rest_api' ) );
|
70 |
}
|
71 |
|
72 |
/**
|
78 |
*/
|
79 |
function members_please_log_in() {
|
80 |
|
81 |
+
// If this is a multisite instance and the user is logged into the network.
|
82 |
+
if ( members_is_private_blog() && is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() ) {
|
83 |
+
members_ms_private_blog_die();
|
84 |
+
}
|
85 |
|
86 |
+
// Check if the private blog feature is active and if the user is not logged in.
|
87 |
+
if ( members_is_private_blog() && ! is_user_logged_in() && members_is_private_page() ) {
|
|
|
88 |
|
|
|
89 |
auth_redirect();
|
90 |
exit;
|
91 |
}
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
+
* Function for determining whether a page should be public even though we're in private
|
96 |
+
* site mode. Plugin devs can filter this to make specific pages public.
|
97 |
+
*
|
98 |
+
* @since 2.0.0
|
99 |
+
* @access public
|
100 |
+
* @return bool
|
101 |
+
*/
|
102 |
+
function members_is_private_page() {
|
103 |
+
|
104 |
+
$is_private = true;
|
105 |
+
|
106 |
+
if ( function_exists( 'bp_is_current_component' ) && ( bp_is_current_component( 'register' ) || bp_is_current_component( 'activate' ) ) )
|
107 |
+
$is_private = false;
|
108 |
+
|
109 |
+
// WooCommerce support.
|
110 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
111 |
+
$page_id = get_option( 'woocommerce_myaccount_page_id' );
|
112 |
+
|
113 |
+
if ( is_page( $page_id ) )
|
114 |
+
$is_private = false;
|
115 |
+
}
|
116 |
+
|
117 |
+
return apply_filters( 'members_is_private_page', $is_private );
|
118 |
+
}
|
119 |
+
|
120 |
/**
|
121 |
* Blocks feed items if the user has selected the private feed feature.
|
122 |
*
|
141 |
|
142 |
return apply_filters( 'members_feed_error_message', members_get_setting( 'private_feed_error' ) );
|
143 |
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Returns an error if the REST API is accessed by an unauthenticated user.
|
147 |
+
*
|
148 |
+
* @link https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#require-authentication-for-all-requests
|
149 |
+
* @since 2.0.0
|
150 |
+
* @access public
|
151 |
+
* @param object $result
|
152 |
+
* @return object
|
153 |
+
*/
|
154 |
+
function members_private_rest_api( $result ) {
|
155 |
+
|
156 |
+
if ( empty( $result ) && members_is_private_rest_api() && ! is_user_logged_in() ) {
|
157 |
+
|
158 |
+
return new WP_Error(
|
159 |
+
'rest_not_logged_in',
|
160 |
+
esc_html(
|
161 |
+
apply_filters(
|
162 |
+
'members_rest_api_error_message',
|
163 |
+
__( 'You are not currently logged in.', 'members' )
|
164 |
+
)
|
165 |
+
),
|
166 |
+
array( 'status' => 401 )
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
return $result;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Outputs an error message if a user attempts to access a site that they do not have
|
175 |
+
* access to on multisite.
|
176 |
+
*
|
177 |
+
* @since 2.0.0
|
178 |
+
* @access public
|
179 |
+
* @return void
|
180 |
+
*/
|
181 |
+
function members_ms_private_blog_die() {
|
182 |
+
|
183 |
+
$blogs = get_blogs_of_user( get_current_user_id() );
|
184 |
+
|
185 |
+
$blogname = get_bloginfo( 'name' );
|
186 |
+
|
187 |
+
$message = __( 'You do not currently have access to the "%s" site. If you believe you should have access, please contact your network administrator.', 'members' );
|
188 |
+
|
189 |
+
if ( empty( $blogs ) )
|
190 |
+
wp_die( sprintf( $message, $blogname ), 403 );
|
191 |
+
|
192 |
+
$output = '<p>' . sprintf( $message, $blogname ) . '</p>';
|
193 |
+
|
194 |
+
$output .= sprintf( '<p>%s</p>', __( 'If you reached this page by accident and meant to visit one of your own sites, try one of the following links.', 'members' ) );
|
195 |
+
|
196 |
+
$output .= '<ul>';
|
197 |
+
|
198 |
+
foreach ( $blogs as $blog )
|
199 |
+
$output .= sprintf( '<li><a href="%s">%s</a></li>', esc_url( get_home_url( $blog->userblog_id ) ), esc_html( $blog->blogname ) );
|
200 |
+
|
201 |
+
$output .= '</ul>';
|
202 |
+
|
203 |
+
wp_die( $output, 403 );
|
204 |
+
}
|
inc/functions-role-groups.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Role groups API. Offers a standardized method for creating role groups.
|
4 |
+
*
|
5 |
+
* @package Members
|
6 |
+
* @subpackage Admin
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
# Registers default groups.
|
14 |
+
add_action( 'init', 'members_register_role_groups', 95 );
|
15 |
+
add_action( 'members_register_role_groups', 'members_register_default_role_groups', 5 );
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Fires the role group registration action hook.
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
* @access public
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
function members_register_role_groups() {
|
25 |
+
|
26 |
+
do_action( 'members_register_role_groups' );
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Registers the default role groups.
|
32 |
+
*
|
33 |
+
* @since 2.0.0
|
34 |
+
* @access public
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
function members_register_default_role_groups() {
|
38 |
+
|
39 |
+
// Register the WordPress group.
|
40 |
+
members_register_role_group( 'wordpress',
|
41 |
+
array(
|
42 |
+
'label' => esc_html__( 'WordPress', 'members' ),
|
43 |
+
'label_count' => _n_noop( 'WordPress %s', 'WordPress %s', 'members' ),
|
44 |
+
'roles' => members_get_wordpress_roles(),
|
45 |
+
)
|
46 |
+
);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Returns the instance of the role group registry.
|
51 |
+
*
|
52 |
+
* @since 2.0.0
|
53 |
+
* @access public
|
54 |
+
* @return object
|
55 |
+
*/
|
56 |
+
function members_role_group_registry() {
|
57 |
+
|
58 |
+
return \Members\Registry::get_instance( 'role_group' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Function for registering a role group.
|
63 |
+
*
|
64 |
+
* @since 1.0.0
|
65 |
+
* @access public
|
66 |
+
* @param string $name
|
67 |
+
* @param array $args
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
function members_register_role_group( $name, $args = array() ) {
|
71 |
+
|
72 |
+
members_role_group_registry()->register( $name, new \Members\Role_Group( $name, $args ) );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Unregisters a group.
|
77 |
+
*
|
78 |
+
* @since 1.0.0
|
79 |
+
* @access public
|
80 |
+
* @param string $name
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
function members_unregister_role_group( $name ) {
|
84 |
+
|
85 |
+
members_role_group_registry()->unregister( $name );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Checks if a group exists.
|
90 |
+
*
|
91 |
+
* @since 1.0.0
|
92 |
+
* @access public
|
93 |
+
* @param string $name
|
94 |
+
* @return bool
|
95 |
+
*/
|
96 |
+
function members_role_group_exists( $name ) {
|
97 |
+
|
98 |
+
return members_role_group_registry()->exists( $name );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Returns an array of registered group objects.
|
103 |
+
*
|
104 |
+
* @since 1.0.0
|
105 |
+
* @access public
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
function members_get_role_groups() {
|
109 |
+
|
110 |
+
return members_role_group_registry()->get_collection();
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Returns a group object if it exists. Otherwise, `FALSE`.
|
115 |
+
*
|
116 |
+
* @since 1.0.0
|
117 |
+
* @access public
|
118 |
+
* @param string $name
|
119 |
+
* @return object|bool
|
120 |
+
*/
|
121 |
+
function members_get_role_group( $name ) {
|
122 |
+
|
123 |
+
return members_role_group_registry()->get( $name );
|
124 |
+
}
|
inc/functions-role-meta.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function members_get_role_meta_option( $role ) {
|
4 |
-
|
5 |
-
return get_option( "members_{$role}_role_meta", array() );
|
6 |
-
}
|
7 |
-
|
8 |
-
function members_add_role_meta( $role, $meta_key, $meta_value, $unique = false ) {
|
9 |
-
|
10 |
-
$check = apply_filter( 'members_add_role_metadata', null, $role, $meta_key, $meta_value, $unique );
|
11 |
-
|
12 |
-
if ( ! is_null( $check ) )
|
13 |
-
return $check;
|
14 |
-
|
15 |
-
$role = members_sanitize_role( $role );
|
16 |
-
|
17 |
-
|
18 |
-
$option = members_get_role_meta_option( $role );
|
19 |
-
|
20 |
-
$add_value = $option[ $meta_key ][] = $meta_value;
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
function members_get_role_meta( $role, $meta_key = '', $single = false ) {
|
26 |
-
|
27 |
-
|
28 |
-
// Devs can short-circuit this by returning anything other than `null`.
|
29 |
-
$check = apply_filters( 'members_get_role_metadata', null, $role, $meta_key, $single );
|
30 |
-
|
31 |
-
if ( ! is_null( $check ) ) {
|
32 |
-
|
33 |
-
return $single && is_array( $check ) ? $check[0] : $check;
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
$role = members_sanitize_role( $role );
|
38 |
-
|
39 |
-
|
40 |
-
$option = members_get_role_meta_option( $role );
|
41 |
-
|
42 |
-
if ( ! $option || ! isset( $option[ $meta_key ] ) )
|
43 |
-
return '';
|
44 |
-
|
45 |
-
$meta_value = $option[ $meta_key ];
|
46 |
-
|
47 |
-
return $single && is_array( $meta_value ) ? $meta_value[0] : $meta_value;
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/functions-roles.php
CHANGED
@@ -4,241 +4,217 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
* @since 1.0.0
|
17 |
-
* @access public
|
18 |
-
* @param string
|
19 |
-
* @return bool
|
20 |
-
*/
|
21 |
-
function members_role_factory() {
|
22 |
-
return Members_Role_Factory::get_instance();
|
23 |
-
}
|
24 |
-
|
25 |
-
/* ====== Multiple Role Functions ====== */
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
*
|
30 |
-
* @since
|
31 |
* @access public
|
32 |
-
* @
|
|
|
33 |
*/
|
34 |
-
function
|
35 |
-
return count( $GLOBALS['wp_roles']->role_names );
|
36 |
-
}
|
37 |
|
38 |
-
|
39 |
-
* Returns an array of `Members_Role` objects.
|
40 |
-
*
|
41 |
-
* @since 1.0.0
|
42 |
-
* @access public
|
43 |
-
* @return array
|
44 |
-
*/
|
45 |
-
function members_get_roles() {
|
46 |
-
return members_role_factory()->roles;
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
*
|
52 |
-
* @since
|
53 |
* @access public
|
54 |
-
* @
|
|
|
55 |
*/
|
56 |
-
function
|
57 |
-
$roles = array();
|
58 |
|
59 |
-
foreach (
|
60 |
-
$roles[ $role->slug ] = $role->name;
|
61 |
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
*
|
68 |
-
* @since 1.0.0
|
69 |
-
* @access public
|
70 |
-
* @return array
|
71 |
-
*/
|
72 |
-
function members_get_role_slugs() {
|
73 |
-
return array_keys( members_role_factory()->roles );
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
* Returns
|
78 |
*
|
79 |
-
* @since
|
80 |
* @access public
|
81 |
-
* @return
|
82 |
*/
|
83 |
-
function
|
84 |
-
$has_users = array();
|
85 |
-
|
86 |
-
foreach ( members_get_active_role_slugs() as $role )
|
87 |
-
$has_users[ $role ] = members_get_role_name( $role );
|
88 |
|
89 |
-
return
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
* Returns
|
94 |
*
|
95 |
* @since 1.0.0
|
96 |
* @access public
|
97 |
* @return array
|
98 |
*/
|
99 |
-
function
|
100 |
-
|
101 |
-
$has_users = array();
|
102 |
-
|
103 |
-
foreach ( members_get_role_user_count() as $role => $count ) {
|
104 |
-
|
105 |
-
if ( 0 < $count )
|
106 |
-
$has_users[] = $role;
|
107 |
-
}
|
108 |
|
109 |
-
return
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
-
*
|
114 |
*
|
115 |
-
* @since
|
116 |
* @access public
|
117 |
-
* @
|
|
|
|
|
118 |
*/
|
119 |
-
function
|
120 |
-
|
|
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
-
*
|
125 |
*
|
126 |
-
* @since
|
127 |
* @access public
|
128 |
-
* @
|
|
|
129 |
*/
|
130 |
-
function
|
131 |
-
|
|
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
-
* Returns
|
136 |
*
|
137 |
-
* @since
|
138 |
* @access public
|
139 |
-
* @
|
|
|
140 |
*/
|
141 |
-
function
|
142 |
-
$editable = array();
|
143 |
|
144 |
-
|
145 |
-
$editable[ $role->slug ] = $role->name;
|
146 |
-
|
147 |
-
return $editable;
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
-
*
|
152 |
*
|
153 |
-
* @since
|
154 |
* @access public
|
155 |
-
* @
|
|
|
156 |
*/
|
157 |
-
function
|
158 |
-
|
|
|
159 |
}
|
160 |
|
|
|
|
|
161 |
/**
|
162 |
-
* Returns an array of
|
163 |
*
|
164 |
-
* @since
|
165 |
* @access public
|
|
|
166 |
* @return array
|
167 |
*/
|
168 |
-
function
|
169 |
-
$
|
170 |
|
171 |
-
|
172 |
-
$uneditable[ $role->slug ] = $role->name;
|
173 |
|
174 |
-
return $
|
175 |
}
|
176 |
|
177 |
/**
|
178 |
* Returns an array of uneditable roles.
|
179 |
*
|
180 |
-
* @since
|
181 |
* @access public
|
182 |
* @return array
|
183 |
*/
|
184 |
-
function
|
185 |
-
|
|
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
-
* Returns an array of core
|
190 |
*
|
191 |
-
* @since
|
192 |
* @access public
|
193 |
* @return array
|
194 |
*/
|
195 |
-
function
|
196 |
-
$names = array();
|
197 |
|
198 |
-
|
199 |
-
$names[ $role->slug ] = $role->name;
|
200 |
|
201 |
-
return $
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
-
* Returns an array of
|
206 |
*
|
207 |
-
* @since
|
208 |
* @access public
|
209 |
* @return array
|
210 |
*/
|
211 |
-
function
|
212 |
-
return array_keys( members_role_factory()->wordpress );
|
213 |
-
}
|
214 |
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
/**
|
218 |
-
*
|
219 |
*
|
220 |
-
* @since
|
221 |
* @access public
|
222 |
-
* @
|
223 |
-
* @return bool
|
224 |
*/
|
225 |
-
function
|
226 |
-
|
|
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
-
*
|
231 |
*
|
232 |
-
* @see Members_Role
|
233 |
* @since 1.0.0
|
234 |
* @access public
|
235 |
-
* @
|
236 |
-
* @return object
|
237 |
*/
|
238 |
-
function
|
239 |
-
|
|
|
240 |
}
|
241 |
|
|
|
|
|
242 |
/**
|
243 |
* Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only
|
244 |
* alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
|
@@ -248,8 +224,10 @@ function members_get_role( $role ) {
|
|
248 |
* @return int
|
249 |
*/
|
250 |
function members_sanitize_role( $role ) {
|
|
|
251 |
$_role = strtolower( $role );
|
252 |
$_role = preg_replace( '/[^a-z0-9_\-\s]/', '', $_role );
|
|
|
253 |
return apply_filters( 'members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
|
254 |
}
|
255 |
|
@@ -280,7 +258,8 @@ function members_translate_role( $role ) {
|
|
280 |
* @return bool
|
281 |
*/
|
282 |
function members_role_has_users( $role ) {
|
283 |
-
|
|
|
284 |
}
|
285 |
|
286 |
/**
|
@@ -291,7 +270,8 @@ function members_role_has_users( $role ) {
|
|
291 |
* @return bool
|
292 |
*/
|
293 |
function members_role_has_caps( $role ) {
|
294 |
-
|
|
|
295 |
}
|
296 |
|
297 |
/**
|
@@ -333,7 +313,8 @@ function members_get_role_user_count( $role = '' ) {
|
|
333 |
* @return int
|
334 |
*/
|
335 |
function members_get_role_granted_cap_count( $role ) {
|
336 |
-
|
|
|
337 |
}
|
338 |
|
339 |
/**
|
@@ -345,19 +326,8 @@ function members_get_role_granted_cap_count( $role ) {
|
|
345 |
* @return int
|
346 |
*/
|
347 |
function members_get_role_denied_cap_count( $role ) {
|
348 |
-
return members_role_factory()->get_role( $role )->denied_cap_count;
|
349 |
-
}
|
350 |
|
351 |
-
|
352 |
-
* Returns the human-readable role name.
|
353 |
-
*
|
354 |
-
* @since 1.0.0
|
355 |
-
* @access public
|
356 |
-
* @param string $role
|
357 |
-
* @return string
|
358 |
-
*/
|
359 |
-
function members_get_role_name( $role ) {
|
360 |
-
return members_role_factory()->get_role( $role )->name;
|
361 |
}
|
362 |
|
363 |
/**
|
@@ -369,11 +339,12 @@ function members_get_role_name( $role ) {
|
|
369 |
* @return bool
|
370 |
*/
|
371 |
function members_is_role_editable( $role ) {
|
372 |
-
|
|
|
373 |
}
|
374 |
|
375 |
/**
|
376 |
-
* Conditional tag to check whether a role is a core WordPress
|
377 |
*
|
378 |
* @since 1.0.0
|
379 |
* @access public
|
@@ -381,6 +352,7 @@ function members_is_role_editable( $role ) {
|
|
381 |
* @return bool
|
382 |
*/
|
383 |
function members_is_wordpress_role( $role ) {
|
|
|
384 |
return in_array( $role, array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ) );
|
385 |
}
|
386 |
|
@@ -394,6 +366,7 @@ function members_is_wordpress_role( $role ) {
|
|
394 |
* @return string
|
395 |
*/
|
396 |
function members_get_new_role_url() {
|
|
|
397 |
return add_query_arg( 'page', 'role-new', admin_url( 'users.php' ) );
|
398 |
}
|
399 |
|
@@ -406,6 +379,7 @@ function members_get_new_role_url() {
|
|
406 |
* @return string
|
407 |
*/
|
408 |
function members_get_clone_role_url( $role ) {
|
|
|
409 |
return add_query_arg( 'clone', $role, members_get_new_role_url() );
|
410 |
}
|
411 |
|
@@ -417,6 +391,7 @@ function members_get_clone_role_url( $role ) {
|
|
417 |
* @return string
|
418 |
*/
|
419 |
function members_get_edit_roles_url() {
|
|
|
420 |
return add_query_arg( 'page', 'roles', admin_url( 'users.php' ) );
|
421 |
}
|
422 |
|
@@ -429,7 +404,8 @@ function members_get_edit_roles_url() {
|
|
429 |
* @return string
|
430 |
*/
|
431 |
function members_get_role_view_url( $view ) {
|
432 |
-
|
|
|
433 |
}
|
434 |
|
435 |
/**
|
@@ -441,6 +417,7 @@ function members_get_role_view_url( $view ) {
|
|
441 |
* @return string
|
442 |
*/
|
443 |
function members_get_edit_role_url( $role ) {
|
|
|
444 |
return add_query_arg( array( 'action' => 'edit', 'role' => $role ), members_get_edit_roles_url() );
|
445 |
}
|
446 |
|
@@ -453,6 +430,7 @@ function members_get_edit_role_url( $role ) {
|
|
453 |
* @return string
|
454 |
*/
|
455 |
function members_get_delete_role_url( $role ) {
|
|
|
456 |
$url = add_query_arg( array( 'action' => 'delete', 'role' => $role ), members_get_edit_roles_url() );
|
457 |
|
458 |
return wp_nonce_url( $url, 'delete_role', 'members_delete_role_nonce' );
|
@@ -467,5 +445,6 @@ function members_get_delete_role_url( $role ) {
|
|
467 |
* @return string
|
468 |
*/
|
469 |
function members_get_role_users_url( $role ) {
|
|
|
470 |
return admin_url( add_query_arg( 'role', $role, 'users.php' ) );
|
471 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
13 |
+
# Register roles.
|
14 |
+
add_action( 'wp_roles_init', 'members_register_roles', 95 );
|
15 |
+
add_action( 'members_register_roles', 'members_register_default_roles', 5 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
+
* Fires the role registration action hook.
|
19 |
*
|
20 |
+
* @since 2.0.0
|
21 |
* @access public
|
22 |
+
* @param object $wp_roles
|
23 |
+
* @return void
|
24 |
*/
|
25 |
+
function members_register_roles( $wp_roles ) {
|
|
|
|
|
26 |
|
27 |
+
do_action( 'members_register_roles', $wp_roles );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* Registers any roles stored globally with WordPress.
|
32 |
*
|
33 |
+
* @since 2.0.0
|
34 |
* @access public
|
35 |
+
* @param object $wp_roles
|
36 |
+
* @return void
|
37 |
*/
|
38 |
+
function members_register_default_roles( $wp_roles ) {
|
|
|
39 |
|
40 |
+
foreach ( $wp_roles->roles as $name => $object ) {
|
|
|
41 |
|
42 |
+
$args = array(
|
43 |
+
'label' => $object['name'],
|
44 |
+
'caps' => $object['capabilities']
|
45 |
+
);
|
46 |
|
47 |
+
members_register_role( $name, $args );
|
48 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* Returns the instance of the role registry.
|
53 |
*
|
54 |
+
* @since 2.0.0
|
55 |
* @access public
|
56 |
+
* @return object
|
57 |
*/
|
58 |
+
function members_role_registry() {
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
return \Members\Registry::get_instance( 'role' );
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
+
* Returns all registered roles.
|
65 |
*
|
66 |
* @since 1.0.0
|
67 |
* @access public
|
68 |
* @return array
|
69 |
*/
|
70 |
+
function members_get_roles() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
return members_role_registry()->get_collection();
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
+
* Registers a role.
|
77 |
*
|
78 |
+
* @since 2.0.0
|
79 |
* @access public
|
80 |
+
* @param string $name
|
81 |
+
* @param array $args
|
82 |
+
* @return void
|
83 |
*/
|
84 |
+
function members_register_role( $name, $args = array() ) {
|
85 |
+
|
86 |
+
members_role_registry()->register( $name, new \Members\Role( $name, $args ) );
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
+
* Unregisters a role.
|
91 |
*
|
92 |
+
* @since 2.0.0
|
93 |
* @access public
|
94 |
+
* @param string $name
|
95 |
+
* @return void
|
96 |
*/
|
97 |
+
function members_unregister_role( $name ) {
|
98 |
+
|
99 |
+
members_role_registry()->unregister( $name );
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* Returns a role object.
|
104 |
*
|
105 |
+
* @since 2.0.0
|
106 |
* @access public
|
107 |
+
* @param string $name
|
108 |
+
* @return object
|
109 |
*/
|
110 |
+
function members_get_role( $name ) {
|
|
|
111 |
|
112 |
+
return members_role_registry()->get( $name );
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
+
* Checks if a role object exists.
|
117 |
*
|
118 |
+
* @since 2.0.0
|
119 |
* @access public
|
120 |
+
* @param string $name
|
121 |
+
* @return bool
|
122 |
*/
|
123 |
+
function members_role_exists( $name ) {
|
124 |
+
|
125 |
+
return members_role_registry()->exists( $name );
|
126 |
}
|
127 |
|
128 |
+
/* ====== Multiple Role Functions ====== */
|
129 |
+
|
130 |
/**
|
131 |
+
* Returns an array of editable roles.
|
132 |
*
|
133 |
+
* @since 2.0.0
|
134 |
* @access public
|
135 |
+
* @global array $wp_roles
|
136 |
* @return array
|
137 |
*/
|
138 |
+
function members_get_editable_roles() {
|
139 |
+
global $wp_roles;
|
140 |
|
141 |
+
$editable = function_exists( 'get_editable_roles' ) ? get_editable_roles() : apply_filters( 'editable_roles', $wp_roles->roles );
|
|
|
142 |
|
143 |
+
return array_keys( $editable );
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
* Returns an array of uneditable roles.
|
148 |
*
|
149 |
+
* @since 2.0.0
|
150 |
* @access public
|
151 |
* @return array
|
152 |
*/
|
153 |
+
function members_get_uneditable_roles() {
|
154 |
+
|
155 |
+
return array_diff( array_keys( members_get_roles() ), members_get_editable_roles() );
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
+
* Returns an array of core WP roles. Note that we remove any that are not registered.
|
160 |
*
|
161 |
+
* @since 2.0.0
|
162 |
* @access public
|
163 |
* @return array
|
164 |
*/
|
165 |
+
function members_get_wordpress_roles() {
|
|
|
166 |
|
167 |
+
$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
|
|
|
168 |
|
169 |
+
return array_intersect( $roles, array_keys( members_get_roles() ) );
|
170 |
}
|
171 |
|
172 |
/**
|
173 |
+
* Returns an array of the roles that have users.
|
174 |
*
|
175 |
+
* @since 2.0.0
|
176 |
* @access public
|
177 |
* @return array
|
178 |
*/
|
179 |
+
function members_get_active_roles() {
|
|
|
|
|
180 |
|
181 |
+
$has_users = array();
|
182 |
+
|
183 |
+
foreach ( members_get_role_user_count() as $role => $count ) {
|
184 |
+
|
185 |
+
if ( 0 < $count )
|
186 |
+
$has_users[] = $role;
|
187 |
+
}
|
188 |
+
|
189 |
+
return $has_users;
|
190 |
+
}
|
191 |
|
192 |
/**
|
193 |
+
* Returns an array of the roles that have no users.
|
194 |
*
|
195 |
+
* @since 2.0.0
|
196 |
* @access public
|
197 |
+
* @return array
|
|
|
198 |
*/
|
199 |
+
function members_get_inactive_roles() {
|
200 |
+
|
201 |
+
return array_diff( array_keys( members_get_roles() ), members_get_active_roles() );
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* Returns a count of all the available roles for the site.
|
206 |
*
|
|
|
207 |
* @since 1.0.0
|
208 |
* @access public
|
209 |
+
* @return int
|
|
|
210 |
*/
|
211 |
+
function members_get_role_count() {
|
212 |
+
|
213 |
+
return count( $GLOBALS['wp_roles']->role_names );
|
214 |
}
|
215 |
|
216 |
+
/* ====== Single Role Functions ====== */
|
217 |
+
|
218 |
/**
|
219 |
* Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only
|
220 |
* alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
|
224 |
* @return int
|
225 |
*/
|
226 |
function members_sanitize_role( $role ) {
|
227 |
+
|
228 |
$_role = strtolower( $role );
|
229 |
$_role = preg_replace( '/[^a-z0-9_\-\s]/', '', $_role );
|
230 |
+
|
231 |
return apply_filters( 'members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
|
232 |
}
|
233 |
|
258 |
* @return bool
|
259 |
*/
|
260 |
function members_role_has_users( $role ) {
|
261 |
+
|
262 |
+
return in_array( $role, members_get_active_roles() );
|
263 |
}
|
264 |
|
265 |
/**
|
270 |
* @return bool
|
271 |
*/
|
272 |
function members_role_has_caps( $role ) {
|
273 |
+
|
274 |
+
return members_get_role( $role )->has_caps;
|
275 |
}
|
276 |
|
277 |
/**
|
313 |
* @return int
|
314 |
*/
|
315 |
function members_get_role_granted_cap_count( $role ) {
|
316 |
+
|
317 |
+
return members_get_role( $role )->granted_cap_count;
|
318 |
}
|
319 |
|
320 |
/**
|
326 |
* @return int
|
327 |
*/
|
328 |
function members_get_role_denied_cap_count( $role ) {
|
|
|
|
|
329 |
|
330 |
+
return members_get_role( $role )->denied_cap_count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
/**
|
339 |
* @return bool
|
340 |
*/
|
341 |
function members_is_role_editable( $role ) {
|
342 |
+
|
343 |
+
return in_array( $role, members_get_editable_roles() );
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
+
* Conditional tag to check whether a role is a core WordPress role.
|
348 |
*
|
349 |
* @since 1.0.0
|
350 |
* @access public
|
352 |
* @return bool
|
353 |
*/
|
354 |
function members_is_wordpress_role( $role ) {
|
355 |
+
|
356 |
return in_array( $role, array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ) );
|
357 |
}
|
358 |
|
366 |
* @return string
|
367 |
*/
|
368 |
function members_get_new_role_url() {
|
369 |
+
|
370 |
return add_query_arg( 'page', 'role-new', admin_url( 'users.php' ) );
|
371 |
}
|
372 |
|
379 |
* @return string
|
380 |
*/
|
381 |
function members_get_clone_role_url( $role ) {
|
382 |
+
|
383 |
return add_query_arg( 'clone', $role, members_get_new_role_url() );
|
384 |
}
|
385 |
|
391 |
* @return string
|
392 |
*/
|
393 |
function members_get_edit_roles_url() {
|
394 |
+
|
395 |
return add_query_arg( 'page', 'roles', admin_url( 'users.php' ) );
|
396 |
}
|
397 |
|
404 |
* @return string
|
405 |
*/
|
406 |
function members_get_role_view_url( $view ) {
|
407 |
+
|
408 |
+
return add_query_arg( 'view', $view, members_get_edit_roles_url() );
|
409 |
}
|
410 |
|
411 |
/**
|
417 |
* @return string
|
418 |
*/
|
419 |
function members_get_edit_role_url( $role ) {
|
420 |
+
|
421 |
return add_query_arg( array( 'action' => 'edit', 'role' => $role ), members_get_edit_roles_url() );
|
422 |
}
|
423 |
|
430 |
* @return string
|
431 |
*/
|
432 |
function members_get_delete_role_url( $role ) {
|
433 |
+
|
434 |
$url = add_query_arg( array( 'action' => 'delete', 'role' => $role ), members_get_edit_roles_url() );
|
435 |
|
436 |
return wp_nonce_url( $url, 'delete_role', 'members_delete_role_nonce' );
|
445 |
* @return string
|
446 |
*/
|
447 |
function members_get_role_users_url( $role ) {
|
448 |
+
|
449 |
return admin_url( add_query_arg( 'role', $role, 'users.php' ) );
|
450 |
}
|
inc/functions-shortcodes.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -38,6 +38,9 @@ function members_register_shortcodes() {
|
|
38 |
add_shortcode( 'members_logged_in', 'members_is_user_logged_in_shortcode' );
|
39 |
add_shortcode( 'is_user_logged_in', 'members_is_user_logged_in_shortcode' ); // @deprecated 1.0.0
|
40 |
|
|
|
|
|
|
|
41 |
// @deprecated 0.2.0.
|
42 |
add_shortcode( 'get_avatar', 'members_get_avatar_shortcode' );
|
43 |
add_shortcode( 'avatar', 'members_get_avatar_shortcode' );
|
@@ -58,6 +61,20 @@ function members_is_user_logged_in_shortcode( $attr, $content = null ) {
|
|
58 |
return is_feed() || ! is_user_logged_in() || is_null( $content ) ? '' : do_shortcode( $content );
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
/**
|
62 |
* Content that should only be shown in feed readers. Can be useful for displaying
|
63 |
* feed-specific items.
|
@@ -91,28 +108,31 @@ function members_access_check_shortcode( $attr, $content = null ) {
|
|
91 |
if ( is_null( $content ) || is_feed() )
|
92 |
return '';
|
93 |
|
|
|
|
|
94 |
// Set up the default attributes.
|
95 |
$defaults = array(
|
96 |
'capability' => '', // Single capability or comma-separated multiple capabilities.
|
97 |
'role' => '', // Single role or comma-separated multiple roles.
|
|
|
98 |
);
|
99 |
|
100 |
// Merge the input attributes and the defaults.
|
101 |
$attr = shortcode_atts( $defaults, $attr, 'members_access' );
|
102 |
|
|
|
|
|
|
|
103 |
// If the current user has the capability, show the content.
|
104 |
if ( $attr['capability'] ) {
|
105 |
|
106 |
// Get the capabilities.
|
107 |
$caps = explode( ',', $attr['capability'] );
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
113 |
-
if ( current_user_can( trim( $cap ) ) )
|
114 |
-
return do_shortcode( $content );
|
115 |
-
}
|
116 |
}
|
117 |
|
118 |
// If the current user has the role, show the content.
|
@@ -121,13 +141,10 @@ function members_access_check_shortcode( $attr, $content = null ) {
|
|
121 |
// Get the roles.
|
122 |
$roles = explode( ',', $attr['role'] );
|
123 |
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
|
128 |
-
if ( members_current_user_has_role( trim( $role ) ) )
|
129 |
-
return do_shortcode( $content );
|
130 |
-
}
|
131 |
}
|
132 |
|
133 |
// Return an empty string if we've made it to this point.
|
@@ -142,5 +159,6 @@ function members_access_check_shortcode( $attr, $content = null ) {
|
|
142 |
* @return string
|
143 |
*/
|
144 |
function members_login_form_shortcode() {
|
|
|
145 |
return wp_login_form( array( 'echo' => false ) );
|
146 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
38 |
add_shortcode( 'members_logged_in', 'members_is_user_logged_in_shortcode' );
|
39 |
add_shortcode( 'is_user_logged_in', 'members_is_user_logged_in_shortcode' ); // @deprecated 1.0.0
|
40 |
|
41 |
+
// Add the `[members_not_logged_in]` shortcode.
|
42 |
+
add_shortcode( 'members_not_logged_in', 'members_not_logged_in_shortcode' );
|
43 |
+
|
44 |
// @deprecated 0.2.0.
|
45 |
add_shortcode( 'get_avatar', 'members_get_avatar_shortcode' );
|
46 |
add_shortcode( 'avatar', 'members_get_avatar_shortcode' );
|
61 |
return is_feed() || ! is_user_logged_in() || is_null( $content ) ? '' : do_shortcode( $content );
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* Displays content if the user viewing it is not currently logged in.
|
66 |
+
*
|
67 |
+
* @since 2.0.0
|
68 |
+
* @access public
|
69 |
+
* @param array $attr
|
70 |
+
* @param string $content
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
function members_not_logged_in_shortcode( $attr, $content = null ) {
|
74 |
+
|
75 |
+
return is_user_logged_in() || is_null( $content ) ? '' : do_shortcode( $content );
|
76 |
+
}
|
77 |
+
|
78 |
/**
|
79 |
* Content that should only be shown in feed readers. Can be useful for displaying
|
80 |
* feed-specific items.
|
108 |
if ( is_null( $content ) || is_feed() )
|
109 |
return '';
|
110 |
|
111 |
+
$user_can = false;
|
112 |
+
|
113 |
// Set up the default attributes.
|
114 |
$defaults = array(
|
115 |
'capability' => '', // Single capability or comma-separated multiple capabilities.
|
116 |
'role' => '', // Single role or comma-separated multiple roles.
|
117 |
+
'operator' => 'or' // Only the `!` operator is supported for now. Everything else falls back to `or`.
|
118 |
);
|
119 |
|
120 |
// Merge the input attributes and the defaults.
|
121 |
$attr = shortcode_atts( $defaults, $attr, 'members_access' );
|
122 |
|
123 |
+
// Get the operator.
|
124 |
+
$operator = strtolower( $attr['operator'] );
|
125 |
+
|
126 |
// If the current user has the capability, show the content.
|
127 |
if ( $attr['capability'] ) {
|
128 |
|
129 |
// Get the capabilities.
|
130 |
$caps = explode( ',', $attr['capability'] );
|
131 |
|
132 |
+
if ( '!' === $operator )
|
133 |
+
return members_current_user_can_any( $caps ) ? '' : do_shortcode( $content );
|
134 |
|
135 |
+
return members_current_user_can_any( $caps ) ? do_shortcode( $content ) : '';
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
// If the current user has the role, show the content.
|
141 |
// Get the roles.
|
142 |
$roles = explode( ',', $attr['role'] );
|
143 |
|
144 |
+
if ( '!' === $operator )
|
145 |
+
return members_current_user_has_role( $roles ) ? '' : do_shortcode( $content );
|
146 |
|
147 |
+
return members_current_user_has_role( $roles ) ? do_shortcode( $content ) : '';
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
// Return an empty string if we've made it to this point.
|
159 |
* @return string
|
160 |
*/
|
161 |
function members_login_form_shortcode() {
|
162 |
+
|
163 |
return wp_login_form( array( 'echo' => false ) );
|
164 |
}
|
inc/functions-users.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -68,15 +68,21 @@ function members_user_has_cap_filter( $allcaps, $caps, $args, $user ) {
|
|
68 |
*
|
69 |
* @since 1.0.0
|
70 |
* @access public
|
71 |
-
* @param int
|
72 |
-
* @param string $
|
73 |
* @return bool
|
74 |
*/
|
75 |
-
function members_user_has_role( $user_id, $
|
76 |
|
77 |
$user = new WP_User( $user_id );
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
/**
|
@@ -84,12 +90,52 @@ function members_user_has_role( $user_id, $role ) {
|
|
84 |
*
|
85 |
* @since 1.0.0
|
86 |
* @access public
|
87 |
-
* @param string $
|
88 |
* @return bool
|
89 |
*/
|
90 |
-
function members_current_user_has_role( $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
return
|
93 |
}
|
94 |
|
95 |
/**
|
@@ -107,7 +153,7 @@ function members_get_user_role_names( $user_id ) {
|
|
107 |
$names = array();
|
108 |
|
109 |
foreach ( $user->roles as $role )
|
110 |
-
$names[ $role ] =
|
111 |
|
112 |
return $names;
|
113 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
68 |
*
|
69 |
* @since 1.0.0
|
70 |
* @access public
|
71 |
+
* @param int $user_id
|
72 |
+
* @param string|array $roles
|
73 |
* @return bool
|
74 |
*/
|
75 |
+
function members_user_has_role( $user_id, $roles ) {
|
76 |
|
77 |
$user = new WP_User( $user_id );
|
78 |
|
79 |
+
foreach ( (array) $roles as $role ) {
|
80 |
+
|
81 |
+
if ( in_array( $role, (array) $user->roles ) )
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
|
85 |
+
return false;
|
86 |
}
|
87 |
|
88 |
/**
|
90 |
*
|
91 |
* @since 1.0.0
|
92 |
* @access public
|
93 |
+
* @param string|array $roles
|
94 |
* @return bool
|
95 |
*/
|
96 |
+
function members_current_user_has_role( $roles ) {
|
97 |
+
|
98 |
+
return is_user_logged_in() ? members_user_has_role( get_current_user_id(), $roles ) : false;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Wrapper for `current_user_can()` that checks if the user can perform any action.
|
103 |
+
* Accepts an array of caps instead of a single cap.
|
104 |
+
*
|
105 |
+
* @since 2.0.0
|
106 |
+
* @access public
|
107 |
+
* @param array $caps
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
function members_current_user_can_any( $caps = array() ) {
|
111 |
+
|
112 |
+
foreach ( $caps as $cap ) {
|
113 |
+
|
114 |
+
if ( current_user_can( $cap ) )
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Wrapper for `current_user_can()` that checks if the user can perform all actions.
|
123 |
+
* Accepts an array of caps instead of a single cap.
|
124 |
+
*
|
125 |
+
* @since 2.0.0
|
126 |
+
* @access public
|
127 |
+
* @param array $caps
|
128 |
+
* @return bool
|
129 |
+
*/
|
130 |
+
function members_current_user_can_all( $caps = array() ) {
|
131 |
+
|
132 |
+
foreach ( $caps as $cap ) {
|
133 |
+
|
134 |
+
if ( ! current_user_can( $cap ) )
|
135 |
+
return false;
|
136 |
+
}
|
137 |
|
138 |
+
return true;
|
139 |
}
|
140 |
|
141 |
/**
|
153 |
$names = array();
|
154 |
|
155 |
foreach ( $user->roles as $role )
|
156 |
+
$names[ $role ] = members_get_role( $role )->label;
|
157 |
|
158 |
return $names;
|
159 |
}
|
inc/functions-widgets.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -25,16 +25,16 @@ function members_register_widgets() {
|
|
25 |
// If the login form widget is enabled.
|
26 |
if ( members_login_widget_enabled() ) {
|
27 |
|
28 |
-
require_once( members_plugin()->
|
29 |
|
30 |
-
register_widget( '
|
31 |
}
|
32 |
|
33 |
// If the users widget is enabled.
|
34 |
if ( members_users_widget_enabled() ) {
|
35 |
|
36 |
-
require_once( members_plugin()->
|
37 |
|
38 |
-
register_widget( '
|
39 |
}
|
40 |
}
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
25 |
// If the login form widget is enabled.
|
26 |
if ( members_login_widget_enabled() ) {
|
27 |
|
28 |
+
require_once( members_plugin()->dir . 'inc/class-widget-login.php' );
|
29 |
|
30 |
+
register_widget( '\Members\Widget_Login' );
|
31 |
}
|
32 |
|
33 |
// If the users widget is enabled.
|
34 |
if ( members_users_widget_enabled() ) {
|
35 |
|
36 |
+
require_once( members_plugin()->dir . 'inc/class-widget-users.php' );
|
37 |
|
38 |
+
register_widget( '\Members\Widget_Users' );
|
39 |
}
|
40 |
}
|
inc/functions.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
@@ -20,5 +20,21 @@
|
|
20 |
* @return bool
|
21 |
*/
|
22 |
function members_validate_boolean( $val ) {
|
|
|
23 |
return filter_var( $val, FILTER_VALIDATE_BOOLEAN );
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
20 |
* @return bool
|
21 |
*/
|
22 |
function members_validate_boolean( $val ) {
|
23 |
+
|
24 |
return filter_var( $val, FILTER_VALIDATE_BOOLEAN );
|
25 |
}
|
26 |
+
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Helper function for sorting objects by priority.
|
30 |
+
*
|
31 |
+
* @since 2.0.0
|
32 |
+
* @access protected
|
33 |
+
* @param object $a
|
34 |
+
* @param object $b
|
35 |
+
* @return int
|
36 |
+
*/
|
37 |
+
function members_priority_sort( $a, $b ) {
|
38 |
+
|
39 |
+
return $a->priority - $b->priority;
|
40 |
+
}
|
inc/template.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
-
* @author Justin Tadlock <
|
8 |
-
* @copyright Copyright (c) 2009 -
|
9 |
-
* @link
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
4 |
*
|
5 |
* @package Members
|
6 |
* @subpackage Includes
|
7 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
8 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
9 |
+
* @link https://themehybrid.com/plugins/members
|
10 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
*/
|
12 |
|
js/edit-post.js
CHANGED
@@ -1,157 +1,38 @@
|
|
1 |
( function() {
|
2 |
|
3 |
-
|
4 |
-
if ( _.isUndefined( members_cp_data ) ) {
|
5 |
-
return;
|
6 |
-
}
|
7 |
|
8 |
-
|
|
|
9 |
|
10 |
-
//
|
11 |
-
|
12 |
-
defaults : {
|
13 |
-
name : '',
|
14 |
-
label : '',
|
15 |
-
description : '',
|
16 |
-
icon : '',
|
17 |
-
selected : false
|
18 |
-
}
|
19 |
-
} );
|
20 |
-
|
21 |
-
// Control model (each control belongs to a manager and section).
|
22 |
-
var Control = Backbone.Model.extend( {
|
23 |
-
defaults : {
|
24 |
-
name : '',
|
25 |
-
type : '',
|
26 |
-
label : '',
|
27 |
-
description : '',
|
28 |
-
value : '',
|
29 |
-
choices : {},
|
30 |
-
attr : '',
|
31 |
-
section : ''
|
32 |
-
}
|
33 |
-
} );
|
34 |
-
|
35 |
-
/* === Collections === */
|
36 |
-
|
37 |
-
// Collection of sections.
|
38 |
-
var Sections = Backbone.Collection.extend( {
|
39 |
-
model : Section
|
40 |
-
} );
|
41 |
-
|
42 |
-
/* === Views === */
|
43 |
|
44 |
-
//
|
45 |
-
|
46 |
-
tagName : 'div',
|
47 |
-
template : wp.template( 'members-cp-section' ),
|
48 |
-
attributes : function() {
|
49 |
-
return {
|
50 |
-
'id' : 'members-cp-section-' + this.model.get( 'name' ),
|
51 |
-
'class' : 'members-cp-section',
|
52 |
-
'aria-hidden' : ! this.model.get( 'selected' )
|
53 |
-
};
|
54 |
-
},
|
55 |
-
initialize : function( options ) {
|
56 |
-
this.model.on( 'change', this.onchange, this );
|
57 |
-
},
|
58 |
-
render : function() {
|
59 |
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
onchange : function() {
|
65 |
|
66 |
-
//
|
67 |
-
|
68 |
-
},
|
69 |
-
} );
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
template : wp.template( 'members-cp-nav' ),
|
74 |
-
tagName : 'li',
|
75 |
-
attributes : function() {
|
76 |
-
return {
|
77 |
-
'aria-selected' : this.model.get( 'selected' )
|
78 |
-
};
|
79 |
-
},
|
80 |
-
initialize : function() {
|
81 |
-
this.model.on( 'change', this.render, this );
|
82 |
-
this.model.on( 'change', this.onchange, this );
|
83 |
-
},
|
84 |
-
render : function() {
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
return this;
|
89 |
-
},
|
90 |
-
events : {
|
91 |
-
'click a' : 'onselect'
|
92 |
-
},
|
93 |
-
onchange : function() {
|
94 |
-
|
95 |
-
// Set the `aria-selected` attibute based on the model selected state.
|
96 |
-
this.el.setAttribute( 'aria-selected', this.model.get( 'selected' ) );
|
97 |
-
},
|
98 |
-
onselect : function( event ) {
|
99 |
-
event.preventDefault();
|
100 |
-
|
101 |
-
// Loop through each of the models in the collection and set them to inactive.
|
102 |
-
_.each( this.model.collection.models, function( m ) {
|
103 |
-
|
104 |
-
m.set( 'selected', false );
|
105 |
-
}, this );
|
106 |
-
|
107 |
-
// Set this view's model to selected.
|
108 |
-
this.model.set( 'selected', true );
|
109 |
-
}
|
110 |
-
} );
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
tagName : 'div',
|
115 |
-
template : wp.template( 'members-cp-control' ),
|
116 |
-
attributes : function() {
|
117 |
-
return {
|
118 |
-
'id' : 'members-cp-control-' + this.model.get( 'name' ),
|
119 |
-
'class' : 'members-cp-control'
|
120 |
-
};
|
121 |
-
},
|
122 |
-
render : function() {
|
123 |
|
124 |
-
|
125 |
-
|
126 |
}
|
127 |
-
|
128 |
-
|
129 |
-
var sections = new Sections();
|
130 |
-
|
131 |
-
_.each( members_cp_data.sections ), function( data ) {
|
132 |
-
|
133 |
-
sections.add( new Section( data ) );
|
134 |
-
}
|
135 |
-
|
136 |
-
sections.forEach( function( section, i ) ) {
|
137 |
-
|
138 |
-
var nav_view = new Nav_View( { model : section } );
|
139 |
-
var section_view = new Section_View( { model : section } );
|
140 |
-
|
141 |
-
document.querySelector( '#members-cp .members-cp-nav' ).appendChild( nav_view.render().el );
|
142 |
-
document.querySelector( '#members-cp .members-cp-content' ).appendChild( section_view.render().el );
|
143 |
-
|
144 |
-
// If the first model, set it to selected.
|
145 |
-
section.set( 'selected', 0 == i );
|
146 |
-
}, this );
|
147 |
-
|
148 |
-
_.each( members_cp_data.controls ), function( data ) {
|
149 |
-
|
150 |
-
var control = new Control( data );
|
151 |
-
|
152 |
-
var view = new Control_View( { model : control } );
|
153 |
-
|
154 |
-
document.getElementById( '#members-cp-section-' + control.get( 'section' ) ).appendChild( view.render().el );
|
155 |
-
} );
|
156 |
|
157 |
}() );
|
1 |
( function() {
|
2 |
|
3 |
+
/* ====== Tabs ====== */
|
|
|
|
|
|
|
4 |
|
5 |
+
// Hides the tab content.
|
6 |
+
jQuery( '.members-tabs .members-tab-content' ).hide();
|
7 |
|
8 |
+
// Shows the first tab's content.
|
9 |
+
jQuery( '.members-tabs .members-tab-content:first-child' ).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
// Makes the 'aria-selected' attribute true for the first tab nav item.
|
12 |
+
jQuery( '.members-tab-nav :first-child' ).attr( 'aria-selected', 'true' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
// When a tab nav item is clicked.
|
15 |
+
jQuery( '.members-tab-nav li a' ).click(
|
16 |
+
function( j ) {
|
17 |
|
18 |
+
// Prevent the default browser action when a link is clicked.
|
19 |
+
j.preventDefault();
|
|
|
20 |
|
21 |
+
// Get the `href` attribute of the item.
|
22 |
+
var href = jQuery( this ).attr( 'href' );
|
|
|
|
|
23 |
|
24 |
+
// Hide all tab content.
|
25 |
+
jQuery( this ).parents( '.members-tabs' ).find( '.members-tab-content' ).hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
// Find the tab content that matches the tab nav item and show it.
|
28 |
+
jQuery( this ).parents( '.members-tabs' ).find( href ).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
// Set the `aria-selected` attribute to false for all tab nav items.
|
31 |
+
jQuery( this ).parents( '.members-tabs' ).find( '.members-tab-title' ).attr( 'aria-selected', 'false' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
// Set the `aria-selected` attribute to true for this tab nav item.
|
34 |
+
jQuery( this ).parent().attr( 'aria-selected', 'true' );
|
35 |
}
|
36 |
+
); // click()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
}() );
|
js/edit-post.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(){jQuery(".members-tabs .members-tab-content").hide(),jQuery(".members-tabs .members-tab-content:first-child").show(),jQuery(".members-tab-nav :first-child").attr("aria-selected","true"),jQuery(".members-tab-nav li a").click(function(e){e.preventDefault();var t=jQuery(this).attr("href");jQuery(this).parents(".members-tabs").find(".members-tab-content").hide(),jQuery(this).parents(".members-tabs").find(t).show(),jQuery(this).parents(".members-tabs").find(".members-tab-title").attr("aria-selected","false"),jQuery(this).parent().attr("aria-selected","true")})}();
|
js/edit-role.js
CHANGED
@@ -325,7 +325,7 @@ jQuery( document ).ready( function() {
|
|
325 |
function() {
|
326 |
|
327 |
// If there's a value in the input, enable the add new button.
|
328 |
-
if ( jQuery( this ).val() ) {
|
329 |
|
330 |
jQuery( '#members-add-new-cap' ).prop( 'disabled', false );
|
331 |
|
@@ -363,6 +363,11 @@ jQuery( document ).ready( function() {
|
|
363 |
// If there's a new cap value.
|
364 |
if ( new_cap ) {
|
365 |
|
|
|
|
|
|
|
|
|
|
|
366 |
// Trigger a click event on the "custom" tab in the edit caps box.
|
367 |
jQuery( 'a[href="#members-tab-custom"]' ).trigger( 'click' );
|
368 |
|
@@ -377,7 +382,7 @@ jQuery( document ).ready( function() {
|
|
377 |
name : { grant : 'grant-new-caps[]', deny : 'deny-new-caps[]' },
|
378 |
is_granted_cap : true,
|
379 |
is_denied_cap : false,
|
380 |
-
label : { grant : members_i18n.label_grant_cap, deny : members_i18n.label_deny_cap }
|
381 |
};
|
382 |
|
383 |
// Prepend our template to the "custom" edit caps tab content.
|
325 |
function() {
|
326 |
|
327 |
// If there's a value in the input, enable the add new button.
|
328 |
+
if ( 'do_not_allow' !== jQuery( this ).val() ) {
|
329 |
|
330 |
jQuery( '#members-add-new-cap' ).prop( 'disabled', false );
|
331 |
|
363 |
// If there's a new cap value.
|
364 |
if ( new_cap ) {
|
365 |
|
366 |
+
// Don't allow the 'do_not_allow' cap.
|
367 |
+
if ( 'do_not_allow' === new_cap ) {
|
368 |
+
return;
|
369 |
+
}
|
370 |
+
|
371 |
// Trigger a click event on the "custom" tab in the edit caps box.
|
372 |
jQuery( 'a[href="#members-tab-custom"]' ).trigger( 'click' );
|
373 |
|
382 |
name : { grant : 'grant-new-caps[]', deny : 'deny-new-caps[]' },
|
383 |
is_granted_cap : true,
|
384 |
is_denied_cap : false,
|
385 |
+
label : { cap : new_cap, grant : members_i18n.label_grant_cap, deny : members_i18n.label_deny_cap }
|
386 |
};
|
387 |
|
388 |
// Prepend our template to the "custom" edit caps tab content.
|
js/edit-role.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(){function e(e){e=e.toLowerCase().trim().replace(/<.*?>/g,"").replace(/\s/g,"_").replace(/[^a-zA-Z0-9_]/g,""),jQuery(".role-slug").text(e)}function r(){var e=jQuery("#members-tab-all input[data-grant-cap]:checked").length,r=jQuery("#members-tab-all input[data-deny-cap]:checked").length,t=jQuery('#members-tab-custom input[name="grant-new-caps[]"]:checked').length,a=jQuery('#members-tab-custom input[name="deny-new-caps[]"]:checked').length;jQuery("#submitdiv .granted-count").text(e+t),jQuery("#submitdiv .denied-count").text(r+a)}function t(e){var r="grant",t="deny";jQuery(e).attr("data-deny-cap")&&(r="deny",t="grant");var a=jQuery(e).attr("data-"+r+"-cap");jQuery(e).prop("checked")?(jQuery("input[data-"+r+'-cap="'+a+'"]').not(e).prop("checked",!0),jQuery("input[data-"+t+'-cap="'+a+'"]').prop("checked",!1)):jQuery("input[data-"+r+'-cap="'+a+'"]').not(e).prop("checked",!1)}jQuery(".members-delete-role-link").click(function(){return window.confirm(members_i18n.ays_delete_role)}),jQuery('input[name="role_name"]').keyup(function(){jQuery('input[name="role"]').val()||e(this.value)}),jQuery('input[name="role"], .role-ok-button').hide(),jQuery(document).on("click",".role-edit-button.closed",function(){jQuery(this).removeClass("closed").addClass("open").text(members_i18n.button_role_ok),jQuery('input[name="role"]').show(),jQuery('input[name="role"]').trigger("focus"),jQuery('input[name="role"]').attr("value",jQuery(".role-slug").text())}),jQuery(document).on("click",".role-edit-button.open",function(){jQuery(this).removeClass("open").addClass("closed").text(members_i18n.button_role_edit),jQuery('input[name="role"]').hide();var r=jQuery('input[name="role"]').val();
|
1 |
+
jQuery(document).ready(function(){function e(e){e=e.toLowerCase().trim().replace(/<.*?>/g,"").replace(/\s/g,"_").replace(/[^a-zA-Z0-9_]/g,""),jQuery(".role-slug").text(e)}function r(){var e=jQuery("#members-tab-all input[data-grant-cap]:checked").length,r=jQuery("#members-tab-all input[data-deny-cap]:checked").length,t=jQuery('#members-tab-custom input[name="grant-new-caps[]"]:checked').length,a=jQuery('#members-tab-custom input[name="deny-new-caps[]"]:checked').length;jQuery("#submitdiv .granted-count").text(e+t),jQuery("#submitdiv .denied-count").text(r+a)}function t(e){var r="grant",t="deny";jQuery(e).attr("data-deny-cap")&&(r="deny",t="grant");var a=jQuery(e).attr("data-"+r+"-cap");jQuery(e).prop("checked")?(jQuery("input[data-"+r+'-cap="'+a+'"]').not(e).prop("checked",!0),jQuery("input[data-"+t+'-cap="'+a+'"]').prop("checked",!1)):jQuery("input[data-"+r+'-cap="'+a+'"]').not(e).prop("checked",!1)}jQuery(".members-delete-role-link").click(function(){return window.confirm(members_i18n.ays_delete_role)}),jQuery('input[name="role_name"]').keyup(function(){jQuery('input[name="role"]').val()||e(this.value)}),jQuery('input[name="role"], .role-ok-button').hide(),jQuery(document).on("click",".role-edit-button.closed",function(){jQuery(this).removeClass("closed").addClass("open").text(members_i18n.button_role_ok),jQuery('input[name="role"]').show(),jQuery('input[name="role"]').trigger("focus"),jQuery('input[name="role"]').attr("value",jQuery(".role-slug").text())}),jQuery(document).on("click",".role-edit-button.open",function(){jQuery(this).removeClass("open").addClass("closed").text(members_i18n.button_role_edit),jQuery('input[name="role"]').hide();var r=jQuery('input[name="role"]').val();e(r?r:jQuery('input[name="role_name"]').val())}),jQuery('input[name="role"]').keypress(function(e){if(13===e.keyCode)return jQuery(".role-edit-button").click().trigger("focus"),e.preventDefault(),!1}),jQuery('.users_page_role-new input[name="role_name"]').val()||jQuery(".users_page_role-new #publish").prop("disabled",!0),jQuery('.users_page_role-new input[name="role_name"]').on("input",function(){jQuery(this).val()?jQuery(".users_page_role-new #publish").prop("disabled",!1):jQuery(".users_page_role-new #publish").prop("disabled",!0)});var a=wp.template("members-cap-section"),n=wp.template("members-cap-control");"undefined"!=typeof members_sections&&"undefined"!=typeof members_controls&&(_.each(members_sections,function(e){jQuery(".members-tab-wrap").append(a(e))}),_.each(members_controls,function(e){jQuery("#members-tab-"+e.section+" tbody").append(n(e))})),jQuery(".members-cap-tabs .members-tab-content").hide(),jQuery(".members-cap-tabs .members-tab-content:first-child").show(),jQuery(".members-tab-nav :first-child").attr("aria-selected","true"),jQuery(".members-which-tab").text(jQuery(".members-tab-nav :first-child a").text()),jQuery(".members-tab-nav li a").click(function(e){e.preventDefault();var r=jQuery(this).attr("href");jQuery(this).parents(".members-cap-tabs").find(".members-tab-content").hide(),jQuery(this).parents(".members-cap-tabs").find(r).show(),jQuery(this).parents(".members-cap-tabs").find(".members-tab-title").attr("aria-selected","false"),jQuery(this).parent().attr("aria-selected","true"),jQuery(".members-which-tab").text(jQuery(this).text())}),r(),jQuery(document).on("change",".members-cap-checklist input[data-grant-cap], .members-cap-checklist input[data-deny-cap]",function(){t(this),r()}),jQuery(document).on("click",".editable-role .members-cap-checklist button",function(){var e=jQuery(this).closest(".members-cap-checklist"),r=jQuery(e).find("input[data-grant-cap]"),t=jQuery(e).find("input[data-deny-cap]");jQuery(r).prop("checked")?(jQuery(r).prop("checked",!1),jQuery(t).prop("checked",!0).change()):jQuery(t).prop("checked")?(jQuery(r).prop("checked",!1),jQuery(t).prop("checked",!1).change()):jQuery(r).prop("checked",!0).change()}),jQuery(document).on("hover",".editable-role .members-cap-checklist button",function(){jQuery(".members-cap-checklist button:focus").not(this).blur()}),postboxes.add_postbox_toggles(pagenow),jQuery("#newcapdiv button.handlediv").attr("type","button"),jQuery("#members-add-new-cap").prop("disabled",!0),jQuery("#members-new-cap-field").on("input",function(){"do_not_allow"!==jQuery(this).val()?jQuery("#members-add-new-cap").prop("disabled",!1):jQuery("#members-add-new-cap").prop("disabled",!0)}),jQuery("#members-new-cap-field").keypress(function(e){if(13===e.keyCode)return jQuery("#members-add-new-cap").click(),e.preventDefault(),!1}),jQuery("#members-add-new-cap").click(function(){var e=jQuery("#members-new-cap-field").val();if(e=e.trim().replace(/<.*?>/g,"").replace(/\s/g,"_").replace(/[^a-zA-Z0-9_]/g,"")){if("do_not_allow"===e)return;jQuery('a[href="#members-tab-custom"]').trigger("click"),members_i18n.label_grant_cap=members_i18n.label_grant_cap.replace(/%s/g,"<code>"+e+"</code>"),members_i18n.label_deny_cap=members_i18n.label_deny_cap.replace(/%s/g,"<code>"+e+"</code>");var r={cap:e,readonly:"",name:{grant:"grant-new-caps[]",deny:"deny-new-caps[]"},is_granted_cap:!0,is_denied_cap:!1,label:{cap:e,grant:members_i18n.label_grant_cap,deny:members_i18n.label_deny_cap}};jQuery("#members-tab-custom tbody").prepend(n(r));var t=jQuery('[data-grant-cap="'+e+'"]').parents(".members-cap-checklist");jQuery(t).addClass("members-highlight"),setTimeout(function(){jQuery(t).removeClass("members-highlight")},500),jQuery("#members-new-cap-field").val(""),jQuery("#members-add-new-cap").prop("disabled",!0),jQuery('.members-cap-checklist input[data-grant-cap="'+e+'"]').trigger("change")}})});
|
lang/members.pot
ADDED
@@ -0,0 +1,1267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017 Members
|
2 |
+
# This file is distributed under the same license as the Members package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Members 2.0.0-dev\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/members\n"
|
7 |
+
"POT-Creation-Date: 2017-07-18 22:34:50+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
|
15 |
+
#: _assets/class-cap-edit.php:92 admin/class-manage-users.php:161
|
16 |
+
#: admin/class-manage-users.php:236 admin/class-role-edit.php:92
|
17 |
+
#: members.php:129 members.php:140
|
18 |
+
msgid "Whoah, partner!"
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#: _assets/class-cap-edit.php:99
|
22 |
+
msgid "The requested cap to edit does not exist."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: _assets/class-cap-edit.php:235
|
26 |
+
msgid "%s cap updated."
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: _assets/class-cap-edit.php:239
|
30 |
+
msgid "The %s cap is not editable. This means that it is most likely added via another plugin for a special use or that you do not have permission to edit it."
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: _assets/class-cap-edit.php:247
|
34 |
+
msgid "The %s cap has been created."
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: _assets/class-cap-edit.php:309
|
38 |
+
msgid "Edit Cap"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: _assets/class-cap-edit.php:312 _assets/class-caps.php:175
|
42 |
+
msgctxt "cap"
|
43 |
+
msgid "Add New"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: _assets/class-cap-edit.php:331
|
47 |
+
msgid "Capability Label"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: _assets/class-cap-edit.php:337
|
51 |
+
msgid "Capability:"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: _assets/class-cap-edit.php:344 _assets/class-cap-new.php:185
|
55 |
+
#: _assets/class-caps.php:70 admin/class-manage-roles.php:86
|
56 |
+
#: admin/class-manage-roles.php:92 admin/class-manage-users.php:360
|
57 |
+
#: admin/class-meta-box-content-permissions.php:174 admin/class-roles.php:170
|
58 |
+
#: admin/class-user-edit.php:92
|
59 |
+
msgid "Roles"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: _assets/class-cap-edit.php:351 _assets/class-cap-edit.php:358
|
63 |
+
#: admin/class-meta-box-publish-role.php:67 admin/class-roles.php:68
|
64 |
+
#: inc/functions-admin-bar.php:35
|
65 |
+
msgid "Role"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: _assets/class-cap-edit.php:352 _assets/class-cap-edit.php:359
|
69 |
+
#: admin/tmpl/cap-section.php:20 admin/tmpl/cap-section.php:28
|
70 |
+
msgid "Grant"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: _assets/class-cap-edit.php:353 _assets/class-cap-edit.php:360
|
74 |
+
#: admin/tmpl/cap-section.php:21 admin/tmpl/cap-section.php:29
|
75 |
+
msgid "Deny"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: _assets/class-cap-list-table.php:377 admin/class-role-list-table.php:337
|
79 |
+
#: admin/class-role-new.php:335 admin/functions-admin.php:46
|
80 |
+
msgid "Edit"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: _assets/class-cap-list-table.php:381 _assets/class-cap-list-table.php:520
|
84 |
+
#: _assets/class-capability-list-table.php:264
|
85 |
+
#: _assets/class-capability-list-table.php:387
|
86 |
+
#: admin/class-role-list-table.php:341 admin/class-role-list-table.php:490
|
87 |
+
msgid "Delete"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: _assets/class-cap-list-table.php:387 admin/class-role-list-table.php:347
|
91 |
+
msgid "View"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: _assets/class-cap-list-table.php:452
|
95 |
+
#: _assets/class-capability-list-table.php:319
|
96 |
+
#: admin/class-role-list-table.php:400
|
97 |
+
msgid "All %s"
|
98 |
+
msgid_plural "All %s"
|
99 |
+
msgstr[0] ""
|
100 |
+
msgstr[1] ""
|
101 |
+
|
102 |
+
#: _assets/class-cap-list-table.php:464
|
103 |
+
#: _assets/class-capability-list-table.php:320
|
104 |
+
#: admin/class-role-list-table.php:405
|
105 |
+
msgid "Mine %s"
|
106 |
+
msgid_plural "Mine %s"
|
107 |
+
msgstr[0] ""
|
108 |
+
msgstr[1] ""
|
109 |
+
|
110 |
+
#: _assets/class-cap-list-table.php:538
|
111 |
+
msgid "All Groups"
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: _assets/class-cap-list-table.php:547
|
115 |
+
#: _assets/class-capability-list-table.php:359
|
116 |
+
msgid "Filter"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: _assets/class-cap-new.php:64 _assets/class-cap-new.php:158
|
120 |
+
msgid "Add New Capability"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: _assets/class-cap-new.php:102
|
124 |
+
msgid "Please input a valid capability."
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: _assets/class-cap-new.php:106
|
128 |
+
msgid "The %s capability already exists."
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: _assets/class-cap-new.php:110
|
132 |
+
msgid "Please select at least one role."
|
133 |
+
msgstr ""
|
134 |
+
|
135 |
+
#: _assets/class-cap-new.php:123
|
136 |
+
msgid "The %s capability has been created."
|
137 |
+
msgstr ""
|
138 |
+
|
139 |
+
#: _assets/class-cap-new.php:172 _assets/class-caps.php:68
|
140 |
+
#: admin/tmpl/cap-section.php:19 admin/tmpl/cap-section.php:27
|
141 |
+
msgid "Capability"
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#: _assets/class-cap-new.php:178
|
145 |
+
msgid "The capability should be unique and contain only alphanumeric characters and underscores."
|
146 |
+
msgstr ""
|
147 |
+
|
148 |
+
#: _assets/class-cap-new.php:189
|
149 |
+
msgid "Select at least one role. Because of the way capabilities work in WordPress, they can only exist if assigned to a role."
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: _assets/class-cap-new.php:209
|
153 |
+
msgid "Add Capability"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: _assets/class-capability-list-table.php:321 inc/functions-role-groups.php:43
|
157 |
+
msgid "WordPress %s"
|
158 |
+
msgid_plural "WordPress %s"
|
159 |
+
msgstr[0] ""
|
160 |
+
msgstr[1] ""
|
161 |
+
|
162 |
+
#: _assets/class-capability-list-table.php:322
|
163 |
+
msgid "Members %s"
|
164 |
+
msgid_plural "Members %s"
|
165 |
+
msgstr[0] ""
|
166 |
+
msgstr[1] ""
|
167 |
+
|
168 |
+
#: _assets/class-capability-list-table.php:349
|
169 |
+
msgid "View all roles"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: _assets/class-caps.php:67
|
173 |
+
msgid "Label"
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: _assets/class-caps.php:69
|
177 |
+
msgid "Groups"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: _assets/class-caps.php:114
|
181 |
+
msgid "Selected caps deleted."
|
182 |
+
msgstr ""
|
183 |
+
|
184 |
+
#: _assets/class-caps.php:133
|
185 |
+
msgid "%s cap deleted."
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: _assets/class-caps.php:172 _assets/class-manage-caps.php:86
|
189 |
+
#: _assets/class-manage-caps.php:92 _assets/page-capabilities.php:45
|
190 |
+
#: _assets/page-capabilities.php:93 admin/views/class-view-general.php:72
|
191 |
+
msgid "Capabilities"
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: _assets/class-caps.php:212 admin/class-roles.php:210
|
195 |
+
#: admin/functions-help.php:46 admin/views/class-view-addons.php:176
|
196 |
+
msgid "Overview"
|
197 |
+
msgstr ""
|
198 |
+
|
199 |
+
#: _assets/class-caps.php:221 admin/class-roles.php:219
|
200 |
+
msgid "Screen Content"
|
201 |
+
msgstr ""
|
202 |
+
|
203 |
+
#: _assets/class-caps.php:230 admin/class-roles.php:228
|
204 |
+
msgid "Available Actions"
|
205 |
+
msgstr ""
|
206 |
+
|
207 |
+
#: _assets/class-caps.php:239 admin/class-roles.php:237
|
208 |
+
msgid "Bulk Actions"
|
209 |
+
msgstr ""
|
210 |
+
|
211 |
+
#: _assets/class-caps.php:258
|
212 |
+
msgid "This screen provides access to all of your user caps. Caps are a method of grouping users. They are made up of capabilities (caps), which give permission to users to perform specific actions on the site."
|
213 |
+
msgstr ""
|
214 |
+
|
215 |
+
#: _assets/class-caps.php:272 admin/class-roles.php:270
|
216 |
+
msgid "You can customize the display of this screen‘s contents in a number of ways:"
|
217 |
+
msgstr ""
|
218 |
+
|
219 |
+
#: _assets/class-caps.php:276
|
220 |
+
msgid "You can hide/display columns based on your needs and decide how many caps to list per screen using the Screen Options tab."
|
221 |
+
msgstr ""
|
222 |
+
|
223 |
+
#: _assets/class-caps.php:277
|
224 |
+
msgid "You can filter the list of caps by types using the text links in the upper left. The default view is to show all caps."
|
225 |
+
msgstr ""
|
226 |
+
|
227 |
+
#: _assets/class-caps.php:291
|
228 |
+
msgid "Hovering over a row in the caps list will display action links that allow you to manage your cap. You can perform the following actions:"
|
229 |
+
msgstr ""
|
230 |
+
|
231 |
+
#: _assets/class-caps.php:295
|
232 |
+
msgid "<strong>Edit</strong> takes you to the editing screen for that cap. You can also reach that screen by clicking on the cap name."
|
233 |
+
msgstr ""
|
234 |
+
|
235 |
+
#: _assets/class-caps.php:296
|
236 |
+
msgid "<strong>Delete</strong> removes your cap from this list and permanently deletes it."
|
237 |
+
msgstr ""
|
238 |
+
|
239 |
+
#: _assets/class-caps.php:297
|
240 |
+
msgid "<strong>Clone</strong> copies the cap and takes you to the new cap screen to further edit it."
|
241 |
+
msgstr ""
|
242 |
+
|
243 |
+
#: _assets/class-caps.php:298
|
244 |
+
msgid "<strong>Users</strong> takes you to the users screen and lists the users that have that cap."
|
245 |
+
msgstr ""
|
246 |
+
|
247 |
+
#: _assets/class-caps.php:312
|
248 |
+
msgid "You can permanently delete multiple caps at once. Select the caps you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply."
|
249 |
+
msgstr ""
|
250 |
+
|
251 |
+
#: _assets/class-manage-caps.php:89
|
252 |
+
msgid "Edit Capability"
|
253 |
+
msgstr ""
|
254 |
+
|
255 |
+
#: _assets/page-capabilities.php:69
|
256 |
+
msgid "%s capability deleted. Not really. This is just a message to output until the functionality is working."
|
257 |
+
msgstr ""
|
258 |
+
|
259 |
+
#: _assets/page-capabilities.php:73
|
260 |
+
msgid "No capability selected to delete."
|
261 |
+
msgstr ""
|
262 |
+
|
263 |
+
#: _assets/page-capabilities.php:96
|
264 |
+
msgid "Add New"
|
265 |
+
msgstr ""
|
266 |
+
|
267 |
+
#: _assets/page-capabilities.php:116
|
268 |
+
msgid "Are you sure you want to delete this capability? This is a permanent action and cannot be undone."
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#: admin/class-cap-control.php:118 admin/functions-admin.php:48
|
272 |
+
msgid "Grant %s capability"
|
273 |
+
msgstr ""
|
274 |
+
|
275 |
+
#: admin/class-cap-control.php:119 admin/functions-admin.php:49
|
276 |
+
msgid "Deny %s capability"
|
277 |
+
msgstr ""
|
278 |
+
|
279 |
+
#: admin/class-cap-tabs.php:165
|
280 |
+
msgid "All"
|
281 |
+
msgstr ""
|
282 |
+
|
283 |
+
#: admin/class-cap-tabs.php:194
|
284 |
+
msgid "Edit Capabilities: %s"
|
285 |
+
msgstr ""
|
286 |
+
|
287 |
+
#: admin/class-manage-roles.php:89 admin/class-role-edit.php:298
|
288 |
+
msgid "Edit Role"
|
289 |
+
msgstr ""
|
290 |
+
|
291 |
+
#: admin/class-manage-users.php:97
|
292 |
+
msgid "Role added to selected users."
|
293 |
+
msgstr ""
|
294 |
+
|
295 |
+
#: admin/class-manage-users.php:102
|
296 |
+
msgid "Role removed from selected users."
|
297 |
+
msgstr ""
|
298 |
+
|
299 |
+
#: admin/class-manage-users.php:106
|
300 |
+
msgid "The current user’s role must have user editing capabilities."
|
301 |
+
msgstr ""
|
302 |
+
|
303 |
+
#: admin/class-manage-users.php:107
|
304 |
+
msgid "Role removed from other selected users."
|
305 |
+
msgstr ""
|
306 |
+
|
307 |
+
#: admin/class-manage-users.php:162 admin/class-manage-users.php:237
|
308 |
+
msgid "One of the selected users is not a member of this site."
|
309 |
+
msgstr ""
|
310 |
+
|
311 |
+
#: admin/class-manage-users.php:326 admin/class-manage-users.php:330
|
312 |
+
msgid "Add role…"
|
313 |
+
msgstr ""
|
314 |
+
|
315 |
+
#: admin/class-manage-users.php:334
|
316 |
+
msgid "Add"
|
317 |
+
msgstr ""
|
318 |
+
|
319 |
+
#: admin/class-manage-users.php:337 admin/class-manage-users.php:341
|
320 |
+
msgid "Remove role…"
|
321 |
+
msgstr ""
|
322 |
+
|
323 |
+
#: admin/class-manage-users.php:345
|
324 |
+
msgid "Remove"
|
325 |
+
msgstr ""
|
326 |
+
|
327 |
+
#: admin/class-manage-users.php:382
|
328 |
+
msgid "None"
|
329 |
+
msgstr ""
|
330 |
+
|
331 |
+
#: admin/class-meta-box-content-permissions.php:115
|
332 |
+
#: admin/views/class-view-general.php:63 admin/views/class-view-general.php:362
|
333 |
+
msgid "Content Permissions"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: admin/class-meta-box-content-permissions.php:180
|
337 |
+
#: admin/views/class-view-general.php:76
|
338 |
+
msgid "Error Message"
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: admin/class-meta-box-content-permissions.php:190
|
342 |
+
msgid "Limit access to the content to users of the selected roles."
|
343 |
+
msgstr ""
|
344 |
+
|
345 |
+
#: admin/class-meta-box-content-permissions.php:210
|
346 |
+
msgid "If no roles are selected, everyone can view the content. The author, any users who can edit the content, and users with the %s capability can view the content regardless of role."
|
347 |
+
msgstr ""
|
348 |
+
|
349 |
+
#: admin/class-meta-box-custom-cap.php:73 admin/functions-help.php:94
|
350 |
+
msgid "Custom Capability"
|
351 |
+
msgstr ""
|
352 |
+
|
353 |
+
#: admin/class-meta-box-custom-cap.php:90
|
354 |
+
msgctxt "capability"
|
355 |
+
msgid "Add New"
|
356 |
+
msgstr ""
|
357 |
+
|
358 |
+
#: admin/class-meta-box-publish-role.php:100
|
359 |
+
msgid "Users:"
|
360 |
+
msgstr ""
|
361 |
+
|
362 |
+
#: admin/class-meta-box-publish-role.php:106
|
363 |
+
msgid "Granted:"
|
364 |
+
msgstr ""
|
365 |
+
|
366 |
+
#: admin/class-meta-box-publish-role.php:112
|
367 |
+
msgid "Denied:"
|
368 |
+
msgstr ""
|
369 |
+
|
370 |
+
#: admin/class-meta-box-publish-role.php:123
|
371 |
+
msgctxt "delete role"
|
372 |
+
msgid "Delete"
|
373 |
+
msgstr ""
|
374 |
+
|
375 |
+
#: admin/class-meta-box-publish-role.php:130
|
376 |
+
msgid "Update"
|
377 |
+
msgstr ""
|
378 |
+
|
379 |
+
#: admin/class-meta-box-publish-role.php:130
|
380 |
+
msgid "Add Role"
|
381 |
+
msgstr ""
|
382 |
+
|
383 |
+
#: admin/class-role-edit.php:99
|
384 |
+
msgid "The requested role to edit does not exist."
|
385 |
+
msgstr ""
|
386 |
+
|
387 |
+
#: admin/class-role-edit.php:226
|
388 |
+
msgid "%s role updated."
|
389 |
+
msgstr ""
|
390 |
+
|
391 |
+
#: admin/class-role-edit.php:230
|
392 |
+
msgid "The %s role is not editable. This means that it is most likely added via another plugin for a special use or that you do not have permission to edit it."
|
393 |
+
msgstr ""
|
394 |
+
|
395 |
+
#: admin/class-role-edit.php:234
|
396 |
+
msgid "The %s role is typically the most important role on the site. Please take extreme caution that you do not inadvertently remove necessary capabilities."
|
397 |
+
msgstr ""
|
398 |
+
|
399 |
+
#: admin/class-role-edit.php:238 admin/class-role-new.php:226
|
400 |
+
msgid "The %s role has been created."
|
401 |
+
msgstr ""
|
402 |
+
|
403 |
+
#: admin/class-role-edit.php:301 admin/class-roles.php:173
|
404 |
+
msgctxt "role"
|
405 |
+
msgid "Add New"
|
406 |
+
msgstr ""
|
407 |
+
|
408 |
+
#: admin/class-role-edit.php:320 admin/class-role-new.php:327
|
409 |
+
#: admin/class-roles.php:67 admin/functions-help.php:62
|
410 |
+
msgid "Role Name"
|
411 |
+
msgstr ""
|
412 |
+
|
413 |
+
#: admin/class-role-edit.php:326 admin/class-role-new.php:333
|
414 |
+
#: inc/class-widget-users.php:228
|
415 |
+
msgid "Role:"
|
416 |
+
msgstr ""
|
417 |
+
|
418 |
+
#: admin/class-role-list-table.php:232
|
419 |
+
msgid "Default Role"
|
420 |
+
msgstr ""
|
421 |
+
|
422 |
+
#: admin/class-role-list-table.php:236
|
423 |
+
msgid "Your Role"
|
424 |
+
msgstr ""
|
425 |
+
|
426 |
+
#: admin/class-role-list-table.php:352
|
427 |
+
msgid "Clone"
|
428 |
+
msgstr ""
|
429 |
+
|
430 |
+
#: admin/class-role-list-table.php:356
|
431 |
+
msgid "Change Default"
|
432 |
+
msgstr ""
|
433 |
+
|
434 |
+
#: admin/class-role-list-table.php:360 admin/class-roles.php:69
|
435 |
+
#: inc/class-widget-users.php:59 inc/functions-cap-groups.php:121
|
436 |
+
msgid "Users"
|
437 |
+
msgstr ""
|
438 |
+
|
439 |
+
#: admin/class-role-list-table.php:410
|
440 |
+
msgid "Has Users %s"
|
441 |
+
msgid_plural "Has Users %s"
|
442 |
+
msgstr[0] ""
|
443 |
+
msgstr[1] ""
|
444 |
+
|
445 |
+
#: admin/class-role-list-table.php:415
|
446 |
+
msgid "No Users %s"
|
447 |
+
msgid_plural "No Users %s"
|
448 |
+
msgstr[0] ""
|
449 |
+
msgstr[1] ""
|
450 |
+
|
451 |
+
#: admin/class-role-list-table.php:420
|
452 |
+
msgid "Editable %s"
|
453 |
+
msgid_plural "Editable %s"
|
454 |
+
msgstr[0] ""
|
455 |
+
msgstr[1] ""
|
456 |
+
|
457 |
+
#: admin/class-role-list-table.php:425
|
458 |
+
msgid "Uneditable %s"
|
459 |
+
msgid_plural "Uneditable %s"
|
460 |
+
msgstr[0] ""
|
461 |
+
msgstr[1] ""
|
462 |
+
|
463 |
+
#: admin/class-role-new.php:109 admin/class-role-new.php:310
|
464 |
+
msgid "Add New Role"
|
465 |
+
msgstr ""
|
466 |
+
|
467 |
+
#: admin/class-role-new.php:235
|
468 |
+
msgid "You must enter a valid role."
|
469 |
+
msgstr ""
|
470 |
+
|
471 |
+
#: admin/class-role-new.php:239
|
472 |
+
msgid "The %s role already exists."
|
473 |
+
msgstr ""
|
474 |
+
|
475 |
+
#: admin/class-role-new.php:243
|
476 |
+
msgid "You must enter a valid role name."
|
477 |
+
msgstr ""
|
478 |
+
|
479 |
+
#: admin/class-role-new.php:310
|
480 |
+
msgid "Clone Role"
|
481 |
+
msgstr ""
|
482 |
+
|
483 |
+
#: admin/class-role-new.php:328
|
484 |
+
msgid "%s Clone"
|
485 |
+
msgstr ""
|
486 |
+
|
487 |
+
#: admin/class-role-new.php:328
|
488 |
+
msgid "Enter role name"
|
489 |
+
msgstr ""
|
490 |
+
|
491 |
+
#: admin/class-roles.php:70
|
492 |
+
msgid "Granted"
|
493 |
+
msgstr ""
|
494 |
+
|
495 |
+
#: admin/class-roles.php:71
|
496 |
+
msgid "Denied"
|
497 |
+
msgstr ""
|
498 |
+
|
499 |
+
#: admin/class-roles.php:112
|
500 |
+
msgid "Selected roles deleted."
|
501 |
+
msgstr ""
|
502 |
+
|
503 |
+
#: admin/class-roles.php:131
|
504 |
+
msgid "%s role deleted."
|
505 |
+
msgstr ""
|
506 |
+
|
507 |
+
#: admin/class-roles.php:256
|
508 |
+
msgid "This screen provides access to all of your user roles. Roles are a method of grouping users. They are made up of capabilities (caps), which give permission to users to perform specific actions on the site."
|
509 |
+
msgstr ""
|
510 |
+
|
511 |
+
#: admin/class-roles.php:274
|
512 |
+
msgid "You can hide/display columns based on your needs and decide how many roles to list per screen using the Screen Options tab."
|
513 |
+
msgstr ""
|
514 |
+
|
515 |
+
#: admin/class-roles.php:275
|
516 |
+
msgid "You can filter the list of roles by types using the text links in the upper left. The default view is to show all roles."
|
517 |
+
msgstr ""
|
518 |
+
|
519 |
+
#: admin/class-roles.php:289
|
520 |
+
msgid "Hovering over a row in the roles list will display action links that allow you to manage your role. You can perform the following actions:"
|
521 |
+
msgstr ""
|
522 |
+
|
523 |
+
#: admin/class-roles.php:293
|
524 |
+
msgid "<strong>Edit</strong> takes you to the editing screen for that role. You can also reach that screen by clicking on the role name."
|
525 |
+
msgstr ""
|
526 |
+
|
527 |
+
#: admin/class-roles.php:294
|
528 |
+
msgid "<strong>Delete</strong> removes your role from this list and permanently deletes it."
|
529 |
+
msgstr ""
|
530 |
+
|
531 |
+
#: admin/class-roles.php:295
|
532 |
+
msgid "<strong>Clone</strong> copies the role and takes you to the new role screen to further edit it."
|
533 |
+
msgstr ""
|
534 |
+
|
535 |
+
#: admin/class-roles.php:296
|
536 |
+
msgid "<strong>Users</strong> takes you to the users screen and lists the users that have that role."
|
537 |
+
msgstr ""
|
538 |
+
|
539 |
+
#: admin/class-roles.php:310
|
540 |
+
msgid "You can permanently delete multiple roles at once. Select the roles you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply."
|
541 |
+
msgstr ""
|
542 |
+
|
543 |
+
#: admin/class-settings.php:174 admin/class-settings.php:175
|
544 |
+
#: admin/class-settings.php:275
|
545 |
+
msgctxt "admin screen"
|
546 |
+
msgid "Members"
|
547 |
+
msgstr ""
|
548 |
+
|
549 |
+
#: admin/class-user-edit.php:97 admin/class-user-new.php:106
|
550 |
+
msgid "User Roles"
|
551 |
+
msgstr ""
|
552 |
+
|
553 |
+
#: admin/functions-admin.php:47
|
554 |
+
msgid "OK"
|
555 |
+
msgstr ""
|
556 |
+
|
557 |
+
#: admin/functions-admin.php:50
|
558 |
+
msgid "Are you sure you want to delete this role? This is a permanent action and cannot be undone."
|
559 |
+
msgstr ""
|
560 |
+
|
561 |
+
#: admin/functions-help.php:23
|
562 |
+
msgid "Documentation"
|
563 |
+
msgstr ""
|
564 |
+
|
565 |
+
#: admin/functions-help.php:24
|
566 |
+
msgid "Support Forums"
|
567 |
+
msgstr ""
|
568 |
+
|
569 |
+
#: admin/functions-help.php:29
|
570 |
+
msgid "For more information:"
|
571 |
+
msgstr ""
|
572 |
+
|
573 |
+
#: admin/functions-help.php:78
|
574 |
+
msgid "Edit Capabilities"
|
575 |
+
msgstr ""
|
576 |
+
|
577 |
+
#: admin/functions-help.php:109
|
578 |
+
msgid "This screen allows you to edit an individual role and its capabilities."
|
579 |
+
msgstr ""
|
580 |
+
|
581 |
+
#: admin/functions-help.php:114
|
582 |
+
msgid "Visit the %s page in the WordPress Codex to see a complete list of roles, capabilities, and their definitions."
|
583 |
+
msgstr ""
|
584 |
+
|
585 |
+
#: admin/functions-help.php:115 admin/views/class-view-general.php:62
|
586 |
+
msgid "Roles and Capabilities"
|
587 |
+
msgstr ""
|
588 |
+
|
589 |
+
#: admin/functions-help.php:130
|
590 |
+
msgid "The role name field allows you to enter a human-readable name for your role."
|
591 |
+
msgstr ""
|
592 |
+
|
593 |
+
#: admin/functions-help.php:134
|
594 |
+
msgid "The machine-readable version of the role appears below the name field, which you can edit. This can only have lowercase letters, numbers, or underscores."
|
595 |
+
msgstr ""
|
596 |
+
|
597 |
+
#: admin/functions-help.php:148
|
598 |
+
msgid "The capabilities edit box is made up of tabs that separate capabilities into groups. You may take the following actions for each capability:"
|
599 |
+
msgstr ""
|
600 |
+
|
601 |
+
#: admin/functions-help.php:152
|
602 |
+
msgid "<strong>Grant</strong> allows you to grant the role a capability."
|
603 |
+
msgstr ""
|
604 |
+
|
605 |
+
#: admin/functions-help.php:153
|
606 |
+
msgid "<strong>Deny</strong> allows you to explicitly deny the role a capability."
|
607 |
+
msgstr ""
|
608 |
+
|
609 |
+
#: admin/functions-help.php:154
|
610 |
+
msgid "You may also opt to neither grant nor deny the role a capability."
|
611 |
+
msgstr ""
|
612 |
+
|
613 |
+
#: admin/functions-help.php:168
|
614 |
+
msgid "The custom capability box allows you to create a custom capability for the role. After hitting the Add New button, it will add the capability to the Custom tab in the Edit Capabilities box."
|
615 |
+
msgstr ""
|
616 |
+
|
617 |
+
#: admin/functions-settings.php:35 inc/functions-cap-groups.php:42
|
618 |
+
msgid "General"
|
619 |
+
msgstr ""
|
620 |
+
|
621 |
+
#: admin/functions-settings.php:46
|
622 |
+
msgid "Add-Ons"
|
623 |
+
msgstr ""
|
624 |
+
|
625 |
+
#: admin/views/class-view-addons.php:53
|
626 |
+
msgid "There are currently no add-ons to show. Please try again later."
|
627 |
+
msgstr ""
|
628 |
+
|
629 |
+
#: admin/views/class-view-addons.php:99 admin/views/class-view-addons.php:194
|
630 |
+
msgid "Purchase"
|
631 |
+
msgstr ""
|
632 |
+
|
633 |
+
#: admin/views/class-view-addons.php:103 admin/views/class-view-addons.php:107
|
634 |
+
#: admin/views/class-view-addons.php:185
|
635 |
+
msgid "Download"
|
636 |
+
msgstr ""
|
637 |
+
|
638 |
+
#: admin/views/class-view-addons.php:121
|
639 |
+
msgid "By %s"
|
640 |
+
msgstr ""
|
641 |
+
|
642 |
+
#: admin/views/class-view-addons.php:145
|
643 |
+
msgid "%s+ Active Installs"
|
644 |
+
msgstr ""
|
645 |
+
|
646 |
+
#: admin/views/class-view-addons.php:213
|
647 |
+
msgid "The Add-Ons screen allows you to view available add-ons for the Members plugin. You can download some plugins directly. Others may be available to purchase."
|
648 |
+
msgstr ""
|
649 |
+
|
650 |
+
#: admin/views/class-view-addons.php:227
|
651 |
+
msgid "Some plugins may be available for direct download. In such cases, you can click the download button to get a ZIP file of the plugin."
|
652 |
+
msgstr ""
|
653 |
+
|
654 |
+
#: admin/views/class-view-addons.php:241
|
655 |
+
msgid "Some add-ons may require purchase before downloading them. Clicking the purchase button will take you off-site to view the add-on in more detail."
|
656 |
+
msgstr ""
|
657 |
+
|
658 |
+
#: admin/views/class-view-general.php:64 admin/views/class-view-general.php:371
|
659 |
+
msgid "Sidebar Widgets"
|
660 |
+
msgstr ""
|
661 |
+
|
662 |
+
#: admin/views/class-view-general.php:65 admin/views/class-view-general.php:380
|
663 |
+
msgid "Private Site"
|
664 |
+
msgstr ""
|
665 |
+
|
666 |
+
#: admin/views/class-view-general.php:70
|
667 |
+
msgid "Role Manager"
|
668 |
+
msgstr ""
|
669 |
+
|
670 |
+
#: admin/views/class-view-general.php:71
|
671 |
+
msgid "Multiple User Roles"
|
672 |
+
msgstr ""
|
673 |
+
|
674 |
+
#: admin/views/class-view-general.php:75
|
675 |
+
msgid "Enable Permissions"
|
676 |
+
msgstr ""
|
677 |
+
|
678 |
+
#: admin/views/class-view-general.php:79
|
679 |
+
msgid "Login Widget"
|
680 |
+
msgstr ""
|
681 |
+
|
682 |
+
#: admin/views/class-view-general.php:80
|
683 |
+
msgid "Users Widget"
|
684 |
+
msgstr ""
|
685 |
+
|
686 |
+
#: admin/views/class-view-general.php:83
|
687 |
+
msgid "Enable Private Site"
|
688 |
+
msgstr ""
|
689 |
+
|
690 |
+
#: admin/views/class-view-general.php:84
|
691 |
+
msgid "REST API"
|
692 |
+
msgstr ""
|
693 |
+
|
694 |
+
#: admin/views/class-view-general.php:85
|
695 |
+
msgid "Disable Feed"
|
696 |
+
msgstr ""
|
697 |
+
|
698 |
+
#: admin/views/class-view-general.php:86
|
699 |
+
msgid "Feed Error Message"
|
700 |
+
msgstr ""
|
701 |
+
|
702 |
+
#: admin/views/class-view-general.php:128
|
703 |
+
msgid "Your roles and capabilities will not revert back to their previous settings after deactivating or uninstalling this plugin, so use this feature wisely."
|
704 |
+
msgstr ""
|
705 |
+
|
706 |
+
#: admin/views/class-view-general.php:143
|
707 |
+
msgid "Enable the role manager."
|
708 |
+
msgstr ""
|
709 |
+
|
710 |
+
#: admin/views/class-view-general.php:161
|
711 |
+
msgid "Denied capabilities should always overrule granted capabilities."
|
712 |
+
msgstr ""
|
713 |
+
|
714 |
+
#: admin/views/class-view-general.php:168
|
715 |
+
msgid "Show human-readable capabilities when possible."
|
716 |
+
msgstr ""
|
717 |
+
|
718 |
+
#: admin/views/class-view-general.php:186
|
719 |
+
msgid "Allow users to be assigned more than a single role."
|
720 |
+
msgstr ""
|
721 |
+
|
722 |
+
#: admin/views/class-view-general.php:201
|
723 |
+
msgid "Enable the content permissions feature."
|
724 |
+
msgstr ""
|
725 |
+
|
726 |
+
#: admin/views/class-view-general.php:236
|
727 |
+
msgid "Enable the login form widget."
|
728 |
+
msgstr ""
|
729 |
+
|
730 |
+
#: admin/views/class-view-general.php:251
|
731 |
+
msgid "Enable the users widget."
|
732 |
+
msgstr ""
|
733 |
+
|
734 |
+
#: admin/views/class-view-general.php:266
|
735 |
+
msgid "Redirect all logged-out users to the login page before allowing them to view the site."
|
736 |
+
msgstr ""
|
737 |
+
|
738 |
+
#: admin/views/class-view-general.php:281
|
739 |
+
msgid "Require authentication for access to the REST API."
|
740 |
+
msgstr ""
|
741 |
+
|
742 |
+
#: admin/views/class-view-general.php:296
|
743 |
+
msgid "Show error message for feed items."
|
744 |
+
msgstr ""
|
745 |
+
|
746 |
+
#: admin/views/class-view-general.php:332
|
747 |
+
msgid "Update Settings"
|
748 |
+
msgstr ""
|
749 |
+
|
750 |
+
#: admin/views/class-view-general.php:353
|
751 |
+
msgid "Role and Capabilities"
|
752 |
+
msgstr ""
|
753 |
+
|
754 |
+
#: admin/views/class-view-general.php:399
|
755 |
+
msgid "The role manager allows you to manage roles on your site by giving you the ability to create, edit, and delete any role. Note that changes to roles do not change settings for the Members plugin. You are literally changing data in your WordPress database. This plugin feature merely provides an interface for you to make these changes."
|
756 |
+
msgstr ""
|
757 |
+
|
758 |
+
#: admin/views/class-view-general.php:403
|
759 |
+
msgid "The multiple user roles feature allows you to assign more than one role to each user from the edit user screen."
|
760 |
+
msgstr ""
|
761 |
+
|
762 |
+
#: admin/views/class-view-general.php:407
|
763 |
+
msgid "Tick the checkbox for denied capabilities to always take precedence over granted capabilities when there is a conflict. This is only relevant when using multiple roles per user."
|
764 |
+
msgstr ""
|
765 |
+
|
766 |
+
#: admin/views/class-view-general.php:411
|
767 |
+
msgid "Tick the checkbox to show human-readable capabilities when possible. Note that custom capabilities and capabilities from third-party plugins will show the machine-readable capability name unless they are registered."
|
768 |
+
msgstr ""
|
769 |
+
|
770 |
+
#: admin/views/class-view-general.php:425
|
771 |
+
msgid "The content permissions features adds a meta box to the edit post screen that allows you to grant permissions for who can read the post content based on the user's role. Only users of roles with the %s capability will be able to use this component."
|
772 |
+
msgstr ""
|
773 |
+
|
774 |
+
#: admin/views/class-view-general.php:439
|
775 |
+
msgid "The sidebar widgets feature adds additional widgets for use in your theme's sidebars."
|
776 |
+
msgstr ""
|
777 |
+
|
778 |
+
#: admin/views/class-view-general.php:453
|
779 |
+
msgid "The private site feature redirects all users who are not logged into the site to the login page, creating an entirely private site. You may also replace your feed content with a custom error message."
|
780 |
+
msgstr ""
|
781 |
+
|
782 |
+
#: inc/class-widget-login.php:44
|
783 |
+
msgid "A widget that allows users to log into your site."
|
784 |
+
msgstr ""
|
785 |
+
|
786 |
+
#: inc/class-widget-login.php:55
|
787 |
+
msgid "Members: Login Form"
|
788 |
+
msgstr ""
|
789 |
+
|
790 |
+
#: inc/class-widget-login.php:59 inc/class-widget-login.php:62
|
791 |
+
msgid "Log In"
|
792 |
+
msgstr ""
|
793 |
+
|
794 |
+
#: inc/class-widget-login.php:60
|
795 |
+
msgid "Username"
|
796 |
+
msgstr ""
|
797 |
+
|
798 |
+
#: inc/class-widget-login.php:61
|
799 |
+
msgid "Password"
|
800 |
+
msgstr ""
|
801 |
+
|
802 |
+
#: inc/class-widget-login.php:63
|
803 |
+
msgid "Remember Me"
|
804 |
+
msgstr ""
|
805 |
+
|
806 |
+
#: inc/class-widget-login.php:73
|
807 |
+
msgid "Please log into the site."
|
808 |
+
msgstr ""
|
809 |
+
|
810 |
+
#: inc/class-widget-login.php:74
|
811 |
+
msgid "You are currently logged in."
|
812 |
+
msgstr ""
|
813 |
+
|
814 |
+
#: inc/class-widget-login.php:209 inc/class-widget-users.php:208
|
815 |
+
msgid "Title:"
|
816 |
+
msgstr ""
|
817 |
+
|
818 |
+
#: inc/class-widget-login.php:213
|
819 |
+
msgid "Username Label:"
|
820 |
+
msgstr ""
|
821 |
+
|
822 |
+
#: inc/class-widget-login.php:217
|
823 |
+
msgid "Password Label:"
|
824 |
+
msgstr ""
|
825 |
+
|
826 |
+
#: inc/class-widget-login.php:221
|
827 |
+
msgid "Log In Label:"
|
828 |
+
msgstr ""
|
829 |
+
|
830 |
+
#: inc/class-widget-login.php:225
|
831 |
+
msgid "Remember Me Label:"
|
832 |
+
msgstr ""
|
833 |
+
|
834 |
+
#: inc/class-widget-login.php:233
|
835 |
+
msgid "Username Value:"
|
836 |
+
msgstr ""
|
837 |
+
|
838 |
+
#: inc/class-widget-login.php:237
|
839 |
+
msgid "Username Field ID:"
|
840 |
+
msgstr ""
|
841 |
+
|
842 |
+
#: inc/class-widget-login.php:241
|
843 |
+
msgid "Remember Me Field ID:"
|
844 |
+
msgstr ""
|
845 |
+
|
846 |
+
#: inc/class-widget-login.php:245
|
847 |
+
msgid "Password Field ID:"
|
848 |
+
msgstr ""
|
849 |
+
|
850 |
+
#: inc/class-widget-login.php:249
|
851 |
+
msgid "Submit Button ID:"
|
852 |
+
msgstr ""
|
853 |
+
|
854 |
+
#: inc/class-widget-login.php:260
|
855 |
+
msgid "\"Remember me\" checkbox?"
|
856 |
+
msgstr ""
|
857 |
+
|
858 |
+
#: inc/class-widget-login.php:266
|
859 |
+
msgid "Check \"remember me\"?"
|
860 |
+
msgstr ""
|
861 |
+
|
862 |
+
#: inc/class-widget-login.php:272
|
863 |
+
msgid "Display avatar?"
|
864 |
+
msgstr ""
|
865 |
+
|
866 |
+
#: inc/class-widget-login.php:276
|
867 |
+
msgid "Logged out text:"
|
868 |
+
msgstr ""
|
869 |
+
|
870 |
+
#: inc/class-widget-login.php:281
|
871 |
+
msgid "Logged in text:"
|
872 |
+
msgstr ""
|
873 |
+
|
874 |
+
#: inc/class-widget-users.php:44
|
875 |
+
msgid "Provides the ability to list the users of the site."
|
876 |
+
msgstr ""
|
877 |
+
|
878 |
+
#: inc/class-widget-users.php:55
|
879 |
+
msgid "Members: Users"
|
880 |
+
msgstr ""
|
881 |
+
|
882 |
+
#: inc/class-widget-users.php:185
|
883 |
+
msgid "Ascending"
|
884 |
+
msgstr ""
|
885 |
+
|
886 |
+
#: inc/class-widget-users.php:186
|
887 |
+
msgid "Descending"
|
888 |
+
msgstr ""
|
889 |
+
|
890 |
+
#: inc/class-widget-users.php:190
|
891 |
+
msgid "Display Name"
|
892 |
+
msgstr ""
|
893 |
+
|
894 |
+
#: inc/class-widget-users.php:191
|
895 |
+
msgid "Email"
|
896 |
+
msgstr ""
|
897 |
+
|
898 |
+
#: inc/class-widget-users.php:192
|
899 |
+
msgid "ID"
|
900 |
+
msgstr ""
|
901 |
+
|
902 |
+
#: inc/class-widget-users.php:193
|
903 |
+
msgid "Nice Name"
|
904 |
+
msgstr ""
|
905 |
+
|
906 |
+
#: inc/class-widget-users.php:194
|
907 |
+
msgid "Post Count"
|
908 |
+
msgstr ""
|
909 |
+
|
910 |
+
#: inc/class-widget-users.php:195
|
911 |
+
msgid "Registered"
|
912 |
+
msgstr ""
|
913 |
+
|
914 |
+
#: inc/class-widget-users.php:196
|
915 |
+
msgid "URL"
|
916 |
+
msgstr ""
|
917 |
+
|
918 |
+
#: inc/class-widget-users.php:197
|
919 |
+
msgid "Login"
|
920 |
+
msgstr ""
|
921 |
+
|
922 |
+
#: inc/class-widget-users.php:212
|
923 |
+
msgid "Order By:"
|
924 |
+
msgstr ""
|
925 |
+
|
926 |
+
#: inc/class-widget-users.php:220
|
927 |
+
msgid "Order:"
|
928 |
+
msgstr ""
|
929 |
+
|
930 |
+
#: inc/class-widget-users.php:237
|
931 |
+
msgid "Limit:"
|
932 |
+
msgstr ""
|
933 |
+
|
934 |
+
#: inc/class-widget-users.php:241
|
935 |
+
msgid "Offset:"
|
936 |
+
msgstr ""
|
937 |
+
|
938 |
+
#: inc/class-widget-users.php:249
|
939 |
+
msgid "Include:"
|
940 |
+
msgstr ""
|
941 |
+
|
942 |
+
#: inc/class-widget-users.php:253
|
943 |
+
msgid "Exclude:"
|
944 |
+
msgstr ""
|
945 |
+
|
946 |
+
#: inc/class-widget-users.php:257
|
947 |
+
msgid "Search:"
|
948 |
+
msgstr ""
|
949 |
+
|
950 |
+
#: inc/class-widget-users.php:261
|
951 |
+
msgid "Meta Key:"
|
952 |
+
msgstr ""
|
953 |
+
|
954 |
+
#: inc/class-widget-users.php:269
|
955 |
+
msgid "Meta Value:"
|
956 |
+
msgstr ""
|
957 |
+
|
958 |
+
#: inc/functions-cap-groups.php:92
|
959 |
+
msgid "Taxonomies"
|
960 |
+
msgstr ""
|
961 |
+
|
962 |
+
#: inc/functions-cap-groups.php:103
|
963 |
+
msgid "Appearance"
|
964 |
+
msgstr ""
|
965 |
+
|
966 |
+
#: inc/functions-cap-groups.php:112
|
967 |
+
msgid "Plugins"
|
968 |
+
msgstr ""
|
969 |
+
|
970 |
+
#: inc/functions-cap-groups.php:130
|
971 |
+
msgid "Custom"
|
972 |
+
msgstr ""
|
973 |
+
|
974 |
+
#: inc/functions-capabilities.php:57
|
975 |
+
msgid "Edit Dashboard"
|
976 |
+
msgstr ""
|
977 |
+
|
978 |
+
#: inc/functions-capabilities.php:58
|
979 |
+
msgid "Edit Files"
|
980 |
+
msgstr ""
|
981 |
+
|
982 |
+
#: inc/functions-capabilities.php:59
|
983 |
+
msgid "Export"
|
984 |
+
msgstr ""
|
985 |
+
|
986 |
+
#: inc/functions-capabilities.php:60
|
987 |
+
msgid "Import"
|
988 |
+
msgstr ""
|
989 |
+
|
990 |
+
#: inc/functions-capabilities.php:61
|
991 |
+
msgid "Manage Links"
|
992 |
+
msgstr ""
|
993 |
+
|
994 |
+
#: inc/functions-capabilities.php:62
|
995 |
+
msgid "Manage Options"
|
996 |
+
msgstr ""
|
997 |
+
|
998 |
+
#: inc/functions-capabilities.php:63
|
999 |
+
msgid "Moderate Comments"
|
1000 |
+
msgstr ""
|
1001 |
+
|
1002 |
+
#: inc/functions-capabilities.php:64
|
1003 |
+
msgid "Read"
|
1004 |
+
msgstr ""
|
1005 |
+
|
1006 |
+
#: inc/functions-capabilities.php:65
|
1007 |
+
msgid "Unfiltered HTML"
|
1008 |
+
msgstr ""
|
1009 |
+
|
1010 |
+
#: inc/functions-capabilities.php:66
|
1011 |
+
msgid "Update Core"
|
1012 |
+
msgstr ""
|
1013 |
+
|
1014 |
+
#: inc/functions-capabilities.php:69
|
1015 |
+
msgid "Delete Others' Posts"
|
1016 |
+
msgstr ""
|
1017 |
+
|
1018 |
+
#: inc/functions-capabilities.php:70
|
1019 |
+
msgid "Delete Posts"
|
1020 |
+
msgstr ""
|
1021 |
+
|
1022 |
+
#: inc/functions-capabilities.php:71
|
1023 |
+
msgid "Delete Private Posts"
|
1024 |
+
msgstr ""
|
1025 |
+
|
1026 |
+
#: inc/functions-capabilities.php:72
|
1027 |
+
msgid "Delete Published Posts"
|
1028 |
+
msgstr ""
|
1029 |
+
|
1030 |
+
#: inc/functions-capabilities.php:73
|
1031 |
+
msgid "Edit Others' Posts"
|
1032 |
+
msgstr ""
|
1033 |
+
|
1034 |
+
#: inc/functions-capabilities.php:74
|
1035 |
+
msgid "Edit Posts"
|
1036 |
+
msgstr ""
|
1037 |
+
|
1038 |
+
#: inc/functions-capabilities.php:75
|
1039 |
+
msgid "Edit Private Posts"
|
1040 |
+
msgstr ""
|
1041 |
+
|
1042 |
+
#: inc/functions-capabilities.php:76
|
1043 |
+
msgid "Edit Published Posts"
|
1044 |
+
msgstr ""
|
1045 |
+
|
1046 |
+
#: inc/functions-capabilities.php:77
|
1047 |
+
msgid "Publish Posts"
|
1048 |
+
msgstr ""
|
1049 |
+
|
1050 |
+
#: inc/functions-capabilities.php:78
|
1051 |
+
msgid "Read Private Posts"
|
1052 |
+
msgstr ""
|
1053 |
+
|
1054 |
+
#: inc/functions-capabilities.php:81
|
1055 |
+
msgid "Delete Others' Pages"
|
1056 |
+
msgstr ""
|
1057 |
+
|
1058 |
+
#: inc/functions-capabilities.php:82
|
1059 |
+
msgid "Delete Pages"
|
1060 |
+
msgstr ""
|
1061 |
+
|
1062 |
+
#: inc/functions-capabilities.php:83
|
1063 |
+
msgid "Delete Private Pages"
|
1064 |
+
msgstr ""
|
1065 |
+
|
1066 |
+
#: inc/functions-capabilities.php:84
|
1067 |
+
msgid "Delete Published Pages"
|
1068 |
+
msgstr ""
|
1069 |
+
|
1070 |
+
#: inc/functions-capabilities.php:85
|
1071 |
+
msgid "Edit Others' Pages"
|
1072 |
+
msgstr ""
|
1073 |
+
|
1074 |
+
#: inc/functions-capabilities.php:86
|
1075 |
+
msgid "Edit Pages"
|
1076 |
+
msgstr ""
|
1077 |
+
|
1078 |
+
#: inc/functions-capabilities.php:87
|
1079 |
+
msgid "Edit Private Pages"
|
1080 |
+
msgstr ""
|
1081 |
+
|
1082 |
+
#: inc/functions-capabilities.php:88
|
1083 |
+
msgid "Edit Published Pages"
|
1084 |
+
msgstr ""
|
1085 |
+
|
1086 |
+
#: inc/functions-capabilities.php:89
|
1087 |
+
msgid "Publish Pages"
|
1088 |
+
msgstr ""
|
1089 |
+
|
1090 |
+
#: inc/functions-capabilities.php:90
|
1091 |
+
msgid "Read Private Pages"
|
1092 |
+
msgstr ""
|
1093 |
+
|
1094 |
+
#: inc/functions-capabilities.php:93
|
1095 |
+
msgid "Upload Files"
|
1096 |
+
msgstr ""
|
1097 |
+
|
1098 |
+
#: inc/functions-capabilities.php:96
|
1099 |
+
msgid "Manage Categories"
|
1100 |
+
msgstr ""
|
1101 |
+
|
1102 |
+
#: inc/functions-capabilities.php:99
|
1103 |
+
msgid "Delete Themes"
|
1104 |
+
msgstr ""
|
1105 |
+
|
1106 |
+
#: inc/functions-capabilities.php:100
|
1107 |
+
msgid "Edit Theme Options"
|
1108 |
+
msgstr ""
|
1109 |
+
|
1110 |
+
#: inc/functions-capabilities.php:101
|
1111 |
+
msgid "Edit Themes"
|
1112 |
+
msgstr ""
|
1113 |
+
|
1114 |
+
#: inc/functions-capabilities.php:102
|
1115 |
+
msgid "Install Themes"
|
1116 |
+
msgstr ""
|
1117 |
+
|
1118 |
+
#: inc/functions-capabilities.php:103
|
1119 |
+
msgid "Switch Themes"
|
1120 |
+
msgstr ""
|
1121 |
+
|
1122 |
+
#: inc/functions-capabilities.php:104
|
1123 |
+
msgid "Update Themes"
|
1124 |
+
msgstr ""
|
1125 |
+
|
1126 |
+
#: inc/functions-capabilities.php:107
|
1127 |
+
msgid "Activate Plugins"
|
1128 |
+
msgstr ""
|
1129 |
+
|
1130 |
+
#: inc/functions-capabilities.php:108
|
1131 |
+
msgid "Delete Plugins"
|
1132 |
+
msgstr ""
|
1133 |
+
|
1134 |
+
#: inc/functions-capabilities.php:109
|
1135 |
+
msgid "Edit Plugins"
|
1136 |
+
msgstr ""
|
1137 |
+
|
1138 |
+
#: inc/functions-capabilities.php:110
|
1139 |
+
msgid "Install Plugins"
|
1140 |
+
msgstr ""
|
1141 |
+
|
1142 |
+
#: inc/functions-capabilities.php:111
|
1143 |
+
msgid "Update Plugins"
|
1144 |
+
msgstr ""
|
1145 |
+
|
1146 |
+
#: inc/functions-capabilities.php:114
|
1147 |
+
msgid "Create Roles"
|
1148 |
+
msgstr ""
|
1149 |
+
|
1150 |
+
#: inc/functions-capabilities.php:115
|
1151 |
+
msgid "Create Users"
|
1152 |
+
msgstr ""
|
1153 |
+
|
1154 |
+
#: inc/functions-capabilities.php:116
|
1155 |
+
msgid "Delete Roles"
|
1156 |
+
msgstr ""
|
1157 |
+
|
1158 |
+
#: inc/functions-capabilities.php:117
|
1159 |
+
msgid "Delete Users"
|
1160 |
+
msgstr ""
|
1161 |
+
|
1162 |
+
#: inc/functions-capabilities.php:118
|
1163 |
+
msgid "Edit Roles"
|
1164 |
+
msgstr ""
|
1165 |
+
|
1166 |
+
#: inc/functions-capabilities.php:119
|
1167 |
+
msgid "Edit Users"
|
1168 |
+
msgstr ""
|
1169 |
+
|
1170 |
+
#: inc/functions-capabilities.php:120
|
1171 |
+
msgid "List Roles"
|
1172 |
+
msgstr ""
|
1173 |
+
|
1174 |
+
#: inc/functions-capabilities.php:121
|
1175 |
+
msgid "List Users"
|
1176 |
+
msgstr ""
|
1177 |
+
|
1178 |
+
#: inc/functions-capabilities.php:122
|
1179 |
+
msgid "Promote Users"
|
1180 |
+
msgstr ""
|
1181 |
+
|
1182 |
+
#: inc/functions-capabilities.php:123
|
1183 |
+
msgid "Remove Users"
|
1184 |
+
msgstr ""
|
1185 |
+
|
1186 |
+
#: inc/functions-capabilities.php:126
|
1187 |
+
msgid "Restrict Content"
|
1188 |
+
msgstr ""
|
1189 |
+
|
1190 |
+
#: inc/functions-capabilities.php:141
|
1191 |
+
msgid "Assign Categories"
|
1192 |
+
msgstr ""
|
1193 |
+
|
1194 |
+
#: inc/functions-capabilities.php:142
|
1195 |
+
msgid "Edit Categories"
|
1196 |
+
msgstr ""
|
1197 |
+
|
1198 |
+
#: inc/functions-capabilities.php:143
|
1199 |
+
msgid "Delete Categories"
|
1200 |
+
msgstr ""
|
1201 |
+
|
1202 |
+
#: inc/functions-capabilities.php:144
|
1203 |
+
msgid "Assign Post Tags"
|
1204 |
+
msgstr ""
|
1205 |
+
|
1206 |
+
#: inc/functions-capabilities.php:145
|
1207 |
+
msgid "Edit Post Tags"
|
1208 |
+
msgstr ""
|
1209 |
+
|
1210 |
+
#: inc/functions-capabilities.php:146
|
1211 |
+
msgid "Delete Post Tags"
|
1212 |
+
msgstr ""
|
1213 |
+
|
1214 |
+
#: inc/functions-capabilities.php:147
|
1215 |
+
msgid "Manage Post Tags"
|
1216 |
+
msgstr ""
|
1217 |
+
|
1218 |
+
#: inc/functions-options.php:134
|
1219 |
+
msgid "Sorry, but you do not have permission to view this content."
|
1220 |
+
msgstr ""
|
1221 |
+
|
1222 |
+
#: inc/functions-options.php:135
|
1223 |
+
msgid "You must be logged into the site to view this content."
|
1224 |
+
msgstr ""
|
1225 |
+
|
1226 |
+
#: inc/functions-private-site.php:163
|
1227 |
+
msgid "You are not currently logged in."
|
1228 |
+
msgstr ""
|
1229 |
+
|
1230 |
+
#: inc/functions-private-site.php:187
|
1231 |
+
msgid "You do not currently have access to the \"%s\" site. If you believe you should have access, please contact your network administrator."
|
1232 |
+
msgstr ""
|
1233 |
+
|
1234 |
+
#: inc/functions-private-site.php:194
|
1235 |
+
msgid "If you reached this page by accident and meant to visit one of your own sites, try one of the following links."
|
1236 |
+
msgstr ""
|
1237 |
+
|
1238 |
+
#: inc/functions-role-groups.php:42
|
1239 |
+
msgid "WordPress"
|
1240 |
+
msgstr ""
|
1241 |
+
|
1242 |
+
#: members.php:151
|
1243 |
+
msgid "Method does not exist."
|
1244 |
+
msgstr ""
|
1245 |
+
|
1246 |
+
#: members.php:282
|
1247 |
+
msgid "Members requires PHP version %1$s. You are running version %2$s. Please upgrade and try again."
|
1248 |
+
msgstr ""
|
1249 |
+
#. Plugin Name of the plugin/theme
|
1250 |
+
msgid "Members"
|
1251 |
+
msgstr ""
|
1252 |
+
|
1253 |
+
#. Plugin URI of the plugin/theme
|
1254 |
+
msgid "https://themehybrid.com/plugins/members"
|
1255 |
+
msgstr ""
|
1256 |
+
|
1257 |
+
#. Description of the plugin/theme
|
1258 |
+
msgid "A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private."
|
1259 |
+
msgstr ""
|
1260 |
+
|
1261 |
+
#. Author of the plugin/theme
|
1262 |
+
msgid "Justin Tadlock"
|
1263 |
+
msgstr ""
|
1264 |
+
|
1265 |
+
#. Author URI of the plugin/theme
|
1266 |
+
msgid "https://themehybrid.com"
|
1267 |
+
msgstr ""
|
languages/members.pot
DELETED
@@ -1,830 +0,0 @@
|
|
1 |
-
# Copyright (C) 2016 Members
|
2 |
-
# This file is distributed under the same license as the Members package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: Members 1.1.1-dev\n"
|
6 |
-
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/members\n"
|
7 |
-
"POT-Creation-Date: 2016-01-09 19:58:30+00:00\n"
|
8 |
-
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
-
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
|
12 |
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
-
|
15 |
-
#: _assets/class-cap-new.php:64 _assets/class-cap-new.php:158
|
16 |
-
msgid "Add New Capability"
|
17 |
-
msgstr ""
|
18 |
-
|
19 |
-
#: _assets/class-cap-new.php:102
|
20 |
-
msgid "Please input a valid capability."
|
21 |
-
msgstr ""
|
22 |
-
|
23 |
-
#: _assets/class-cap-new.php:106
|
24 |
-
msgid "The %s capability already exists."
|
25 |
-
msgstr ""
|
26 |
-
|
27 |
-
#: _assets/class-cap-new.php:110
|
28 |
-
msgid "Please select at least one role."
|
29 |
-
msgstr ""
|
30 |
-
|
31 |
-
#: _assets/class-cap-new.php:123
|
32 |
-
msgid "The %s capability has been created."
|
33 |
-
msgstr ""
|
34 |
-
|
35 |
-
#: _assets/class-cap-new.php:172 admin/tmpl/cap-section.php:19
|
36 |
-
#: admin/tmpl/cap-section.php:27
|
37 |
-
msgid "Capability"
|
38 |
-
msgstr ""
|
39 |
-
|
40 |
-
#: _assets/class-cap-new.php:178
|
41 |
-
msgid "The capability should be unique and contain only alphanumeric characters and underscores."
|
42 |
-
msgstr ""
|
43 |
-
|
44 |
-
#: _assets/class-cap-new.php:185 admin/class-manage-roles.php:84
|
45 |
-
#: admin/class-manage-roles.php:90 admin/class-roles.php:168
|
46 |
-
#: admin/class-user-edit.php:87 admin/functions-admin.php:151
|
47 |
-
msgid "Roles"
|
48 |
-
msgstr ""
|
49 |
-
|
50 |
-
#: _assets/class-cap-new.php:189
|
51 |
-
msgid "Select at least one role. Because of the way capabilities work in WordPress, they can only exist if assigned to a role."
|
52 |
-
msgstr ""
|
53 |
-
|
54 |
-
#: _assets/class-cap-new.php:209
|
55 |
-
msgid "Add Capability"
|
56 |
-
msgstr ""
|
57 |
-
|
58 |
-
#: _assets/class-capability-list-table.php:264
|
59 |
-
#: _assets/class-capability-list-table.php:387
|
60 |
-
#: admin/class-role-list-table.php:338 admin/class-role-list-table.php:463
|
61 |
-
msgid "Delete"
|
62 |
-
msgstr ""
|
63 |
-
|
64 |
-
#: _assets/class-capability-list-table.php:319
|
65 |
-
#: admin/class-role-list-table.php:408
|
66 |
-
msgid "All %s"
|
67 |
-
msgid_plural "All %s"
|
68 |
-
msgstr[0] ""
|
69 |
-
msgstr[1] ""
|
70 |
-
|
71 |
-
#: _assets/class-capability-list-table.php:320
|
72 |
-
#: admin/functions-role-groups.php:112
|
73 |
-
msgid "Mine %s"
|
74 |
-
msgid_plural "Mine %s"
|
75 |
-
msgstr[0] ""
|
76 |
-
msgstr[1] ""
|
77 |
-
|
78 |
-
#: _assets/class-capability-list-table.php:321
|
79 |
-
#: admin/functions-role-groups.php:158
|
80 |
-
msgid "WordPress %s"
|
81 |
-
msgid_plural "WordPress %s"
|
82 |
-
msgstr[0] ""
|
83 |
-
msgstr[1] ""
|
84 |
-
|
85 |
-
#: _assets/class-capability-list-table.php:322
|
86 |
-
msgid "Members %s"
|
87 |
-
msgid_plural "Members %s"
|
88 |
-
msgstr[0] ""
|
89 |
-
msgstr[1] ""
|
90 |
-
|
91 |
-
#: _assets/class-capability-list-table.php:349
|
92 |
-
msgid "View all roles"
|
93 |
-
msgstr ""
|
94 |
-
|
95 |
-
#: _assets/class-capability-list-table.php:359
|
96 |
-
msgid "Filter"
|
97 |
-
msgstr ""
|
98 |
-
|
99 |
-
#: _assets/page-capabilities.php:45 _assets/page-capabilities.php:93
|
100 |
-
#: admin/class-settings.php:133
|
101 |
-
msgid "Capabilities"
|
102 |
-
msgstr ""
|
103 |
-
|
104 |
-
#: _assets/page-capabilities.php:69
|
105 |
-
msgid "%s capability deleted. Not really. This is just a message to output until the functionality is working."
|
106 |
-
msgstr ""
|
107 |
-
|
108 |
-
#: _assets/page-capabilities.php:73
|
109 |
-
msgid "No capability selected to delete."
|
110 |
-
msgstr ""
|
111 |
-
|
112 |
-
#: _assets/page-capabilities.php:96 admin/class-meta-box-custom-cap.php:88
|
113 |
-
#: admin/class-role-edit.php:260 admin/class-roles.php:171
|
114 |
-
msgid "Add New"
|
115 |
-
msgstr ""
|
116 |
-
|
117 |
-
#: _assets/page-capabilities.php:116
|
118 |
-
msgid "Are you sure you want to delete this capability? This is a permanent action and cannot be undone."
|
119 |
-
msgstr ""
|
120 |
-
|
121 |
-
#: admin/class-cap-control.php:115 admin/functions-admin.php:51
|
122 |
-
msgid "Grant %s capability"
|
123 |
-
msgstr ""
|
124 |
-
|
125 |
-
#: admin/class-cap-control.php:116 admin/functions-admin.php:52
|
126 |
-
msgid "Deny %s capability"
|
127 |
-
msgstr ""
|
128 |
-
|
129 |
-
#: admin/class-cap-tabs.php:174
|
130 |
-
msgid "Edit Capabilities: %s"
|
131 |
-
msgstr ""
|
132 |
-
|
133 |
-
#: admin/class-manage-roles.php:87 admin/class-role-edit.php:257
|
134 |
-
msgid "Edit Role"
|
135 |
-
msgstr ""
|
136 |
-
|
137 |
-
#: admin/class-meta-box-content-permissions.php:99 admin/class-settings.php:125
|
138 |
-
#: admin/class-settings.php:398
|
139 |
-
msgid "Content Permissions"
|
140 |
-
msgstr ""
|
141 |
-
|
142 |
-
#: admin/class-meta-box-content-permissions.php:132
|
143 |
-
msgid "Limit access to this post's content to users of the selected roles."
|
144 |
-
msgstr ""
|
145 |
-
|
146 |
-
#: admin/class-meta-box-content-permissions.php:152
|
147 |
-
msgid "If no roles are selected, everyone can view the content. The post author, any users who can edit this post, and users with the %s capability can view the content regardless of role."
|
148 |
-
msgstr ""
|
149 |
-
|
150 |
-
#: admin/class-meta-box-content-permissions.php:156
|
151 |
-
msgid "Custom error message:"
|
152 |
-
msgstr ""
|
153 |
-
|
154 |
-
#: admin/class-meta-box-content-permissions.php:158
|
155 |
-
msgid "Message shown to users that do not have permission to view the post."
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: admin/class-meta-box-custom-cap.php:71 admin/functions-help.php:94
|
159 |
-
msgid "Custom Capability"
|
160 |
-
msgstr ""
|
161 |
-
|
162 |
-
#: admin/class-meta-box-publish-role.php:65 admin/class-roles.php:66
|
163 |
-
#: inc/functions-admin-bar.php:35
|
164 |
-
msgid "Role"
|
165 |
-
msgstr ""
|
166 |
-
|
167 |
-
#: admin/class-meta-box-publish-role.php:98
|
168 |
-
msgid "Users:"
|
169 |
-
msgstr ""
|
170 |
-
|
171 |
-
#: admin/class-meta-box-publish-role.php:104
|
172 |
-
msgid "Granted:"
|
173 |
-
msgstr ""
|
174 |
-
|
175 |
-
#: admin/class-meta-box-publish-role.php:110
|
176 |
-
msgid "Denied:"
|
177 |
-
msgstr ""
|
178 |
-
|
179 |
-
#: admin/class-meta-box-publish-role.php:121
|
180 |
-
msgctxt "delete role"
|
181 |
-
msgid "Delete"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: admin/class-meta-box-publish-role.php:128
|
185 |
-
msgid "Update"
|
186 |
-
msgstr ""
|
187 |
-
|
188 |
-
#: admin/class-meta-box-publish-role.php:128
|
189 |
-
msgid "Add Role"
|
190 |
-
msgstr ""
|
191 |
-
|
192 |
-
#: admin/class-role-edit.php:90 members.php:165 members.php:176
|
193 |
-
msgid "Whoah, partner!"
|
194 |
-
msgstr ""
|
195 |
-
|
196 |
-
#: admin/class-role-edit.php:97
|
197 |
-
msgid "The requested role to edit does not exist."
|
198 |
-
msgstr ""
|
199 |
-
|
200 |
-
#: admin/class-role-edit.php:189
|
201 |
-
msgid "%s role updated."
|
202 |
-
msgstr ""
|
203 |
-
|
204 |
-
#: admin/class-role-edit.php:193
|
205 |
-
msgid "The %s role is not editable. This means that it is most likely added via another plugin for a special use or that you do not have permission to edit it."
|
206 |
-
msgstr ""
|
207 |
-
|
208 |
-
#: admin/class-role-edit.php:197 admin/class-role-new.php:224
|
209 |
-
msgid "The %s role has been created."
|
210 |
-
msgstr ""
|
211 |
-
|
212 |
-
#: admin/class-role-edit.php:279 admin/class-role-new.php:325
|
213 |
-
#: admin/class-roles.php:65 admin/functions-help.php:62
|
214 |
-
msgid "Role Name"
|
215 |
-
msgstr ""
|
216 |
-
|
217 |
-
#: admin/class-role-edit.php:285 admin/class-role-new.php:331
|
218 |
-
#: inc/class-widget-users.php:227
|
219 |
-
msgid "Role:"
|
220 |
-
msgstr ""
|
221 |
-
|
222 |
-
#: admin/class-role-list-table.php:229
|
223 |
-
msgid "Default Role"
|
224 |
-
msgstr ""
|
225 |
-
|
226 |
-
#: admin/class-role-list-table.php:233
|
227 |
-
msgid "Your Role"
|
228 |
-
msgstr ""
|
229 |
-
|
230 |
-
#: admin/class-role-list-table.php:334 admin/class-role-new.php:333
|
231 |
-
#: admin/functions-admin.php:49
|
232 |
-
msgid "Edit"
|
233 |
-
msgstr ""
|
234 |
-
|
235 |
-
#: admin/class-role-list-table.php:344
|
236 |
-
msgid "View"
|
237 |
-
msgstr ""
|
238 |
-
|
239 |
-
#: admin/class-role-list-table.php:349
|
240 |
-
msgid "Clone"
|
241 |
-
msgstr ""
|
242 |
-
|
243 |
-
#: admin/class-role-list-table.php:353
|
244 |
-
msgid "Change Default"
|
245 |
-
msgstr ""
|
246 |
-
|
247 |
-
#: admin/class-role-list-table.php:357 admin/class-roles.php:67
|
248 |
-
#: admin/functions-cap-groups.php:193 inc/class-widget-users.php:57
|
249 |
-
msgid "Users"
|
250 |
-
msgstr ""
|
251 |
-
|
252 |
-
#: admin/class-role-new.php:107 admin/class-role-new.php:308
|
253 |
-
msgid "Add New Role"
|
254 |
-
msgstr ""
|
255 |
-
|
256 |
-
#: admin/class-role-new.php:233
|
257 |
-
msgid "You must enter a valid role."
|
258 |
-
msgstr ""
|
259 |
-
|
260 |
-
#: admin/class-role-new.php:237
|
261 |
-
msgid "The %s role already exists."
|
262 |
-
msgstr ""
|
263 |
-
|
264 |
-
#: admin/class-role-new.php:241
|
265 |
-
msgid "You must enter a valid role name."
|
266 |
-
msgstr ""
|
267 |
-
|
268 |
-
#: admin/class-role-new.php:308
|
269 |
-
msgid "Clone Role"
|
270 |
-
msgstr ""
|
271 |
-
|
272 |
-
#: admin/class-role-new.php:326
|
273 |
-
msgid "%s Clone"
|
274 |
-
msgstr ""
|
275 |
-
|
276 |
-
#: admin/class-role-new.php:326
|
277 |
-
msgid "Enter role name"
|
278 |
-
msgstr ""
|
279 |
-
|
280 |
-
#: admin/class-roles.php:68
|
281 |
-
msgid "Granted"
|
282 |
-
msgstr ""
|
283 |
-
|
284 |
-
#: admin/class-roles.php:69
|
285 |
-
msgid "Denied"
|
286 |
-
msgstr ""
|
287 |
-
|
288 |
-
#: admin/class-roles.php:110
|
289 |
-
msgid "Selected roles deleted."
|
290 |
-
msgstr ""
|
291 |
-
|
292 |
-
#: admin/class-roles.php:129
|
293 |
-
msgid "%s role deleted."
|
294 |
-
msgstr ""
|
295 |
-
|
296 |
-
#: admin/class-roles.php:208 admin/functions-help.php:46
|
297 |
-
msgid "Overview"
|
298 |
-
msgstr ""
|
299 |
-
|
300 |
-
#: admin/class-roles.php:217
|
301 |
-
msgid "Screen Content"
|
302 |
-
msgstr ""
|
303 |
-
|
304 |
-
#: admin/class-roles.php:226
|
305 |
-
msgid "Available Actions"
|
306 |
-
msgstr ""
|
307 |
-
|
308 |
-
#: admin/class-roles.php:235
|
309 |
-
msgid "Bulk Actions"
|
310 |
-
msgstr ""
|
311 |
-
|
312 |
-
#: admin/class-roles.php:254
|
313 |
-
msgid "This screen provides access to all of your user roles. Roles are a method of grouping users. They are made up of capabilities (caps), which give permission to users to perform specific actions on the site."
|
314 |
-
msgstr ""
|
315 |
-
|
316 |
-
#: admin/class-roles.php:268
|
317 |
-
msgid "You can customize the display of this screen‘s contents in a number of ways:"
|
318 |
-
msgstr ""
|
319 |
-
|
320 |
-
#: admin/class-roles.php:272
|
321 |
-
msgid "You can hide/display columns based on your needs and decide how many roles to list per screen using the Screen Options tab."
|
322 |
-
msgstr ""
|
323 |
-
|
324 |
-
#: admin/class-roles.php:273
|
325 |
-
msgid "You can filter the list of roles by types using the text links in the upper left. The default view is to show all roles."
|
326 |
-
msgstr ""
|
327 |
-
|
328 |
-
#: admin/class-roles.php:287
|
329 |
-
msgid "Hovering over a row in the roles list will display action links that allow you to manage your role. You can perform the following actions:"
|
330 |
-
msgstr ""
|
331 |
-
|
332 |
-
#: admin/class-roles.php:291
|
333 |
-
msgid "<strong>Edit</strong> takes you to the editing screen for that role. You can also reach that screen by clicking on the role name."
|
334 |
-
msgstr ""
|
335 |
-
|
336 |
-
#: admin/class-roles.php:292
|
337 |
-
msgid "<strong>Delete</strong> removes your role from this list and permanently deletes it."
|
338 |
-
msgstr ""
|
339 |
-
|
340 |
-
#: admin/class-roles.php:293
|
341 |
-
msgid "<strong>Clone</strong> copies the role and takes you to the new role screen to further edit it."
|
342 |
-
msgstr ""
|
343 |
-
|
344 |
-
#: admin/class-roles.php:294
|
345 |
-
msgid "<strong>Users</strong> takes you to the users screen and lists the users that have that role."
|
346 |
-
msgstr ""
|
347 |
-
|
348 |
-
#: admin/class-roles.php:308
|
349 |
-
msgid "You can permanently delete multiple roles at once. Select the roles you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply."
|
350 |
-
msgstr ""
|
351 |
-
|
352 |
-
#: admin/class-settings.php:70 admin/class-settings.php:362
|
353 |
-
msgid "Members Settings"
|
354 |
-
msgstr ""
|
355 |
-
|
356 |
-
#: admin/class-settings.php:71
|
357 |
-
msgctxt "admin screen"
|
358 |
-
msgid "Members"
|
359 |
-
msgstr ""
|
360 |
-
|
361 |
-
#: admin/class-settings.php:124
|
362 |
-
msgid "Roles and Capabilities"
|
363 |
-
msgstr ""
|
364 |
-
|
365 |
-
#: admin/class-settings.php:126 admin/class-settings.php:407
|
366 |
-
msgid "Sidebar Widgets"
|
367 |
-
msgstr ""
|
368 |
-
|
369 |
-
#: admin/class-settings.php:127 admin/class-settings.php:416
|
370 |
-
msgid "Private Site"
|
371 |
-
msgstr ""
|
372 |
-
|
373 |
-
#: admin/class-settings.php:132
|
374 |
-
msgid "Role Manager"
|
375 |
-
msgstr ""
|
376 |
-
|
377 |
-
#: admin/class-settings.php:134
|
378 |
-
msgid "Multiple User Roles"
|
379 |
-
msgstr ""
|
380 |
-
|
381 |
-
#: admin/class-settings.php:137
|
382 |
-
msgid "Enable Permissions"
|
383 |
-
msgstr ""
|
384 |
-
|
385 |
-
#: admin/class-settings.php:138
|
386 |
-
msgid "Error Message"
|
387 |
-
msgstr ""
|
388 |
-
|
389 |
-
#: admin/class-settings.php:141
|
390 |
-
msgid "Login Widget"
|
391 |
-
msgstr ""
|
392 |
-
|
393 |
-
#: admin/class-settings.php:142
|
394 |
-
msgid "Users Widget"
|
395 |
-
msgstr ""
|
396 |
-
|
397 |
-
#: admin/class-settings.php:145
|
398 |
-
msgid "Enable Private Site"
|
399 |
-
msgstr ""
|
400 |
-
|
401 |
-
#: admin/class-settings.php:146
|
402 |
-
msgid "Disable Feed"
|
403 |
-
msgstr ""
|
404 |
-
|
405 |
-
#: admin/class-settings.php:147
|
406 |
-
msgid "Feed Error Message"
|
407 |
-
msgstr ""
|
408 |
-
|
409 |
-
#: admin/class-settings.php:188
|
410 |
-
msgid "Your roles and capabilities will not revert back to their previous settings after deactivating or uninstalling this plugin, so use this feature wisely."
|
411 |
-
msgstr ""
|
412 |
-
|
413 |
-
#: admin/class-settings.php:203
|
414 |
-
msgid "Enable the role manager."
|
415 |
-
msgstr ""
|
416 |
-
|
417 |
-
#: admin/class-settings.php:218
|
418 |
-
msgid "Denied capabilities should always overrule granted capabilities."
|
419 |
-
msgstr ""
|
420 |
-
|
421 |
-
#: admin/class-settings.php:233
|
422 |
-
msgid "Allow users to be assigned more than a single role."
|
423 |
-
msgstr ""
|
424 |
-
|
425 |
-
#: admin/class-settings.php:248
|
426 |
-
msgid "Enable the content permissions feature."
|
427 |
-
msgstr ""
|
428 |
-
|
429 |
-
#: admin/class-settings.php:283
|
430 |
-
msgid "Enable the login form widget."
|
431 |
-
msgstr ""
|
432 |
-
|
433 |
-
#: admin/class-settings.php:298
|
434 |
-
msgid "Enable the users widget."
|
435 |
-
msgstr ""
|
436 |
-
|
437 |
-
#: admin/class-settings.php:313
|
438 |
-
msgid "Redirect all logged-out users to the login page before allowing them to view the site."
|
439 |
-
msgstr ""
|
440 |
-
|
441 |
-
#: admin/class-settings.php:328
|
442 |
-
msgid "Show error message for feed items."
|
443 |
-
msgstr ""
|
444 |
-
|
445 |
-
#: admin/class-settings.php:367
|
446 |
-
msgid "Update Settings"
|
447 |
-
msgstr ""
|
448 |
-
|
449 |
-
#: admin/class-settings.php:389
|
450 |
-
msgid "Role and Capabilities"
|
451 |
-
msgstr ""
|
452 |
-
|
453 |
-
#: admin/class-settings.php:422 admin/functions-help.php:23
|
454 |
-
msgid "Documentation"
|
455 |
-
msgstr ""
|
456 |
-
|
457 |
-
#: admin/class-settings.php:423 admin/functions-help.php:24
|
458 |
-
msgid "Support Forums"
|
459 |
-
msgstr ""
|
460 |
-
|
461 |
-
#: admin/class-settings.php:424
|
462 |
-
msgid "Users, Roles, and Capabilities"
|
463 |
-
msgstr ""
|
464 |
-
|
465 |
-
#: admin/class-settings.php:440
|
466 |
-
msgid "The role manager allows you to manage roles on your site by giving you the ability to create, edit, and delete any role. Note that changes to roles do not change settings for the Members plugin. You are literally changing data in your WordPress database. This plugin feature merely provides an interface for you to make these changes."
|
467 |
-
msgstr ""
|
468 |
-
|
469 |
-
#: admin/class-settings.php:444
|
470 |
-
msgid "Tick the checkbox for denied capabilities to always take precedence over granted capabilities when there is a conflict. This is only relevant when using multiple roles per user."
|
471 |
-
msgstr ""
|
472 |
-
|
473 |
-
#: admin/class-settings.php:448
|
474 |
-
msgid "The multiple user roles feature allows you to assign more than one role to each user from the edit user screen."
|
475 |
-
msgstr ""
|
476 |
-
|
477 |
-
#: admin/class-settings.php:462
|
478 |
-
msgid "The content permissions features adds a meta box to the edit post screen that allows you to grant permissions for who can read the post content based on the user's role. Only users of roles with the %s capability will be able to use this component."
|
479 |
-
msgstr ""
|
480 |
-
|
481 |
-
#: admin/class-settings.php:476
|
482 |
-
msgid "The sidebar widgets feature adds additional widgets for use in your theme's sidebars."
|
483 |
-
msgstr ""
|
484 |
-
|
485 |
-
#: admin/class-settings.php:490
|
486 |
-
msgid "The private site feature redirects all users who are not logged into the site to the login page, creating an entirely private site. You may also replace your feed content with a custom error message."
|
487 |
-
msgstr ""
|
488 |
-
|
489 |
-
#: admin/class-user-edit.php:92
|
490 |
-
msgid "User Roles"
|
491 |
-
msgstr ""
|
492 |
-
|
493 |
-
#: admin/functions-admin.php:50
|
494 |
-
msgid "OK"
|
495 |
-
msgstr ""
|
496 |
-
|
497 |
-
#: admin/functions-admin.php:53
|
498 |
-
msgid "Are you sure you want to delete this role? This is a permanent action and cannot be undone."
|
499 |
-
msgstr ""
|
500 |
-
|
501 |
-
#: admin/functions-admin.php:180
|
502 |
-
msgid "None"
|
503 |
-
msgstr ""
|
504 |
-
|
505 |
-
#: admin/functions-cap-groups.php:106
|
506 |
-
msgid "All"
|
507 |
-
msgstr ""
|
508 |
-
|
509 |
-
#: admin/functions-cap-groups.php:116
|
510 |
-
msgid "General"
|
511 |
-
msgstr ""
|
512 |
-
|
513 |
-
#: admin/functions-cap-groups.php:165
|
514 |
-
msgid "Taxonomies"
|
515 |
-
msgstr ""
|
516 |
-
|
517 |
-
#: admin/functions-cap-groups.php:175
|
518 |
-
msgid "Appearance"
|
519 |
-
msgstr ""
|
520 |
-
|
521 |
-
#: admin/functions-cap-groups.php:184
|
522 |
-
msgid "Plugins"
|
523 |
-
msgstr ""
|
524 |
-
|
525 |
-
#: admin/functions-cap-groups.php:202
|
526 |
-
msgid "Custom"
|
527 |
-
msgstr ""
|
528 |
-
|
529 |
-
#: admin/functions-help.php:29
|
530 |
-
msgid "For more information:"
|
531 |
-
msgstr ""
|
532 |
-
|
533 |
-
#: admin/functions-help.php:78
|
534 |
-
msgid "Edit Capabilities"
|
535 |
-
msgstr ""
|
536 |
-
|
537 |
-
#: admin/functions-help.php:109
|
538 |
-
msgid "This screen allows you to edit an individual role and its capabilities."
|
539 |
-
msgstr ""
|
540 |
-
|
541 |
-
#: admin/functions-help.php:123
|
542 |
-
msgid "The role name field allows you to enter a human-readable name for your role."
|
543 |
-
msgstr ""
|
544 |
-
|
545 |
-
#: admin/functions-help.php:127
|
546 |
-
msgid "The machine-readable version of the role appears below the name field, which you can edit. This can only have lowercase letters, numbers, or underscores."
|
547 |
-
msgstr ""
|
548 |
-
|
549 |
-
#: admin/functions-help.php:141
|
550 |
-
msgid "The capabilities edit box is made up of tabs that separate capabilities into groups. You may take the following actions for each capability:"
|
551 |
-
msgstr ""
|
552 |
-
|
553 |
-
#: admin/functions-help.php:145
|
554 |
-
msgid "<strong>Grant</strong> allows you to grant the role a capability."
|
555 |
-
msgstr ""
|
556 |
-
|
557 |
-
#: admin/functions-help.php:146
|
558 |
-
msgid "<strong>Deny</strong> allows you to explicitly deny the role a capability."
|
559 |
-
msgstr ""
|
560 |
-
|
561 |
-
#: admin/functions-help.php:147
|
562 |
-
msgid "You may also opt to neither grant nor deny the role a capability."
|
563 |
-
msgstr ""
|
564 |
-
|
565 |
-
#: admin/functions-help.php:161
|
566 |
-
msgid "The custom capability box allows you to create a custom capability for the role. After hitting the Add New button, it will add the capability to the Custom tab in the Edit Capabilities box."
|
567 |
-
msgstr ""
|
568 |
-
|
569 |
-
#: admin/functions-role-groups.php:111
|
570 |
-
msgid "Mine"
|
571 |
-
msgstr ""
|
572 |
-
|
573 |
-
#: admin/functions-role-groups.php:121
|
574 |
-
msgid "Has Users"
|
575 |
-
msgstr ""
|
576 |
-
|
577 |
-
#: admin/functions-role-groups.php:122
|
578 |
-
msgid "Has Users %s"
|
579 |
-
msgid_plural "Has Users %s"
|
580 |
-
msgstr[0] ""
|
581 |
-
msgstr[1] ""
|
582 |
-
|
583 |
-
#: admin/functions-role-groups.php:130
|
584 |
-
msgid "No Users"
|
585 |
-
msgstr ""
|
586 |
-
|
587 |
-
#: admin/functions-role-groups.php:131
|
588 |
-
msgid "No Users %s"
|
589 |
-
msgid_plural "No Users %s"
|
590 |
-
msgstr[0] ""
|
591 |
-
msgstr[1] ""
|
592 |
-
|
593 |
-
#: admin/functions-role-groups.php:139
|
594 |
-
msgid "Editable"
|
595 |
-
msgstr ""
|
596 |
-
|
597 |
-
#: admin/functions-role-groups.php:140
|
598 |
-
msgid "Editable %s"
|
599 |
-
msgid_plural "Editable %s"
|
600 |
-
msgstr[0] ""
|
601 |
-
msgstr[1] ""
|
602 |
-
|
603 |
-
#: admin/functions-role-groups.php:148
|
604 |
-
msgid "Uneditable"
|
605 |
-
msgstr ""
|
606 |
-
|
607 |
-
#: admin/functions-role-groups.php:149
|
608 |
-
msgid "Uneditable %s"
|
609 |
-
msgid_plural "Uneditable %s"
|
610 |
-
msgstr[0] ""
|
611 |
-
msgstr[1] ""
|
612 |
-
|
613 |
-
#: admin/functions-role-groups.php:157
|
614 |
-
msgid "WordPress"
|
615 |
-
msgstr ""
|
616 |
-
|
617 |
-
#: admin/tmpl/cap-section.php:20 admin/tmpl/cap-section.php:28
|
618 |
-
msgid "Grant"
|
619 |
-
msgstr ""
|
620 |
-
|
621 |
-
#: admin/tmpl/cap-section.php:21 admin/tmpl/cap-section.php:29
|
622 |
-
msgid "Deny"
|
623 |
-
msgstr ""
|
624 |
-
|
625 |
-
#: inc/class-widget-login.php:42
|
626 |
-
msgid "A widget that allows users to log into your site."
|
627 |
-
msgstr ""
|
628 |
-
|
629 |
-
#: inc/class-widget-login.php:53
|
630 |
-
msgid "Members: Login Form"
|
631 |
-
msgstr ""
|
632 |
-
|
633 |
-
#: inc/class-widget-login.php:57 inc/class-widget-login.php:60
|
634 |
-
msgid "Log In"
|
635 |
-
msgstr ""
|
636 |
-
|
637 |
-
#: inc/class-widget-login.php:58
|
638 |
-
msgid "Username"
|
639 |
-
msgstr ""
|
640 |
-
|
641 |
-
#: inc/class-widget-login.php:59
|
642 |
-
msgid "Password"
|
643 |
-
msgstr ""
|
644 |
-
|
645 |
-
#: inc/class-widget-login.php:61
|
646 |
-
msgid "Remember Me"
|
647 |
-
msgstr ""
|
648 |
-
|
649 |
-
#: inc/class-widget-login.php:71
|
650 |
-
msgid "Please log into the site."
|
651 |
-
msgstr ""
|
652 |
-
|
653 |
-
#: inc/class-widget-login.php:72
|
654 |
-
msgid "You are currently logged in."
|
655 |
-
msgstr ""
|
656 |
-
|
657 |
-
#: inc/class-widget-login.php:207 inc/class-widget-users.php:207
|
658 |
-
msgid "Title:"
|
659 |
-
msgstr ""
|
660 |
-
|
661 |
-
#: inc/class-widget-login.php:211
|
662 |
-
msgid "Username Label:"
|
663 |
-
msgstr ""
|
664 |
-
|
665 |
-
#: inc/class-widget-login.php:215
|
666 |
-
msgid "Password Label:"
|
667 |
-
msgstr ""
|
668 |
-
|
669 |
-
#: inc/class-widget-login.php:219
|
670 |
-
msgid "Log In Label:"
|
671 |
-
msgstr ""
|
672 |
-
|
673 |
-
#: inc/class-widget-login.php:223
|
674 |
-
msgid "Remember Me Label:"
|
675 |
-
msgstr ""
|
676 |
-
|
677 |
-
#: inc/class-widget-login.php:231
|
678 |
-
msgid "Username Value:"
|
679 |
-
msgstr ""
|
680 |
-
|
681 |
-
#: inc/class-widget-login.php:235
|
682 |
-
msgid "Username Field ID:"
|
683 |
-
msgstr ""
|
684 |
-
|
685 |
-
#: inc/class-widget-login.php:239
|
686 |
-
msgid "Remember Me Field ID:"
|
687 |
-
msgstr ""
|
688 |
-
|
689 |
-
#: inc/class-widget-login.php:243
|
690 |
-
msgid "Password Field ID:"
|
691 |
-
msgstr ""
|
692 |
-
|
693 |
-
#: inc/class-widget-login.php:247
|
694 |
-
msgid "Submit Button ID:"
|
695 |
-
msgstr ""
|
696 |
-
|
697 |
-
#: inc/class-widget-login.php:258
|
698 |
-
msgid "\"Remember me\" checkbox?"
|
699 |
-
msgstr ""
|
700 |
-
|
701 |
-
#: inc/class-widget-login.php:264
|
702 |
-
msgid "Check \"remember me\"?"
|
703 |
-
msgstr ""
|
704 |
-
|
705 |
-
#: inc/class-widget-login.php:270
|
706 |
-
msgid "Display avatar?"
|
707 |
-
msgstr ""
|
708 |
-
|
709 |
-
#: inc/class-widget-login.php:274
|
710 |
-
msgid "Logged out text:"
|
711 |
-
msgstr ""
|
712 |
-
|
713 |
-
#: inc/class-widget-login.php:279
|
714 |
-
msgid "Logged in text:"
|
715 |
-
msgstr ""
|
716 |
-
|
717 |
-
#: inc/class-widget-users.php:42
|
718 |
-
msgid "Provides the ability to list the users of the site."
|
719 |
-
msgstr ""
|
720 |
-
|
721 |
-
#: inc/class-widget-users.php:53
|
722 |
-
msgid "Members: Users"
|
723 |
-
msgstr ""
|
724 |
-
|
725 |
-
#: inc/class-widget-users.php:183
|
726 |
-
msgid "Ascending"
|
727 |
-
msgstr ""
|
728 |
-
|
729 |
-
#: inc/class-widget-users.php:184
|
730 |
-
msgid "Descending"
|
731 |
-
msgstr ""
|
732 |
-
|
733 |
-
#: inc/class-widget-users.php:188
|
734 |
-
msgid "Display Name"
|
735 |
-
msgstr ""
|
736 |
-
|
737 |
-
#: inc/class-widget-users.php:189
|
738 |
-
msgid "Email"
|
739 |
-
msgstr ""
|
740 |
-
|
741 |
-
#: inc/class-widget-users.php:190
|
742 |
-
msgid "ID"
|
743 |
-
msgstr ""
|
744 |
-
|
745 |
-
#: inc/class-widget-users.php:191
|
746 |
-
msgid "Nice Name"
|
747 |
-
msgstr ""
|
748 |
-
|
749 |
-
#: inc/class-widget-users.php:192
|
750 |
-
msgid "Post Count"
|
751 |
-
msgstr ""
|
752 |
-
|
753 |
-
#: inc/class-widget-users.php:193
|
754 |
-
msgid "Registered"
|
755 |
-
msgstr ""
|
756 |
-
|
757 |
-
#: inc/class-widget-users.php:194
|
758 |
-
msgid "URL"
|
759 |
-
msgstr ""
|
760 |
-
|
761 |
-
#: inc/class-widget-users.php:195
|
762 |
-
msgid "Login"
|
763 |
-
msgstr ""
|
764 |
-
|
765 |
-
#: inc/class-widget-users.php:211
|
766 |
-
msgid "Order By:"
|
767 |
-
msgstr ""
|
768 |
-
|
769 |
-
#: inc/class-widget-users.php:219
|
770 |
-
msgid "Order:"
|
771 |
-
msgstr ""
|
772 |
-
|
773 |
-
#: inc/class-widget-users.php:235
|
774 |
-
msgid "Limit:"
|
775 |
-
msgstr ""
|
776 |
-
|
777 |
-
#: inc/class-widget-users.php:239
|
778 |
-
msgid "Offset:"
|
779 |
-
msgstr ""
|
780 |
-
|
781 |
-
#: inc/class-widget-users.php:247
|
782 |
-
msgid "Include:"
|
783 |
-
msgstr ""
|
784 |
-
|
785 |
-
#: inc/class-widget-users.php:251
|
786 |
-
msgid "Exclude:"
|
787 |
-
msgstr ""
|
788 |
-
|
789 |
-
#: inc/class-widget-users.php:255
|
790 |
-
msgid "Search:"
|
791 |
-
msgstr ""
|
792 |
-
|
793 |
-
#: inc/class-widget-users.php:259
|
794 |
-
msgid "Meta Key:"
|
795 |
-
msgstr ""
|
796 |
-
|
797 |
-
#: inc/class-widget-users.php:267
|
798 |
-
msgid "Meta Value:"
|
799 |
-
msgstr ""
|
800 |
-
|
801 |
-
#: inc/functions-options.php:116
|
802 |
-
msgid "Sorry, but you do not have permission to view this content."
|
803 |
-
msgstr ""
|
804 |
-
|
805 |
-
#: inc/functions-options.php:117
|
806 |
-
msgid "You must be logged into the site to view this content."
|
807 |
-
msgstr ""
|
808 |
-
|
809 |
-
#: members.php:187
|
810 |
-
msgid "Method does not exist."
|
811 |
-
msgstr ""
|
812 |
-
#. Plugin Name of the plugin/theme
|
813 |
-
msgid "Members"
|
814 |
-
msgstr ""
|
815 |
-
|
816 |
-
#. Plugin URI of the plugin/theme
|
817 |
-
msgid "http://themehybrid.com/plugins/members"
|
818 |
-
msgstr ""
|
819 |
-
|
820 |
-
#. Description of the plugin/theme
|
821 |
-
msgid "A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private."
|
822 |
-
msgstr ""
|
823 |
-
|
824 |
-
#. Author of the plugin/theme
|
825 |
-
msgid "Justin Tadlock"
|
826 |
-
msgstr ""
|
827 |
-
|
828 |
-
#. Author URI of the plugin/theme
|
829 |
-
msgid "http://themehybrid.com"
|
830 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
members.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Members
|
4 |
-
* Plugin URI:
|
5 |
* Description: A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private.
|
6 |
-
* Version:
|
7 |
* Author: Justin Tadlock
|
8 |
-
* Author URI:
|
9 |
* Text Domain: members
|
10 |
* Domain Path: /languages
|
11 |
*
|
@@ -25,10 +25,10 @@
|
|
25 |
* write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*
|
27 |
* @package Members
|
28 |
-
* @version
|
29 |
-
* @author Justin Tadlock <
|
30 |
-
* @copyright Copyright (c) 2009 -
|
31 |
-
* @link
|
32 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
33 |
*/
|
34 |
|
@@ -41,67 +41,31 @@
|
|
41 |
final class Members_Plugin {
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @since 1.0.0
|
47 |
-
* @access public
|
48 |
-
* @var string
|
49 |
-
*/
|
50 |
-
public $dir_path = '';
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Plugin directory URI.
|
54 |
-
*
|
55 |
-
* @since 1.0.0
|
56 |
-
* @access public
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
public $dir_uri = '';
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Plugin admin directory path.
|
63 |
-
*
|
64 |
-
* @since 1.0.0
|
65 |
-
* @access public
|
66 |
-
* @var string
|
67 |
-
*/
|
68 |
-
public $admin_dir = '';
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Plugin includes directory path.
|
72 |
-
*
|
73 |
-
* @since 1.0.0
|
74 |
-
* @access public
|
75 |
-
* @var string
|
76 |
-
*/
|
77 |
-
public $inc_dir = '';
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Plugin templates directory path.
|
81 |
*
|
82 |
-
* @since
|
83 |
* @access public
|
84 |
* @var string
|
85 |
*/
|
86 |
-
|
87 |
|
88 |
/**
|
89 |
-
* Plugin
|
90 |
*
|
91 |
-
* @since
|
92 |
* @access public
|
93 |
* @var string
|
94 |
*/
|
95 |
-
public $
|
96 |
|
97 |
/**
|
98 |
-
* Plugin
|
99 |
*
|
100 |
-
* @since
|
101 |
* @access public
|
102 |
* @var string
|
103 |
*/
|
104 |
-
public $
|
105 |
|
106 |
/**
|
107 |
* User count of all roles.
|
@@ -125,7 +89,7 @@ final class Members_Plugin {
|
|
125 |
static $instance = null;
|
126 |
|
127 |
if ( is_null( $instance ) ) {
|
128 |
-
$instance = new
|
129 |
$instance->setup();
|
130 |
$instance->includes();
|
131 |
$instance->setup_actions();
|
@@ -193,90 +157,80 @@ final class Members_Plugin {
|
|
193 |
* Sets up globals.
|
194 |
*
|
195 |
* @since 1.0.0
|
196 |
-
* @access
|
197 |
* @return void
|
198 |
*/
|
199 |
private function setup() {
|
200 |
|
201 |
// Main plugin directory path and URI.
|
202 |
-
$this->
|
203 |
-
$this->
|
204 |
-
|
205 |
-
// Plugin directory paths.
|
206 |
-
$this->inc_dir = trailingslashit( $this->dir_path . 'inc' );
|
207 |
-
$this->admin_dir = trailingslashit( $this->dir_path . 'admin' );
|
208 |
-
$this->templates_dir = trailingslashit( $this->dir_path . 'templates' );
|
209 |
-
|
210 |
-
// Plugin directory URIs.
|
211 |
-
$this->css_uri = trailingslashit( $this->dir_uri . 'css' );
|
212 |
-
$this->js_uri = trailingslashit( $this->dir_uri . 'js' );
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
* Loads files needed by the plugin.
|
217 |
*
|
218 |
* @since 1.0.0
|
219 |
-
* @access
|
220 |
* @return void
|
221 |
*/
|
222 |
private function includes() {
|
223 |
|
224 |
// Load class files.
|
225 |
-
require_once( $this->
|
226 |
-
require_once( $this->
|
|
|
|
|
|
|
227 |
|
228 |
// Load includes files.
|
229 |
-
require_once( $this->
|
230 |
-
require_once( $this->
|
231 |
-
require_once( $this->
|
232 |
-
require_once( $this->
|
233 |
-
require_once( $this->
|
234 |
-
require_once( $this->
|
235 |
-
require_once( $this->
|
236 |
-
require_once( $this->
|
237 |
-
require_once( $this->
|
238 |
-
require_once( $this->
|
239 |
-
require_once( $this->
|
|
|
|
|
240 |
|
241 |
// Load template files.
|
242 |
-
require_once( $this->
|
243 |
|
244 |
// Load admin files.
|
245 |
if ( is_admin() ) {
|
246 |
|
247 |
// General admin functions.
|
248 |
-
require_once( $this->
|
249 |
-
require_once( $this->
|
250 |
|
251 |
// Plugin settings.
|
252 |
-
require_once( $this->
|
253 |
|
254 |
-
//
|
255 |
-
require_once( $this->
|
|
|
|
|
256 |
|
257 |
// Edit posts.
|
258 |
-
require_once( $this->
|
259 |
|
260 |
// Role management.
|
261 |
-
require_once( $this->
|
262 |
-
require_once( $this->
|
263 |
-
require_once( $this->
|
264 |
-
require_once( $this->
|
265 |
-
require_once( $this->
|
266 |
-
require_once( $this->
|
267 |
-
|
268 |
-
// Role groups.
|
269 |
-
require_once( $this->admin_dir . 'class-role-group.php' );
|
270 |
-
require_once( $this->admin_dir . 'class-role-group-factory.php' );
|
271 |
-
require_once( $this->admin_dir . 'functions-role-groups.php' );
|
272 |
|
273 |
// Edit capabilities tabs and groups.
|
274 |
-
require_once( $this->
|
275 |
-
require_once( $this->
|
276 |
-
require_once( $this->
|
277 |
-
require_once( $this->admin_dir . 'class-cap-group.php' );
|
278 |
-
require_once( $this->admin_dir . 'class-cap-group-factory.php' );
|
279 |
-
require_once( $this->admin_dir . 'functions-cap-groups.php' );
|
280 |
}
|
281 |
}
|
282 |
|
@@ -284,7 +238,7 @@ final class Members_Plugin {
|
|
284 |
* Sets up main plugin actions and filters.
|
285 |
*
|
286 |
* @since 1.0.0
|
287 |
-
* @access
|
288 |
* @return void
|
289 |
*/
|
290 |
private function setup_actions() {
|
@@ -304,7 +258,8 @@ final class Members_Plugin {
|
|
304 |
* @return void
|
305 |
*/
|
306 |
public function i18n() {
|
307 |
-
|
|
|
308 |
}
|
309 |
|
310 |
/**
|
@@ -316,6 +271,20 @@ final class Members_Plugin {
|
|
316 |
*/
|
317 |
public function activation() {
|
318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
// Get the administrator role.
|
320 |
$role = get_role( 'administrator' );
|
321 |
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Members
|
4 |
+
* Plugin URI: https://themehybrid.com/plugins/members
|
5 |
* Description: A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private.
|
6 |
+
* Version: 2.0.0
|
7 |
* Author: Justin Tadlock
|
8 |
+
* Author URI: https://themehybrid.com
|
9 |
* Text Domain: members
|
10 |
* Domain Path: /languages
|
11 |
*
|
25 |
* write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*
|
27 |
* @package Members
|
28 |
+
* @version 2.0.0
|
29 |
+
* @author Justin Tadlock <justintadlock@gmail.com>
|
30 |
+
* @copyright Copyright (c) 2009 - 2017, Justin Tadlock
|
31 |
+
* @link https://themehybrid.com/plugins/members
|
32 |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
33 |
*/
|
34 |
|
41 |
final class Members_Plugin {
|
42 |
|
43 |
/**
|
44 |
+
* Minimum required PHP version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
*
|
46 |
+
* @since 2.0.0
|
47 |
* @access public
|
48 |
* @var string
|
49 |
*/
|
50 |
+
private $php_version = '5.3.0';
|
51 |
|
52 |
/**
|
53 |
+
* Plugin directory path.
|
54 |
*
|
55 |
+
* @since 2.0.0
|
56 |
* @access public
|
57 |
* @var string
|
58 |
*/
|
59 |
+
public $dir = '';
|
60 |
|
61 |
/**
|
62 |
+
* Plugin directory URI.
|
63 |
*
|
64 |
+
* @since 2.0.0
|
65 |
* @access public
|
66 |
* @var string
|
67 |
*/
|
68 |
+
public $uri = '';
|
69 |
|
70 |
/**
|
71 |
* User count of all roles.
|
89 |
static $instance = null;
|
90 |
|
91 |
if ( is_null( $instance ) ) {
|
92 |
+
$instance = new self;
|
93 |
$instance->setup();
|
94 |
$instance->includes();
|
95 |
$instance->setup_actions();
|
157 |
* Sets up globals.
|
158 |
*
|
159 |
* @since 1.0.0
|
160 |
+
* @access private
|
161 |
* @return void
|
162 |
*/
|
163 |
private function setup() {
|
164 |
|
165 |
// Main plugin directory path and URI.
|
166 |
+
$this->dir = trailingslashit( plugin_dir_path( __FILE__ ) );
|
167 |
+
$this->uri = trailingslashit( plugin_dir_url( __FILE__ ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
|
170 |
/**
|
171 |
* Loads files needed by the plugin.
|
172 |
*
|
173 |
* @since 1.0.0
|
174 |
+
* @access private
|
175 |
* @return void
|
176 |
*/
|
177 |
private function includes() {
|
178 |
|
179 |
// Load class files.
|
180 |
+
require_once( $this->dir . 'inc/class-capability.php' );
|
181 |
+
require_once( $this->dir . 'inc/class-cap-group.php' );
|
182 |
+
require_once( $this->dir . 'inc/class-registry.php' );
|
183 |
+
require_once( $this->dir . 'inc/class-role-group.php' );
|
184 |
+
require_once( $this->dir . 'inc/class-role.php' );
|
185 |
|
186 |
// Load includes files.
|
187 |
+
require_once( $this->dir . 'inc/functions.php' );
|
188 |
+
require_once( $this->dir . 'inc/functions-admin-bar.php' );
|
189 |
+
require_once( $this->dir . 'inc/functions-capabilities.php' );
|
190 |
+
require_once( $this->dir . 'inc/functions-cap-groups.php' );
|
191 |
+
require_once( $this->dir . 'inc/functions-content-permissions.php' );
|
192 |
+
require_once( $this->dir . 'inc/functions-deprecated.php' );
|
193 |
+
require_once( $this->dir . 'inc/functions-options.php' );
|
194 |
+
require_once( $this->dir . 'inc/functions-private-site.php' );
|
195 |
+
require_once( $this->dir . 'inc/functions-roles.php' );
|
196 |
+
require_once( $this->dir . 'inc/functions-role-groups.php' );
|
197 |
+
require_once( $this->dir . 'inc/functions-shortcodes.php' );
|
198 |
+
require_once( $this->dir . 'inc/functions-users.php' );
|
199 |
+
require_once( $this->dir . 'inc/functions-widgets.php' );
|
200 |
|
201 |
// Load template files.
|
202 |
+
require_once( $this->dir . 'inc/template.php' );
|
203 |
|
204 |
// Load admin files.
|
205 |
if ( is_admin() ) {
|
206 |
|
207 |
// General admin functions.
|
208 |
+
require_once( $this->dir . 'admin/functions-admin.php' );
|
209 |
+
require_once( $this->dir . 'admin/functions-help.php' );
|
210 |
|
211 |
// Plugin settings.
|
212 |
+
require_once( $this->dir . 'admin/class-settings.php' );
|
213 |
|
214 |
+
// User management.
|
215 |
+
require_once( $this->dir . 'admin/class-manage-users.php' );
|
216 |
+
require_once( $this->dir . 'admin/class-user-edit.php' );
|
217 |
+
require_once( $this->dir . 'admin/class-user-new.php' );
|
218 |
|
219 |
// Edit posts.
|
220 |
+
require_once( $this->dir . 'admin/class-meta-box-content-permissions.php' );
|
221 |
|
222 |
// Role management.
|
223 |
+
require_once( $this->dir . 'admin/class-manage-roles.php' );
|
224 |
+
require_once( $this->dir . 'admin/class-roles.php' );
|
225 |
+
require_once( $this->dir . 'admin/class-role-edit.php' );
|
226 |
+
require_once( $this->dir . 'admin/class-role-new.php' );
|
227 |
+
require_once( $this->dir . 'admin/class-meta-box-publish-role.php' );
|
228 |
+
require_once( $this->dir . 'admin/class-meta-box-custom-cap.php' );
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
// Edit capabilities tabs and groups.
|
231 |
+
require_once( $this->dir . 'admin/class-cap-tabs.php' );
|
232 |
+
require_once( $this->dir . 'admin/class-cap-section.php' );
|
233 |
+
require_once( $this->dir . 'admin/class-cap-control.php' );
|
|
|
|
|
|
|
234 |
}
|
235 |
}
|
236 |
|
238 |
* Sets up main plugin actions and filters.
|
239 |
*
|
240 |
* @since 1.0.0
|
241 |
+
* @access private
|
242 |
* @return void
|
243 |
*/
|
244 |
private function setup_actions() {
|
258 |
* @return void
|
259 |
*/
|
260 |
public function i18n() {
|
261 |
+
|
262 |
+
load_plugin_textdomain( 'members', false, trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . 'lang' );
|
263 |
}
|
264 |
|
265 |
/**
|
271 |
*/
|
272 |
public function activation() {
|
273 |
|
274 |
+
// Check PHP version requirements.
|
275 |
+
if ( version_compare( PHP_VERSION, $this->php_version, '<' ) ) {
|
276 |
+
|
277 |
+
// Make sure the plugin is deactivated.
|
278 |
+
deactivate_plugins( plugin_basename( __FILE__ ) );
|
279 |
+
|
280 |
+
// Add an error message and die.
|
281 |
+
wp_die( sprintf(
|
282 |
+
__( 'Members requires PHP version %1$s. You are running version %2$s. Please upgrade and try again.', 'members' ),
|
283 |
+
$this->php_version,
|
284 |
+
PHP_VERSION
|
285 |
+
) );
|
286 |
+
}
|
287 |
+
|
288 |
// Get the administrator role.
|
289 |
$role = get_role( 'administrator' );
|
290 |
|
readme.md
CHANGED
@@ -17,13 +17,13 @@ It puts you in control over permissions on your site by providing a user interfa
|
|
17 |
|
18 |
## Professional Support
|
19 |
|
20 |
-
If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](
|
21 |
|
22 |
## Copyright and License
|
23 |
|
24 |
This project is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
|
25 |
|
26 |
-
2009 – 
|
27 |
|
28 |
## Documentation
|
29 |
|
@@ -75,7 +75,9 @@ Every capability can have one of three "states" for a role. The role can be *gr
|
|
75 |
|
76 |
You can assign a user more than one role by going to that edit user screen in the admin and locating the "Roles" section. There will be a checkbox for every role.
|
77 |
|
78 |
-
|
|
|
|
|
79 |
|
80 |
### Content permissions feature
|
81 |
|
@@ -101,12 +103,17 @@ The `[members_access]` shortcode is for hiding content from particular roles and
|
|
101 |
|
102 |
* `capability`: A capability that has been assigned to a role.
|
103 |
* `role`: A user role from WordPress or one that you've created.
|
|
|
104 |
|
105 |
Note that `capability` and `role` parameters aren't used in conjunction. The code first checks for the capability (if input) then checks for the role (if input).
|
106 |
|
107 |
To check for multiple capabilities or multiple roles, simply add a comma between each capability/role. For example, the following code checks for an editor or administrator:
|
108 |
|
109 |
-
[members_access role="administrator,editor"]
|
|
|
|
|
|
|
|
|
110 |
|
111 |
#### [members_logged_in]
|
112 |
|
@@ -116,6 +123,12 @@ The `[members_logged_in]` shortcode should be used to check if a user is current
|
|
116 |
|
117 |
This shortcode has no parameters.
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
#### [members_login_form]
|
120 |
|
121 |
The `[members_login_form]` shortcode is used to show a login form on the page.
|
@@ -173,3 +186,52 @@ Some plugins and themes might rely on the old user level system in WordPress. T
|
|
173 |
By default, the levels aren't shown. They still exist, but are tucked away behind the scenes. While not recommended, if you need to control who has what level (levels are just capabilities), add this to your plugin or your theme's `functions.php`:
|
174 |
|
175 |
add_filter( 'members_remove_old_levels', '__return_false' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
## Professional Support
|
19 |
|
20 |
+
If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](https://themehybrid.com/board/topics), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 75,000+ users (and growing).
|
21 |
|
22 |
## Copyright and License
|
23 |
|
24 |
This project is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
|
25 |
|
26 |
+
2009 – 2017 © [Justin Tadlock](http://justintadlock.com).
|
27 |
|
28 |
## Documentation
|
29 |
|
75 |
|
76 |
You can assign a user more than one role by going to that edit user screen in the admin and locating the "Roles" section. There will be a checkbox for every role.
|
77 |
|
78 |
+
You can also multiple roles to a user from the add new user screen.
|
79 |
+
|
80 |
+
On the "Users" screen in the admin, you can bulk add or remove single roles from multiple users.
|
81 |
|
82 |
### Content permissions feature
|
83 |
|
103 |
|
104 |
* `capability`: A capability that has been assigned to a role.
|
105 |
* `role`: A user role from WordPress or one that you've created.
|
106 |
+
* `operator`: Accepts `!` to negate the role or capability.
|
107 |
|
108 |
Note that `capability` and `role` parameters aren't used in conjunction. The code first checks for the capability (if input) then checks for the role (if input).
|
109 |
|
110 |
To check for multiple capabilities or multiple roles, simply add a comma between each capability/role. For example, the following code checks for an editor or administrator:
|
111 |
|
112 |
+
[members_access role="administrator,editor"]Show this content to administrators or editors only.[/members_access]
|
113 |
+
|
114 |
+
To check that the user does not have a role:
|
115 |
+
|
116 |
+
[members_access role="administrator" operator="!"]Show this content to anyone who is not an administrator.[/members_access]
|
117 |
|
118 |
#### [members_logged_in]
|
119 |
|
123 |
|
124 |
This shortcode has no parameters.
|
125 |
|
126 |
+
##### [members_not_logged_in]
|
127 |
+
|
128 |
+
The `[members_not_logged_in]` shortcode should be used to show content to users who are not logged into the site. If the user is logged in, the content will be hidden.
|
129 |
+
|
130 |
+
[members_not_logged_in]This content is only shown to logged-out visitors.[/members_not_logged_in]
|
131 |
+
|
132 |
#### [members_login_form]
|
133 |
|
134 |
The `[members_login_form]` shortcode is used to show a login form on the page.
|
186 |
By default, the levels aren't shown. They still exist, but are tucked away behind the scenes. While not recommended, if you need to control who has what level (levels are just capabilities), add this to your plugin or your theme's `functions.php`:
|
187 |
|
188 |
add_filter( 'members_remove_old_levels', '__return_false' );
|
189 |
+
|
190 |
+
### Registering capabilities
|
191 |
+
|
192 |
+
If you're a plugin developer with custom capabilities, beginning with version 2.0.0 of Members, you can register your capabilities with Members. Essentially, this allows users to see your capabilities in a nicely-formatted, human-readable form (e.g., `Publish Posts` instead of `publish_posts`). This also means that it can be translated so that it's easier to understand for users who do not read English.
|
193 |
+
|
194 |
+
add_action( 'members_register_caps', 'th_register_caps' );
|
195 |
+
|
196 |
+
function th_register_caps() {
|
197 |
+
|
198 |
+
members_register_cap(
|
199 |
+
'your_cap_name',
|
200 |
+
array(
|
201 |
+
'label' => __( 'Your Capability Label', 'example-textdomain' ),
|
202 |
+
'group' => 'example'
|
203 |
+
)
|
204 |
+
);
|
205 |
+
}
|
206 |
+
|
207 |
+
The `group` argument is not required, but will allow you to assign the capability to a cap group.
|
208 |
+
|
209 |
+
### Registering cap groups
|
210 |
+
|
211 |
+
Members groups capabilities so that users can more easily find them when editing roles. If your plugin has multiple capabilities, you should consider creating a custom cap group.
|
212 |
+
|
213 |
+
add_action( 'members_register_cap_groups', 'th_register_cap_groups' );
|
214 |
+
|
215 |
+
function th_register_cap_groups() {
|
216 |
+
|
217 |
+
members_register_cap_group(
|
218 |
+
'your_group_name',
|
219 |
+
array(
|
220 |
+
'label' => __( 'Your Group Label', 'example-textdomain' ),
|
221 |
+
'caps' => array(),
|
222 |
+
'icon' => 'dashicons-admin-generic',
|
223 |
+
'priority' => 10
|
224 |
+
)
|
225 |
+
);
|
226 |
+
}
|
227 |
+
|
228 |
+
The arguments for the array are:
|
229 |
+
|
230 |
+
* `label` - An internationalized text label for your group.
|
231 |
+
* `caps` - An array of initial capabilities to add to your group.
|
232 |
+
* `icon` - The name of one of core WP's [dashicons](https://developer.wordpress.org/resource/dashicons/) or a custom class (would need to be styled by your plugin in this case).
|
233 |
+
* `priority` - The priority of your group compared to other groups. `10` is the default.
|
234 |
+
|
235 |
+
_Note that custom post types are automatically registered as groups with Members. So, if you want to do something custom with that, you simply need to unregister the group before registering your own._
|
236 |
+
|
237 |
+
members_unregister_cap_group( "type-{$post_type}" );
|
readme.txt
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
=== Members ===
|
2 |
|
3 |
Contributors: greenshady
|
4 |
-
Donate link:
|
5 |
-
Tags:
|
6 |
-
Requires at least: 4.
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag:
|
9 |
|
10 |
The most powerful user, role, and capability management plugin for WordPress.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
Members is a plugin that extends your control over your blog. It's a user, role, and capability
|
15 |
|
16 |
It puts you in control over permissions on your site by providing a user interface (UI) for WordPress' powerful role and cap system, which is traditionally only available to developers who know how to code this by hand.
|
17 |
|
18 |
### Plugin Features
|
19 |
|
20 |
-
* **Role
|
21 |
* **Multiple User Roles:** Give one, two, or even more roles to any user.
|
22 |
* **Explicitly Deny Capabilities:** Deny specific caps to specific user roles.
|
23 |
* **Clone Roles:** Build a new role by cloning an existing role.
|
@@ -27,19 +27,19 @@ It puts you in control over permissions on your site by providing a user interfa
|
|
27 |
* **Private Site:** You can make your site and its feed completely private if you want.
|
28 |
* **Plugin Integration:** Members is highly recommended by other WordPress developers. Many existing plugins integrate their custom roles and caps directly into it.
|
29 |
|
30 |
-
For more info, vist the [Members plugin home page](
|
31 |
|
32 |
### Like this plugin?
|
33 |
|
34 |
The Members plugin is a massive project with 1,000s of lines of code to maintain. A major update can take weeks or months of work. I don't make any money directly from this plugin while other, similar plugins charge substantial fees to even download them or get updates. Please consider helping the cause by:
|
35 |
|
36 |
-
* [Making a donation](
|
37 |
-
* [Signing up at my site](
|
38 |
* [Rating the plugin](https://wordpress.org/support/view/plugin-reviews/members?rate=5#postform).
|
39 |
|
40 |
### Professional Support
|
41 |
|
42 |
-
If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](
|
43 |
|
44 |
### Plugin Development
|
45 |
|
@@ -67,6 +67,10 @@ Most things should be fairly straightforward, but I've included an in-depth guid
|
|
67 |
|
68 |
You can also [view the readme](https://github.com/justintadlock/members/blob/master/readme.md) online.
|
69 |
|
|
|
|
|
|
|
|
|
70 |
### I can't access the "Role Manager" features.
|
71 |
|
72 |
When the plugin is first activated, it runs a script that sets specific capabilities to the "Administrator" role on your site that grants you access to this feature. So, you must be logged in with the administrator account to access the role manager.
|
@@ -77,7 +81,7 @@ If, for some reason, you do have the administrator role and the role manager is
|
|
77 |
|
78 |
Please read the documentation for the plugin before actually using it, especially a plugin that controls permissions for your site. I cannot stress this enough. This is a powerful plugin that allows you to make direct changes to roles and capabilities in the database.
|
79 |
|
80 |
-
You'll need to stop by my [support forums](
|
81 |
|
82 |
== Screenshots ==
|
83 |
|
@@ -87,6 +91,10 @@ You'll need to stop by my [support forums](http://themehybrid.com/board/topics)
|
|
87 |
4. Plugin settings screen
|
88 |
5. Select multiple roles per user (edit user screen)
|
89 |
|
|
|
|
|
|
|
|
|
90 |
== Changelog ==
|
91 |
|
92 |
The change log is located in the `changelog.md` file in the plugin folder. You may also [view the change log](https://github.com/justintadlock/members/blob/master/changelog.md) online.
|
1 |
=== Members ===
|
2 |
|
3 |
Contributors: greenshady
|
4 |
+
Donate link: https://themehybrid.com/donate
|
5 |
+
Tags: capabilities, roles, members, users
|
6 |
+
Requires at least: 4.7
|
7 |
+
Tested up to: 4.8
|
8 |
+
Stable tag: 2.0.0
|
9 |
|
10 |
The most powerful user, role, and capability management plugin for WordPress.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Members is a plugin that extends your control over your blog. It's a user, role, and capability editor plugin that was created to make WordPress a more powerful CMS.
|
15 |
|
16 |
It puts you in control over permissions on your site by providing a user interface (UI) for WordPress' powerful role and cap system, which is traditionally only available to developers who know how to code this by hand.
|
17 |
|
18 |
### Plugin Features
|
19 |
|
20 |
+
* **Role Editor:** Allows you to edit, create, and delete roles as well as capabilities for these roles.
|
21 |
* **Multiple User Roles:** Give one, two, or even more roles to any user.
|
22 |
* **Explicitly Deny Capabilities:** Deny specific caps to specific user roles.
|
23 |
* **Clone Roles:** Build a new role by cloning an existing role.
|
27 |
* **Private Site:** You can make your site and its feed completely private if you want.
|
28 |
* **Plugin Integration:** Members is highly recommended by other WordPress developers. Many existing plugins integrate their custom roles and caps directly into it.
|
29 |
|
30 |
+
For more info, vist the [Members plugin home page](https://themehybrid.com/plugins/members).
|
31 |
|
32 |
### Like this plugin?
|
33 |
|
34 |
The Members plugin is a massive project with 1,000s of lines of code to maintain. A major update can take weeks or months of work. I don't make any money directly from this plugin while other, similar plugins charge substantial fees to even download them or get updates. Please consider helping the cause by:
|
35 |
|
36 |
+
* [Making a donation](https://themehybrid.com/donate).
|
37 |
+
* [Signing up at my site](https://themehybrid.com/club).
|
38 |
* [Rating the plugin](https://wordpress.org/support/view/plugin-reviews/members?rate=5#postform).
|
39 |
|
40 |
### Professional Support
|
41 |
|
42 |
+
If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](https://themehybrid.com/board/topics), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 75,000+ users (and growing).
|
43 |
|
44 |
### Plugin Development
|
45 |
|
67 |
|
68 |
You can also [view the readme](https://github.com/justintadlock/members/blob/master/readme.md) online.
|
69 |
|
70 |
+
### Minimum PHP requirements.
|
71 |
+
|
72 |
+
Since version 2.0.0 of Members, PHP 5.3.0+ is required to use the plugin. The plugin will not allow itself to be activated and will output an error message if an earlier version of PHP is detected.
|
73 |
+
|
74 |
### I can't access the "Role Manager" features.
|
75 |
|
76 |
When the plugin is first activated, it runs a script that sets specific capabilities to the "Administrator" role on your site that grants you access to this feature. So, you must be logged in with the administrator account to access the role manager.
|
81 |
|
82 |
Please read the documentation for the plugin before actually using it, especially a plugin that controls permissions for your site. I cannot stress this enough. This is a powerful plugin that allows you to make direct changes to roles and capabilities in the database.
|
83 |
|
84 |
+
You'll need to stop by my [support forums](https://themehybrid.com/board/topics) to see if we can get your site fixed if you managed to lock yourself out. I know that this can be a bit can be a bit scary, but it's not that tough to fix with a little custom code.
|
85 |
|
86 |
== Screenshots ==
|
87 |
|
91 |
4. Plugin settings screen
|
92 |
5. Select multiple roles per user (edit user screen)
|
93 |
|
94 |
+
== Upgrade Notice ==
|
95 |
+
|
96 |
+
If upgrading from a version prior to 2.0.0, please note that the plugin now requires PHP 5.3.0 or later.
|
97 |
+
|
98 |
== Changelog ==
|
99 |
|
100 |
The change log is located in the `changelog.md` file in the plugin folder. You may also [view the change log](https://github.com/justintadlock/members/blob/master/changelog.md) online.
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|