Capability Manager Enhanced - Version 1.5.8

Version Description

  • Fixed : PHP warning for deprecated function WP_Roles::reinit
    • Change : Don't allow non-Administrator to edit Administrators, even if Administrator role level is set to 0
Download this release

Release Info

Developer kevinB
Plugin Icon 128x128 Capability Manager Enhanced
Version 1.5.8
Comparing to
See all releases

Code changes from version 1.5.7 to 1.5.8

capsman-enhanced.php CHANGED
@@ -1,41 +1,31 @@
1
  <?php
2
- /*
3
- Plugin Name: Capability Manager Enhanced
4
- Plugin URI: http://presspermit.com/capability-manager
5
- Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6
- Version: 1.5.7
7
- Author: Jordi Canals, Kevin Behrens
8
- Author URI: http://agapetry.net
9
- Text Domain: capsman-enhanced
10
- Domain Path: /lang/
11
- */
12
-
13
  /**
14
  * Capability Manager. Main Plugin File.
15
  * Plugin to create and manage Roles and Capabilities.
16
  *
 
17
  * @author Jordi Canals, Kevin Behrens
18
- * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2012-2015 Kevin Behrens
19
  * @license GNU General Public License version 3
20
  * @link http://agapetry.net
21
- *
22
-
23
- Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
24
- Modifications Copyright 2012-2015, Kevin Behrens <kevin@agapetry.net>
25
-
26
- This program is free software; you can redistribute it and/or
27
- modify it under the terms of the GNU General Public License
28
- version 3 as published by the Free Software Foundation.
29
-
30
- This program is distributed in the hope that it will be useful,
31
- but WITHOUT ANY WARRANTY; without even the implied warranty of
32
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
- GNU General Public License for more details <http://www.gnu.org/licenses/>.
34
  */
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  if ( ! defined( 'CAPSMAN_VERSION' ) ) {
37
- define( 'CAPSMAN_VERSION', '1.5.7' );
38
- define( 'CAPSMAN_ENH_VERSION', '1.5.7' );
39
  }
40
 
