Capability Manager Enhanced - Version 1.9.9

Version Description

  • 13 May 2020 =
    • Compat : PublishPress Permissions - "Type-Specific Capabilities" setting was not properly synchronized with Permissions > Settings > Core > Filtered Post Types
Download this release

Release Info

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

Code changes from version 1.9.6 to 1.9.9

capsman-enhanced.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: PublishPress Capabilities
4
  * Plugin URI: https://publishpress.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.9.6
7
  * Author: PublishPress
8
  * Author URI: https://publishpress.com/
9
  * Text Domain: capsman-enhanced
@@ -25,13 +25,13 @@
25
  * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
26
  * @license GNU General Public License version 3
27
  * @link https://publishpress.com/
28
- * @version 1.9.6
29
  */
30
 
31
  if (!defined('CAPSMAN_VERSION')) {
32
- define('CAPSMAN_VERSION', '1.9.6');
33
- define('CAPSMAN_ENH_VERSION', '1.9.6');
34
- define('PUBLISHPRESS_CAPS_VERSION', '1.9.6');
35
  }
36
 
37
  foreach (get_option('active_plugins') as $plugin_file) {
3
  * Plugin Name: PublishPress Capabilities
4
  * Plugin URI: https://publishpress.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.9.9
7
  * Author: PublishPress
8
  * Author URI: https://publishpress.com/
9
  * Text Domain: capsman-enhanced
25
  * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
26
  * @license GNU General Public License version 3
27
  * @link https://publishpress.com/
28
+ * @version 1.9.9
29
  */
30
 
31
  if (!defined('CAPSMAN_VERSION')) {
32
+ define('CAPSMAN_VERSION', '1.9.9');
33
+ define('CAPSMAN_ENH_VERSION', '1.9.9');
34
+ define('PUBLISHPRESS_CAPS_VERSION', '1.9.9');
35
  }
36
 
37
  foreach (get_option('active_plugins') as $plugin_file) {
includes/cap-helper.php CHANGED
@@ -33,7 +33,9 @@ class CME_Cap_Helper {
33
 
34
  $append_caps = array( 'edit_published_posts' => 'edit_posts', 'edit_private_posts' => 'edit_posts', 'delete_posts' => 'edit_posts', 'delete_others_posts' => 'delete_posts', 'delete_published_posts' => 'delete_posts', 'delete_private_posts' => 'delete_posts', 'read' => 'read' );
35
 
36
- if ( get_option('pp_define_create_posts_cap') ) {
 
 
37
  foreach( array( 'post', 'page' ) as $post_type ) {
38
  if ( $wp_post_types[$post_type]->cap->create_posts == $wp_post_types[$post_type]->cap->edit_posts ) {
39
  $wp_post_types[$post_type]->cap->create_posts = "create_{$post_type}s";
33
 
34
  $append_caps = array( 'edit_published_posts' => 'edit_posts', 'edit_private_posts' => 'edit_posts', 'delete_posts' => 'edit_posts', 'delete_others_posts' => 'delete_posts', 'delete_published_posts' => 'delete_posts', 'delete_private_posts' => 'delete_posts', 'read' => 'read' );
35
 
36
+ $pp_prefix = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp' : 'presspermit';
37
+
38
+ if ( get_option("{$pp_prefix}_define_create_posts_cap") ) {
39
  foreach( array( 'post', 'page' ) as $post_type ) {
40
  if ( $wp_post_types[$post_type]->cap->create_posts == $wp_post_types[$post_type]->cap->edit_posts ) {
41
  $wp_post_types[$post_type]->cap->create_posts = "create_{$post_type}s";
includes/filters.php CHANGED
@@ -49,6 +49,8 @@ add_filter('plugin_action_links_' . plugin_basename(CME_FILE), '_cme_fltPluginAc
49
 
50
  add_filter('pp_custom_status_list', 'cme_filter_custom_status_list', 10, 2);
51
 
 
 
52
  function _cme_publishpress_roles_js() {
53
  if (defined('PUBLISHPRESS_VERSION') && ((strpos($_SERVER['REQUEST_URI'], 'page=pp-manage-roles')))) {
54
  require_once(dirname(__FILE__) . '/publishpress-roles.php');
@@ -56,6 +58,25 @@ function _cme_publishpress_roles_js() {
56
  }
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  /**
60
  * Filters the list of custom statuses
61
  *
@@ -210,13 +231,13 @@ function _cme_remap_term_meta_cap ( $caps, $cap, $user_id, $args ) {
210
  function cme_get_assisted_post_types() {
211
  $type_args = array( 'public' => true, 'show_ui' => true );
212
 
213
- $types = get_post_types( $type_args, 'names', 'or' );
214
 
215
  if ( $omit_types = apply_filters( 'pp_unfiltered_post_types', array( 'wp_block' ) ) ) {
216
- $post_types = array_diff_key( $types, array_fill_keys( (array) $omit_types, true ) );
217
  }
218
 
219
- $option_name = (defined('PRESSPERMIT_VERSION')) ? 'presspermit_enabled_post_types' : 'pp_enabled_post_types';
220
  $enabled = (array) get_option( $option_name, array( 'post' => true, 'page' => true ) );
221
  $post_types = array_intersect( $post_types, array_keys( array_filter( $enabled ) ) );
222
 
@@ -234,7 +255,8 @@ function cme_get_assisted_taxonomies() {
234
  $taxonomies = array_diff_key( $taxonomies, array_fill_keys( (array) $omit_taxonomies, true ) );
235
  }
236
 
237
- $enabled = (array) get_option( 'pp_enabled_taxonomies', array() );
 
238
  $taxonomies = array_intersect( $taxonomies, array_keys( array_filter( $enabled ) ) );
239
 
240
  return apply_filters( 'cme_assisted_taxonomies', $taxonomies, $tx_args );
49
 
50
  add_filter('pp_custom_status_list', 'cme_filter_custom_status_list', 10, 2);
51
 
52
+ add_action('plugins_loaded', '_cme_migrate_pp_options');
53
+
54
  function _cme_publishpress_roles_js() {
55
  if (defined('PUBLISHPRESS_VERSION') && ((strpos($_SERVER['REQUEST_URI'], 'page=pp-manage-roles')))) {
56
  require_once(dirname(__FILE__) . '/publishpress-roles.php');
58
  }
59
  }
60
 
61
+ // Capabilities previously stored, retrieved settings from 'pp_' option names. Now using 'presspermit_' option names unless PressPermit 2.6.x or older is activated, but need to migrate previous settings
62
+ function _cme_migrate_pp_options() {
63
+ if (!get_option('cme_pp_options_migrated') && get_option('cme_enabled_post_types')) {
64
+ foreach(['enabled_post_types', 'enabled_taxonomies', 'define_create_posts_cap'] as $option_basename) {
65
+ $presspermit_options = get_option("presspermit_{$option_basename}");
66
+
67
+ if (!$presspermit_options || !defined('PRESSPERMIT_VERSION')) {
68
+ $prefix = ('enabled_post_types' == $option_basename) ? 'cme_' : 'pp_';
69
+
70
+ if ($option_val = get_option("{$prefix}_{$option_basename}")) {
71
+ update_option("presspermit_{$option_basename}", $option_val);
72
+ }
73
+ }
74
+ }
75
+
76
+ update_option('cme_pp_options_migrated', true);
77
+ }
78
+ }
79
+
80
  /**
81
  * Filters the list of custom statuses
82
  *
231
  function cme_get_assisted_post_types() {
232
  $type_args = array( 'public' => true, 'show_ui' => true );
233
 
234
+ $post_types = get_post_types( $type_args, 'names', 'or' );
235
 
236
  if ( $omit_types = apply_filters( 'pp_unfiltered_post_types', array( 'wp_block' ) ) ) {
237
+ $post_types = array_diff_key( $post_types, array_fill_keys( (array) $omit_types, true ) );
238
  }
239
 
240
+ $option_name = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp_enabled_post_types' : 'presspermit_enabled_post_types';
241
  $enabled = (array) get_option( $option_name, array( 'post' => true, 'page' => true ) );
242
  $post_types = array_intersect( $post_types, array_keys( array_filter( $enabled ) ) );
243
 
255
  $taxonomies = array_diff_key( $taxonomies, array_fill_keys( (array) $omit_taxonomies, true ) );
256
  }
257
 
258
+ $option_name = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp_enabled_taxonomies' : 'presspermit_enabled_taxonomies';
259
+ $enabled = (array) get_option( $option_name, array() );
260
  $taxonomies = array_intersect( $taxonomies, array_keys( array_filter( $enabled ) ) );
261
 
262
  return apply_filters( 'cme_assisted_taxonomies', $taxonomies, $tx_args );
includes/manager.php CHANGED
@@ -46,6 +46,13 @@ function _cme_core_caps() {
46
  'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes', 'install_themes',
47
  'update_core', 'list_users', 'remove_users', 'promote_users', 'edit_theme_options', 'delete_themes', 'export' ), true );
48
 
 
 
 
 
 
 
 
49
  ksort( $core_caps );
50
  return $core_caps;
51
  }
46
  'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes', 'install_themes',
47
  'update_core', 'list_users', 'remove_users', 'promote_users', 'edit_theme_options', 'delete_themes', 'export' ), true );
48
 
49
+ // @todo (possibly)
50
+ /*
51
+ if (is_multisite()) {
52
+ $core_caps['manage_network_plugins'] = true;
53
+ }
54
+ */
55
+
56
  ksort( $core_caps );
57
  return $core_caps;
58
  }
includes/pp-handler.php CHANGED
@@ -14,6 +14,8 @@ function _cme_update_pp_usage() {
14
 
15
  $posted = $_POST;
16
 
 
 
17
  foreach( $options as $option_basename ) {
18
  if ( ! isset( $posted["{$option_basename}-options"] ) )
19
  continue;
@@ -36,8 +38,7 @@ function _cme_update_pp_usage() {
36
  }
37
  }
38
 
39
- //$option_name = ( ( 'detailed_taxonomies' == $option_basename ) || ! defined( 'PRESSPERMIT_ACTIVE' ) ) ? 'cme_' . $option_basename : 'pp_' . $option_basename;
40
- $option_name = ( 'detailed_taxonomies' == $option_basename ) ? 'cme_' . $option_basename : 'pp_' . $option_basename;
41
 
42
  if ( $current = get_option( $option_name ) ) {
43
  if ( $current = array_diff_key( $current, $unselected ) )
@@ -61,7 +62,7 @@ function _cme_update_pp_usage() {
61
  }
62
 
63
  if ( ! empty( $_REQUEST['update_filtered_types']) ) {
64
- update_option( 'pp_' . 'define_create_posts_cap', ! empty($_REQUEST['pp_define_create_posts_cap']) );
65
  }
66
  }
67
 
14
 
15
  $posted = $_POST;
16
 
17
+ $pp_prefix = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp' : 'presspermit';
18
+
19
  foreach( $options as $option_basename ) {
20
  if ( ! isset( $posted["{$option_basename}-options"] ) )
21
  continue;
38
  }
39
  }
40
 
41
+ $option_name = ( 'detailed_taxonomies' == $option_basename ) ? 'cme_' . $option_basename : $pp_prefix . '_' . $option_basename;
 
42
 
43
  if ( $current = get_option( $option_name ) ) {
44
  if ( $current = array_diff_key( $current, $unselected ) )
62
  }
63
 
64
  if ( ! empty( $_REQUEST['update_filtered_types']) ) {
65
+ update_option( $pp_prefix . '_define_create_posts_cap', ! empty($_REQUEST['pp_define_create_posts_cap']) );
66
  }
67
  }
68
 
includes/pp-ui.php CHANGED
@@ -35,7 +35,7 @@ class Capsman_PP_UI {
35
 
36
  echo '<ul class="ul-disc publishpress-caps-extra-hints" style="margin-top:10px;display:none">';
37
 
38
- $pp_prefix = ( defined( 'PRESSPERMIT_VERSION') ) ? 'presspermit' : 'pp';
39
 
40
  if ( defined( 'PPCE_VERSION' ) || ! defined( 'PRESSPERMIT_ACTIVE' ) || in_array( $default, array( 'subscriber', 'contributor', 'author', 'editor' ) ) ) {
41
  echo '<li>';
@@ -114,7 +114,9 @@ class Capsman_PP_UI {
114
  echo '<td style="width:50%">';
115
 
116
  $option_basename = 'enabled_post_types';
117
- $enabled = get_option( 'pp_' . $option_basename, array( 'post' => true, 'page' => true ) );
 
 
118
 
119
  foreach( $defined_types as $key => $type_obj ) {
120
  if ( ! $key )
@@ -148,7 +150,9 @@ class Capsman_PP_UI {
148
  </tr>
149
  </table>
150
 
151
- <?php $define_create_posts_cap = get_option( 'pp_define_create_posts_cap' );?>
 
 
152
 
153
  <div style="margin-top:10px;margin-bottom:10px">
154
  <label for="pp_define_create_posts_cap">
@@ -180,8 +184,10 @@ class Capsman_PP_UI {
180
 
181
  echo '<td style="width:50%">';
182
 
 
 
183
  $option_basename = 'enabled_taxonomies';
184
- $option_name = 'pp_' . $option_basename;
185
 
186
  $enabled = get_option( $option_name, array() );
187
 
35
 
36
  echo '<ul class="ul-disc publishpress-caps-extra-hints" style="margin-top:10px;display:none">';
37
 
38
+ $pp_prefix = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp' : 'presspermit';
39
 
40
  if ( defined( 'PPCE_VERSION' ) || ! defined( 'PRESSPERMIT_ACTIVE' ) || in_array( $default, array( 'subscriber', 'contributor', 'author', 'editor' ) ) ) {
41
  echo '<li>';
114
  echo '<td style="width:50%">';
115
 
116
  $option_basename = 'enabled_post_types';
117
+ $pp_prefix = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp' : 'presspermit';
118
+
119
+ $enabled = get_option( $pp_prefix . '_' . $option_basename, array( 'post' => true, 'page' => true ) );
120
 
121
  foreach( $defined_types as $key => $type_obj ) {
122
  if ( ! $key )
150
  </tr>
151
  </table>
152
 
153
+ <?php
154
+
155
+ $define_create_posts_cap = get_option("{$pp_prefix}_define_create_posts_cap");?>
156
 
157
  <div style="margin-top:10px;margin-bottom:10px">
158
  <label for="pp_define_create_posts_cap">
184
 
185
  echo '<td style="width:50%">';
186
 
187
+ $pp_prefix = (defined('PPC_VERSION') && !defined('PRESSPERMIT_VERSION')) ? 'pp' : 'presspermit';
188
+
189
  $option_basename = 'enabled_taxonomies';
190
+ $option_name = $pp_prefix . '_' . $option_basename;
191
 
192
  $enabled = get_option( $option_name, array() );
193
 
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: user roles, capabilities, permissions, authors, editors, post types, taxon
7
  Requires at least: 4.9.7
8
  Tested up to: 5.4
9
  Requires PHP: 5.6.20
10
- Stable tag: 1.9.6
11
  License: GPLv3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -114,10 +114,14 @@ Fixed : Non-administrators with user editing capabilities could add new Administ
114
 
115
  == Changelog ==
116
 
 
 
 
117
  = 1.9.6 - 23 Apr 2020 =
118
  * Change : Add New Role retains capitalization as entered for role title (otherwise applies proper case)
119
  * Feature : Rename Role sidebar box on Capabilities screen
120
  * Fixed : Fatal error on plugin load if Administrator role does not exist
 
121
 
122
  = 1.9.5 - 6 Apr 2020 =
123
  * Fixed : Fatal error loading Capabilities screen on a small percentage of installations
7
  Requires at least: 4.9.7
8
  Tested up to: 5.4
9
  Requires PHP: 5.6.20
10
+ Stable tag: 1.9.9
11
  License: GPLv3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
114
 
115
  == Changelog ==
116
 
117
+ = 1.9.9 - 13 May 2020 =
118
+ * Compat : PublishPress Permissions - "Type-Specific Capabilities" setting was not properly synchronized with Permissions > Settings > Core > Filtered Post Types
119
+
120
  = 1.9.6 - 23 Apr 2020 =
121
  * Change : Add New Role retains capitalization as entered for role title (otherwise applies proper case)
122
  * Feature : Rename Role sidebar box on Capabilities screen
123
  * Fixed : Fatal error on plugin load if Administrator role does not exist
124
+ * Compat : PublishPress Permissions - Post Type selections for "Type-Specific Capabilities" were not synchronized with PublishPress Permissions under some conditions
125
 
126
  = 1.9.5 - 6 Apr 2020 =
127
  * Fixed : Fatal error loading Capabilities screen on a small percentage of installations