Members - Version 2.0.1

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 Icon 128x128 Members
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

admin/class-meta-box-content-permissions.php CHANGED
@@ -198,7 +198,7 @@ final class Meta_Box_Content_Permissions {
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; ?>
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( members_translate_role( $role ) ); ?>
202
  </label>
203
  </li>
204
  <?php endforeach; ?>
admin/class-user-edit.php CHANGED
@@ -172,7 +172,7 @@ final class User_Edit {
172
  } else {
173
 
174
  // Loop through the current user roles.
175
- foreach ( (array) $user->roles as $old_role ) {
176
 
177
  // Remove the role if it is editable.
178
  if ( members_is_role_editable( $old_role ) )
172
  } else {
173
 
174
  // Loop through the current user roles.
175
+ foreach ( (array) $old_user_data->roles as $old_role ) {
176
 
177
  // Remove the role if it is editable.
178
  if ( members_is_role_editable( $old_role ) )
admin/class-user-new.php CHANGED
@@ -48,11 +48,17 @@ final class User_New {
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
  /**
@@ -67,9 +73,6 @@ final class User_New {
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 );
48
  private function setup_actions() {
49
 
50
  // If multiple roles per user is not enabled, bail.
51
+ //
52
+ // @since 2.0.1 Added a check to not run on multisite.
53
+ // @link https://github.com/justintadlock/members/issues/153
54
+ if ( ! members_multiple_user_roles_enabled() || is_multisite() )
55
  return;
56
 
57
  // Only run our customization on the 'user-edit.php' page in the admin.
58
  add_action( 'load-user-new.php', array( $this, 'load' ) );
59
+
60
+ // Sets the new user's roles.
61
+ add_action( 'user_register', array( $this, 'user_register' ), 5 );
62
  }
63
 
64
  /**
73
  // Adds the profile fields.
74
  add_action( 'user_new_form', array( $this, 'profile_fields' ) );
75
 
 
 
 
76
  // Handle scripts.
77
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
78
  add_action( 'admin_footer', array( $this, 'print_scripts' ), 25 );
admin/views/class-view-general.php CHANGED
@@ -99,6 +99,7 @@ class View_General extends View {
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;
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['show_human_caps'] = ! empty( $settings['show_human_caps'] ) ? true : false;
103
  $settings['multi_roles'] = ! empty( $settings['multi_roles'] ) ? true : false;
104
  $settings['content_permissions'] = ! empty( $settings['content_permissions'] ) ? true : false;
105
  $settings['login_form_widget'] = ! empty( $settings['login_form_widget'] ) ? true : false;
changelog.md CHANGED
@@ -1,5 +1,20 @@
1
  # Change Log
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## [2.0.0] - 2017-07-19
4
 
5
  ### Added
1
  # Change Log
2
 
3
+ ## [2.0.1] - 2017-09-28
4
+
5
+ ### Changed
6
+
7
+ * Cap groups registered by the plugin bumped up 5 in priority. Primarily, this was to make sure post type cap groups were registered earlier than the default of `10`.
8
+ * Better handling of the PHP notice. We're going to check prior to loading any other code and add an admin notice if the site doesn't meet minimum requirements.
9
+
10
+ ### Fixed
11
+
12
+ * The `show_human_caps` setting was not properly saving because it wasn't accounted for in the validation callback.
13
+ * Make sure to use the correct `$old_user_data` variable when removing all roles from a user. Otherwise, this doesn't work.
14
+ * Super admins should be able to see any private site when multisite is enabled.
15
+ * Make sure that role labels (where the plugin outputs them) are the translated version.
16
+ * Multi-role selection has been removed for the Add New User screen on multisite installs. This was to address multiple issues in core with hardcoded values that the plugin couldn't filter. The feature may return in the future in a different form. Note that this doesn't change single-site installs.
17
+
18
  ## [2.0.0] - 2017-07-19
19
 
20
  ### Added
inc/functions-cap-groups.php CHANGED
@@ -81,7 +81,7 @@ function members_register_default_cap_groups() {
81
  'label' => $type->labels->name,
82
  'caps' => $has_caps,
83
  'icon' => $icon,
84
- 'priority' => 5
85
  )
86
  );
87
  }
@@ -93,7 +93,7 @@ function members_register_default_cap_groups() {
93
  'caps' => members_get_taxonomy_group_caps(),
94
  'icon' => 'dashicons-tag',
95
  'diff_added' => true,
96
- 'priority' => 10
97
  )
98
  );
99
 
@@ -102,7 +102,7 @@ function members_register_default_cap_groups() {
102
  array(
103
  'label' => esc_html__( 'Appearance', 'members' ),
104
  'icon' => 'dashicons-admin-appearance',
105
- 'priority' => 15
106
  )
107
  );
108
 
@@ -111,7 +111,7 @@ function members_register_default_cap_groups() {
111
  array(
112
  'label' => esc_html__( 'Plugins', 'members' ),
113
  'icon' => 'dashicons-admin-plugins',
114
- 'priority' => 20
115
  )
116
  );
117
 
@@ -120,7 +120,7 @@ function members_register_default_cap_groups() {
120
  array(
121
  'label' => esc_html__( 'Users', 'members' ),
122
  'icon' => 'dashicons-admin-users',
123
- 'priority' => 25
124
  )
125
  );
126
 
81
  'label' => $type->labels->name,
82
  'caps' => $has_caps,
83
  'icon' => $icon,
84
+ 'priority' => 10
85
  )
86
  );
87
  }
93
  'caps' => members_get_taxonomy_group_caps(),
94
  'icon' => 'dashicons-tag',
95
  'diff_added' => true,
96
+ 'priority' => 15
97
  )
98
  );
99
 
102
  array(
103
  'label' => esc_html__( 'Appearance', 'members' ),
104
  'icon' => 'dashicons-admin-appearance',
105
+ 'priority' => 20
106
  )
107
  );
108
 
111
  array(
112
  'label' => esc_html__( 'Plugins', 'members' ),
113
  'icon' => 'dashicons-admin-plugins',
114
+ 'priority' => 25
115
  )
116
  );
117
 
120
  array(
121
  'label' => esc_html__( 'Users', 'members' ),
122
  'icon' => 'dashicons-admin-users',
123
+ 'priority' => 30
124
  )
125
  );
126
 
inc/functions-private-site.php CHANGED
@@ -78,13 +78,17 @@ function members_is_private_rest_api() {
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;
78
  */
79
  function members_please_log_in() {
80
 
81
+ // If private blog is not enabled, bail.
82
+ if ( ! members_is_private_blog() )
83
+ return;
84
+
85
  // If this is a multisite instance and the user is logged into the network.
86
+ if ( is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() && ! is_super_admin() ) {
87
  members_ms_private_blog_die();
88
  }
89
 
90
  // Check if the private blog feature is active and if the user is not logged in.
91
+ if ( ! is_user_logged_in() && members_is_private_page() ) {
92
 
93
  auth_redirect();
94
  exit;
inc/functions-roles.php CHANGED
@@ -40,7 +40,7 @@ function members_register_default_roles( $wp_roles ) {
40
  foreach ( $wp_roles->roles as $name => $object ) {
41
 
42
  $args = array(
43
- 'label' => $object['name'],
44
  'caps' => $object['capabilities']
45
  );
46
 
@@ -247,7 +247,23 @@ function members_sanitize_role( $role ) {
247
  function members_translate_role( $role ) {
248
  global $wp_roles;
249
 
250
- return apply_filters( 'members_translate_role', translate_user_role( $wp_roles->role_names[ $role ] ), $role );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
 
253
  /**
40
  foreach ( $wp_roles->roles as $name => $object ) {
41
 
42
  $args = array(
43
+ 'label' => members_translate_role_hook( $object['name'], $name ),
44
  'caps' => $object['capabilities']
45
  );
46
 
247
  function members_translate_role( $role ) {
248
  global $wp_roles;
249
 
250
+ return members_translate_role_hook( $wp_roles->role_names[ $role ], $role );
251
+ }
252
+
253
+ /**
254
+ * Hook for translating user roles. I needed to separate this from the primary
255
+ * `members_translate_role()` function in case `$wp_roles` was not yet available
256
+ * but both the role and role label were.
257
+ *
258
+ * @since 2.0.1
259
+ * @access public
260
+ * @param string $label
261
+ * @param string $role
262
+ * @return string
263
+ */
264
+ function members_translate_role_hook( $label, $role ) {
265
+
266
+ return apply_filters( 'members_translate_role', translate_user_role( $label ), $role );
267
  }
268
 
269
  /**
members.php CHANGED
@@ -3,11 +3,11 @@
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
  *
12
  * The members plugin was created because the WordPress community is lacking a solid permissions
13
  * plugin that is both open source and works completely within the confines of the APIs in WordPress.
@@ -25,7 +25,7 @@
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
@@ -176,6 +176,16 @@ final class Members_Plugin {
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' );
@@ -278,11 +288,7 @@ final class Members_Plugin {
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.
@@ -298,6 +304,42 @@ final class Members_Plugin {
298
  $role->add_cap( 'restrict_content' ); // Edit per-post content permissions.
299
  }
300
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  }
302
 
303
  /**
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.1
7
  * Author: Justin Tadlock
8
  * Author URI: https://themehybrid.com
9
  * Text Domain: members
10
+ * Domain Path: /lang
11
  *
12
  * The members plugin was created because the WordPress community is lacking a solid permissions
13
  * plugin that is both open source and works completely within the confines of the APIs in WordPress.
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.1
29
  * @author Justin Tadlock <justintadlock@gmail.com>
30
  * @copyright Copyright (c) 2009 - 2017, Justin Tadlock
31
  * @link https://themehybrid.com/plugins/members
176
  */
177
  private function includes() {
178
 
179
+ // Check if we meet the minimum PHP version.
180
+ if ( version_compare( PHP_VERSION, $this->php_version, '<' ) ) {
181
+
182
+ // Add admin notice.
183
+ add_action( 'admin_notices', array( $this, 'php_admin_notice' ) );
184
+
185
+ // Bail.
186
+ return;
187
+ }
188
+
189
  // Load class files.
190
  require_once( $this->dir . 'inc/class-capability.php' );
191
  require_once( $this->dir . 'inc/class-cap-group.php' );
288
  deactivate_plugins( plugin_basename( __FILE__ ) );
289
 
290
  // Add an error message and die.
291
+ wp_die( $this->get_min_php_message() );
 
 
 
 
292
  }
293
 
294
  // Get the administrator role.
304
  $role->add_cap( 'restrict_content' ); // Edit per-post content permissions.
305
  }
306
  }
307
+
308
+ /**
309
+ * Returns a message noting the minimum version of PHP required.
310
+ *
311
+ * @since 2.0.1
312
+ * @access private
313
+ * @return void
314
+ */
315
+ private function get_min_php_message() {
316
+
317
+ return sprintf(
318
+ __( 'Members requires PHP version %1$s. You are running version %2$s. Please upgrade and try again.', 'members' ),
319
+ $this->php_version,
320
+ PHP_VERSION
321
+ );
322
+ }
323
+
324
+ /**
325
+ * Outputs the admin notice that the user needs to upgrade their PHP version. It also
326
+ * auto-deactivates the plugin.
327
+ *
328
+ * @since 2.0.1
329
+ * @access public
330
+ * @return void
331
+ */
332
+ public function php_admin_notice() {
333
+
334
+ // Output notice.
335
+ printf(
336
+ '<div class="notice notice-error is-dismissible"><p><strong>%s</strong></p></div>',
337
+ esc_html( $this->get_min_php_message() )
338
+ );
339
+
340
+ // Make sure the plugin is deactivated.
341
+ deactivate_plugins( plugin_basename( __FILE__ ) );
342
+ }
343
  }
344
 
345
  /**
readme.txt CHANGED
@@ -4,8 +4,11 @@ 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
 
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.2
8
+ Requires PHP: 5.3
9
+ Stable tag: 2.0.1
10
+ License: GPLv2 or later
11
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
  The most powerful user, role, and capability management plugin for WordPress.
14