41
  if ( cme_is_plugin_active( 'capsman.php' ) ) {
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Capability Manager. Main Plugin File.
4
  * Plugin to create and manage Roles and Capabilities.
5
  *
6
+ * @package capability-manager-enhanced
7
  * @author Jordi Canals, Kevin Behrens
8
+ * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2012-2018 Kevin Behrens
9
  * @license GNU General Public License version 3
10
  * @link http://agapetry.net
11
+ * @version 1.5.8
 
 
 
 
 
 
 
 
 
 
 
 
12
  */
13
 
14
+ /*
15
+ Plugin Name: Capability Manager Enhanced
16
+ Plugin URI: http://presspermit.com/capability-manager
17
+ Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
18
+ Version: 1.5.8
19
+ Author: Jordi Canals, Kevin Behrens
20
+ Author URI: http://agapetry.net
21
+ Text Domain: capsman-enhanced
22
+ Domain Path: /lang/
23
+ License: GPLv3
24
+ */
25
+
26
  if ( ! defined( 'CAPSMAN_VERSION' ) ) {
27
+ define( 'CAPSMAN_VERSION', '1.5.8' );
28
+ define( 'CAPSMAN_ENH_VERSION', '1.5.8' );
29
  }
30
 
31
  if ( cme_is_plugin_active( 'capsman.php' ) ) {
images/Thumbs.db DELETED
Binary file
includes/admin.php CHANGED
@@ -47,7 +47,7 @@ if( defined('PP_ACTIVE') ) {
47
  <div id="icon-capsman-admin" class="icon32"></div>
48
  <?php endif; ?>
49
 
50
- <h2 <?php echo $style;?>><?php _e('Roles and Capabilities', 'capsman-enhanced') ?></h2>
51
 
52
  <form method="post" action="admin.php?page=<?php echo $this->ID ?>">
53
  <?php wp_nonce_field('capsman-general-manager'); ?>
@@ -165,16 +165,14 @@ if( defined('PP_ACTIVE') ) {
165
 
166
  if ( MULTISITE ) {
167
  global $wp_roles;
168
- if ( method_exists( $wp_roles, 'reinit' ) ) {
169
- global $wpdb;
170
 
171
- if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
172
- switch_to_blog(1);
173
- wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
174
- }
175
-
176
- $wp_roles->reinit();
177
  }
 
 
178
  }
179
 
180
  global $capsman;
@@ -713,7 +711,7 @@ function cme_network_role_ui( $default ) {
713
  return false;
714
  ?>
715
 
716
- <div style="float:right;margin:left:10px;margin-right:10px">
717
  <?php
718
  if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
719
  $autocreate_roles = array();
@@ -733,4 +731,4 @@ function cme_network_role_ui( $default ) {
733
 
734
  function cme_plugin_info_url( $plugin_slug ) {
735
  return self_admin_url( "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678" );
736
- }
47
  <div id="icon-capsman-admin" class="icon32"></div>
48
  <?php endif; ?>
49
 
50
+ <h1 <?php echo $style;?>><?php _e('Roles and Capabilities', 'capsman-enhanced') ?></h1>
51
 
52
  <form method="post" action="admin.php?page=<?php echo $this->ID ?>">
53
  <?php wp_nonce_field('capsman-general-manager'); ?>
165
 
166
  if ( MULTISITE ) {
167
  global $wp_roles;
168
+ global $wpdb;
 
169
 
170
+ if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
171
+ switch_to_blog(1);
172
+ wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
 
 
 
173
  }
174
+
175
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
176
  }
177
 
178
  global $capsman;
711
  return false;
712
  ?>
713
 
714
+ <div style="float:right;margin-left:10px;margin-right:10px">
715
  <?php
716
  if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
717
  $autocreate_roles = array();
731
 
732
  function cme_plugin_info_url( $plugin_slug ) {
733
  return self_admin_url( "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678" );
734
+ }
includes/handler.php CHANGED
@@ -39,8 +39,7 @@ class CapsmanHandler
39
  } elseif ( ! empty($post['SaveRole']) ) {
40
  if ( MULTISITE ) {
41
  global $wp_roles;
42
- if ( method_exists( $wp_roles, 'reinit' ) )
43
- $wp_roles->reinit();
44
  }
45
 
46
  $this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
@@ -62,8 +61,7 @@ class CapsmanHandler
62
  } elseif ( ! empty($post['AddCap']) ) {
63
  if ( MULTISITE ) {
64
  global $wp_roles;
65
- if ( method_exists( $wp_roles, 'reinit' ) )
66
- $wp_roles->reinit();
67
  }
68
 
69
  $role = get_role($post['current']);
@@ -258,7 +256,7 @@ class CapsmanHandler
258
  continue;
259
 
260
  switch_to_blog( $id );
261
- $wp_roles->reinit();
262
 
263
  if ( $blog_role = $wp_roles->get_role( $role_name ) ) {
264
  $stored_role_caps = ( ! empty($blog_role->capabilities) && is_array($blog_role->capabilities) ) ? array_intersect( $blog_role->capabilities, array(true, 1) ) : array();
@@ -286,7 +284,7 @@ class CapsmanHandler
286
  restore_current_blog();
287
  }
288
 
289
- $wp_roles->reinit();
290
  }
291
  } // endif multisite installation with super admin editing a main site role
292
  }
39
  } elseif ( ! empty($post['SaveRole']) ) {
40
  if ( MULTISITE ) {
41
  global $wp_roles;
42
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
 
43
  }
44
 
45
  $this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
61
  } elseif ( ! empty($post['AddCap']) ) {
62
  if ( MULTISITE ) {
63
  global $wp_roles;
64
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
 
65
  }
66
 
67
  $role = get_role($post['current']);
256
  continue;
257
 
258
  switch_to_blog( $id );
259
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
260
 
261
  if ( $blog_role = $wp_roles->get_role( $role_name ) ) {
262
  $stored_role_caps = ( ! empty($blog_role->capabilities) && is_array($blog_role->capabilities) ) ? array_intersect( $blog_role->capabilities, array(true, 1) ) : array();
284
  restore_current_blog();
285
  }
286
 
287
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
288
  }
289
  } // endif multisite installation with super admin editing a main site role
290
  }
includes/manager.php CHANGED
@@ -260,6 +260,9 @@ class CapabilityManager extends akPluginAbstract
260
  $r = get_role( $role );
261
  $level = ak_caps2level($r->capabilities);
262
 
 
 
 
263
  if ( $level > $this->max_level ) {
264
  $caps = array('do_not_allow');
265
  break;
260
  $r = get_role( $role );
261
  $level = ak_caps2level($r->capabilities);
262
 
263
+ if ( ( ! $level ) && ( 'administrator' == $role ) )
264
+ $level = 10;
265
+
266
  if ( $level > $this->max_level ) {
267
  $caps = array('do_not_allow');
268
  break;
includes/network.php CHANGED
@@ -7,7 +7,7 @@ function _cme_new_blog( $new_blog_id ) {
7
  $restore_blog_id = $blog_id;
8
 
9
  switch_to_blog( 1 );
10
- $wp_roles->reinit();
11
 
12
  $main_site_caps = array();
13
  $role_captions = array();
@@ -27,7 +27,7 @@ function _cme_new_blog( $new_blog_id ) {
27
  }
28
 
29
  switch_to_blog($new_blog_id);
30
- $wp_roles->reinit();
31
 
32
  if ( defined('PP_ACTIVE') ) {
33
  pp_refresh_options();
@@ -66,7 +66,7 @@ function _cme_new_blog( $new_blog_id ) {
66
  pp_update_option( 'supplemental_role_defs', $blog_pp_only );
67
 
68
  switch_to_blog($restore_blog_id);
69
- $wp_roles->reinit();
70
 
71
  if ( defined('PP_ACTIVE') )
72
  pp_refresh_options();
7
  $restore_blog_id = $blog_id;
8
 
9
  switch_to_blog( 1 );
10
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
11
 
12
  $main_site_caps = array();
13
  $role_captions = array();
27
  }
28
 
29
  switch_to_blog($new_blog_id);
30
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
31
 
32
  if ( defined('PP_ACTIVE') ) {
33
  pp_refresh_options();
66
  pp_update_option( 'supplemental_role_defs', $blog_pp_only );
67
 
68
  switch_to_blog($restore_blog_id);
69
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
70
 
71
  if ( defined('PP_ACTIVE') )
72
  pp_refresh_options();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: txanny, kevinB
3
  Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWZVFUDLLYQBA
4
  Tags: roles, capabilities, manager, editor, rights, role, capability, types, taxonomies, network, multisite, default
5
  Requires at least: 3.1
6
- Tested up to: 4.7
7
- Stable tag: 1.5.7
8
 
9
  A simple way to manage WordPress roles and capabilities.
10
 
@@ -99,7 +99,7 @@ Keep in mind that this plugin's purpose is to conveniently view and modify the c
99
  == License ==
100
 
101
  Copyright 2009, 2010 Jordi Canals
102
- Copyright 2013-2015, Kevin Behrens
103
 
104
  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
105
 
@@ -109,6 +109,10 @@ You should have received a copy of the GNU General Public License along with thi
109
 
110
  == Changelog ==
111
 
 
 
 
 
112
  = 1.5.7 =
113
  * Change : Revert menu captions to previous behavior ("Permissions > Role Capabilities" if Press Permit Core is active, otherwise "Users > Capabilities")
114
 
3
  Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWZVFUDLLYQBA
4
  Tags: roles, capabilities, manager, editor, rights, role, capability, types, taxonomies, network, multisite, default
5
  Requires at least: 3.1
6
+ Tested up to: 4.9.5
7
+ Stable tag: 1.5.8
8
 
9
  A simple way to manage WordPress roles and capabilities.
10
 
99
  == License ==
100
 
101
  Copyright 2009, 2010 Jordi Canals
102
+ Copyright 2013-2018, Kevin Behrens
103
 
104
  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
105
 
109
 
110
  == Changelog ==
111
 
112
+ = 1.5.8 =
113
+ * Fixed : PHP warning for deprecated function WP_Roles::reinit
114
+ * Change : Don't allow non-Administrator to edit Administrators, even if Administrator role level is set to 0
115
+
116
  = 1.5.7 =
117
  * Change : Revert menu captions to previous behavior ("Permissions > Role Capabilities" if Press Permit Core is active, otherwise "Users > Capabilities")
118