Capability Manager Enhanced - Version 1.7

Version Description

  • 28 Mar 2019
Download this release

Release Info

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

Code changes from version 1.6.1 to 1.7

admin.css CHANGED
@@ -158,10 +158,18 @@ padding-right: 10px;
158
margin-top: 5px;
159
}
160
161
#akmin td.sidebar {
162
width: 300px;
163
}
164
165
#akmin input.regular-text {
166
width: 200px;
167
}
@@ -180,4 +188,9 @@ td.cm-has-via-pp {
180
background-color: #7f7;
181
}
182
183
- #akmin span.publishpress,#akmin span.publishpress a,#akmin span.publishpress a:visited {color:#655997;font-weight:bold}
158
margin-top: 5px;
159
}
160
161
+ #akmin input.button-primary {
162
+ margin: 5px;
163
+ }
164
+
165
#akmin td.sidebar {
166
width: 300px;
167
}
168
169
+ #akmin .cme-backup-tool a {
170
+ padding-left:0;
171
+ }
172
+
173
#akmin input.regular-text {
174
width: 200px;
175
}
188
background-color: #7f7;
189
}
190
191
+ #akmin div.publishpress-headline {line-height:25px}
192
+ #akmin span.publishpress-thanks{margin-left:5px;color:#655997;white-space:nowrap}
193
+ #akmin span.publishpress-thanks,#akmin span.publishpress-thanks a,#akmin span.publishpress-thanks a:visited {color:#655997;font-weight:bold;}
194
+
195
+ table#akmin td.sidebar li.publishpress-contact{text-align:center}
196
+ table#akmin td.sidebar li.publishpress-contact a{padding:5px 0 5px 0;}
admin.dev.js CHANGED
@@ -4,7 +4,7 @@ jQuery(document).ready( function($) {
4
$('td.cap-unreg').attr('title',cmeAdmin.typeCapUnregistered);
5
$('a.normal-cap').attr('title',cmeAdmin.switchableCaption);
6
$('span.cap-x').attr('title',cmeAdmin.capNegated);
7
- $('table.cme-checklist input[class!="cme-check-all"]').attr('title',cmeAdmin.chkCaption);
8
9
$('table.cme-checklist a.neg-cap').click( function(e) {
10
$(this).closest('td').removeClass('cap-yes').removeClass('cap-no').addClass('cap-neg');
4
$('td.cap-unreg').attr('title',cmeAdmin.typeCapUnregistered);
5
$('a.normal-cap').attr('title',cmeAdmin.switchableCaption);
6
$('span.cap-x').attr('title',cmeAdmin.capNegated);
7
+ $('table.cme-checklist input[class!="cme-check-all"]').not(':disabled').attr('title',cmeAdmin.chkCaption);
8
9
$('table.cme-checklist a.neg-cap').click( function(e) {
10
$(this).closest('td').removeClass('cap-yes').removeClass('cap-no').addClass('cap-neg');
admin.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready(function($){$('a.neg-cap').attr('title',cmeAdmin.negationCaption);$('a.neg-type-caps').attr('title',cmeAdmin.typeCapsNegationCaption);$('td.cap-unreg').attr('title',cmeAdmin.typeCapUnregistered);$('a.normal-cap').attr('title',cmeAdmin.switchableCaption);$('span.cap-x').attr('title',cmeAdmin.capNegated);$('table.cme-checklist input[class!="cme-check-all"]').attr('title',cmeAdmin.chkCaption);$('table.cme-checklist a.neg-cap').click(function(e){$(this).closest('td').removeClass('cap-yes').removeClass('cap-no').addClass('cap-neg');var cap_name_attr=$(this).parent().find('input[type="checkbox"]').attr('name');$(this).after('<input type="hidden" class="cme-negation-input" name="'+cap_name_attr+'" value="" />');return false;});$(document).on('click','table.cme-typecaps span.cap-x,table.cme-checklist span.cap-x,table.cme-checklist td.cap-neg span',function(e){$(this).closest('td').removeClass('cap-neg').removeClass('cap-yes').addClass('cap-no');$(this).parent().find('input[type="checkbox"]').prop('checked',false);$(this).parent().find('input.cme-negation-input').remove();return false;});$('input.cme-check-all').click(function(e){$(this).closest('table').find('input[type="checkbox"][disabled!="disabled"]:visible').prop('checked',$(this).is(":checked"));});$('a.cme-neg-all').click(function(e){$(this).closest('table').find('a.neg-cap:visible').click();return false;});$('a.cme-switch-all').click(function(e){$(this).closest('table').find('td.cap-neg span').click();return false;});$('table.cme-typecaps a.neg-type-caps').click(function(e){$(this).closest('tr').find('td[class!="cap-neg"]').filter('td[class!="cap-unreg"]').each(function(e){$(this).addClass('cap-neg');var cap_name_attr=$(this).parent().find('input[type="checkbox"]').attr('name');$(this).append('<input type="hidden" class="cme-negation-input" name="'+cap_name_attr+'" value="" />');});return false;});$('table.cme-typecaps th').click(function(){var columnNo=$(this).index();var check_val=!$(this).prop('checked_all');if($(this).hasClass('term-cap'))
2
var class_sel='[class*="term-cap"]';else
3
var class_sel='[class*="post-cap"]';$(this).closest("table").find("tr td"+class_sel+":nth-child("+(columnNo+1)+') input[type="checkbox"]:visible').prop("checked",check_val);$(this).prop('checked_all',check_val);});$('a.cme-fix-read-cap').click(function(){$('input[name="caps[read]"]').prop('checked',true);$('input[name="SaveRole"]').trigger('click');return false;});});
1
+ jQuery(document).ready(function($){$('a.neg-cap').attr('title',cmeAdmin.negationCaption);$('a.neg-type-caps').attr('title',cmeAdmin.typeCapsNegationCaption);$('td.cap-unreg').attr('title',cmeAdmin.typeCapUnregistered);$('a.normal-cap').attr('title',cmeAdmin.switchableCaption);$('span.cap-x').attr('title',cmeAdmin.capNegated);$('table.cme-checklist input[class!="cme-check-all"]').not(':disabled').attr('title',cmeAdmin.chkCaption);$('table.cme-checklist a.neg-cap').click(function(e){$(this).closest('td').removeClass('cap-yes').removeClass('cap-no').addClass('cap-neg');var cap_name_attr=$(this).parent().find('input[type="checkbox"]').attr('name');$(this).after('<input type="hidden" class="cme-negation-input" name="'+cap_name_attr+'" value="" />');return false;});$(document).on('click','table.cme-typecaps span.cap-x,table.cme-checklist span.cap-x,table.cme-checklist td.cap-neg span',function(e){$(this).closest('td').removeClass('cap-neg').removeClass('cap-yes').addClass('cap-no');$(this).parent().find('input[type="checkbox"]').prop('checked',false);$(this).parent().find('input.cme-negation-input').remove();return false;});$('input.cme-check-all').click(function(e){$(this).closest('table').find('input[type="checkbox"][disabled!="disabled"]:visible').prop('checked',$(this).is(":checked"));});$('a.cme-neg-all').click(function(e){$(this).closest('table').find('a.neg-cap:visible').click();return false;});$('a.cme-switch-all').click(function(e){$(this).closest('table').find('td.cap-neg span').click();return false;});$('table.cme-typecaps a.neg-type-caps').click(function(e){$(this).closest('tr').find('td[class!="cap-neg"]').filter('td[class!="cap-unreg"]').each(function(e){$(this).addClass('cap-neg');var cap_name_attr=$(this).parent().find('input[type="checkbox"]').attr('name');$(this).append('<input type="hidden" class="cme-negation-input" name="'+cap_name_attr+'" value="" />');});return false;});$('table.cme-typecaps th').click(function(){var columnNo=$(this).index();var check_val=!$(this).prop('checked_all');if($(this).hasClass('term-cap'))
2
var class_sel='[class*="term-cap"]';else
3
var class_sel='[class*="post-cap"]';$(this).closest("table").find("tr td"+class_sel+":nth-child("+(columnNo+1)+') input[type="checkbox"]:visible').prop("checked",check_val);$(this).prop('checked_all',check_val);});$('a.cme-fix-read-cap').click(function(){$('input[name="caps[read]"]').prop('checked',true);$('input[name="SaveRole"]').trigger('click');return false;});});
capsman-enhanced.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: Capability Manager Enhanced
4
* Plugin URI: https://publishpress.com
5
* Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6
- * Version: 1.6.1
7
* Author: PublishPress
8
* Author URI: https://publishpress.com
9
* Text Domain: capsman-enhanced
@@ -23,12 +23,12 @@
23
* @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2019 PublishPress
24
* @license GNU General Public License version 3
25
* @link https://publishpress.com
26
- * @version 1.6.1
27
*/
28
29
if ( ! defined( 'CAPSMAN_VERSION' ) ) {
30
- define( 'CAPSMAN_VERSION', '1.6.1' );
31
- define( 'CAPSMAN_ENH_VERSION', '1.6.1' );
32
}
33
34
if ( cme_is_plugin_active( 'capsman.php' ) ) {
@@ -95,13 +95,48 @@ if ( cme_is_plugin_active( 'capsman.php' ) ) {
95
add_action( 'init', '_cme_init' );
96
add_action( 'plugins_loaded', '_cme_act_pp_active', 1 );
97
98
function _cme_act_pp_active() {
99
- if ( defined('PP_VERSION') || defined('PPC_VERSION') )
100
- define( 'PP_ACTIVE', true );
101
}
102
103
function _cme_init() {
104
- require_once ( dirname(__FILE__) . '/includes/filters.php' );
105
106
load_plugin_textdomain('capsman-enhanced', false, dirname(__FILE__) . '/lang');
107
}
@@ -149,5 +184,9 @@ function _cme_pp_default_pattern_role( $role ) {
149
}
150
}
151
152
if ( is_multisite() )
153
require_once ( dirname(__FILE__) . '/includes/network.php' );
3
* Plugin Name: Capability Manager Enhanced
4
* Plugin URI: https://publishpress.com
5
* Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6
+ * Version: 1.7
7
* Author: PublishPress
8
* Author URI: https://publishpress.com
9
* Text Domain: capsman-enhanced
23
* @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2019 PublishPress
24
* @license GNU General Public License version 3
25
* @link https://publishpress.com
26
+ * @version 1.7
27
*/
28
29
if ( ! defined( 'CAPSMAN_VERSION' ) ) {
30
+ define( 'CAPSMAN_VERSION', '1.7' );
31
+ define( 'CAPSMAN_ENH_VERSION', '1.7' );
32
}
33
34
if ( cme_is_plugin_active( 'capsman.php' ) ) {
95
add_action( 'init', '_cme_init' );
96
add_action( 'plugins_loaded', '_cme_act_pp_active', 1 );
97
98
+ add_action( 'init', '_cme_cap_helper', 49 ); // Press Permit Cap Helper, registered at 50, will leave caps which we've already defined
99
+ //add_action( 'wp_loaded', '_cme_cap_helper_late_init', 99 ); // now instead adding registered_post_type, registered_taxonomy action handlers for latecomers
100
+ // @todo: do this in PP Core also
101
+
102
function _cme_act_pp_active() {
103
+ if ( defined('PRESSPERMIT_VERSION') || ( defined('PPC_VERSION') && function_exists( 'pp_init_cap_caster' ) ) ) {
104
+ define( 'PRESSPERMIT_ACTIVE', true );
105
+ } else {
106
+ if ( defined('SCOPER_VERSION') || ( defined('PP_VERSION') && function_exists('pp_init_users_interceptor') ) ) {
107
+ define( 'OLD_PRESSPERMIT_ACTIVE', true );
108
+ }
109
+ }
110
+ }
111
+
112
+ function _cme_cap_helper() {
113
+ global $cme_cap_helper;
114
+
115
+ require_once ( dirname(__FILE__) . '/includes/cap-helper.php' );
116
+ $cme_cap_helper = new CME_Cap_Helper();
117
+
118
+ add_action( 'registered_post_type', '_cme_post_type_late_reg', 5, 2 );
119
+ add_action( 'registered_taxonomy', '_cme_taxonomy_late_reg', 5, 2 );
120
+ }
121
+
122
+ function _cme_post_type_late_reg( $post_type, $type_obj ) {
123
+ global $cme_cap_helper;
124
+
125
+ if ( ! empty( $type_obj->public ) || ! empty( $type_obj->show_ui ) ) {
126
+ $cme_cap_helper->refresh();
127
+ }
128
+ }
129
+
130
+ function _cme_taxonomy_late_reg( $taxonomy, $tx_obj ) {
131
+ global $cme_cap_helper;
132
+
133
+ if ( ! empty( $tx_obj->public ) ) {
134
+ $cme_cap_helper->refresh();
135
+ }
136
}
137
138
function _cme_init() {
139
+ require_once ( dirname(__FILE__) . '/includes/filters.php' );
140
141
load_plugin_textdomain('capsman-enhanced', false, dirname(__FILE__) . '/lang');
142
}
184
}
185
}
186
187
+ function capsman_get_pp_option( $option_basename ) {
188
+ return ( function_exists( 'presspermit_get_option') ) ? presspermit_get_option($option_basename) : capsman_get_pp_option($option_basename);
189
+ }
190
+
191
if ( is_multisite() )
192
require_once ( dirname(__FILE__) . '/includes/network.php' );
framework/styles/admin.css CHANGED
@@ -113,6 +113,10 @@ table#akmin td.sidebar a {
113
border: 0 none;
114
display: block;
115
}
116
117
table#akmin td.sidebar ul li {
118
margin: 0;
113
border: 0 none;
114
display: block;
115
}
116
+
117
+ table#akmin td.sidebar .cme-backup-tool a {
118
+ padding-left: 0;
119
+ }
120
121
table#akmin td.sidebar ul li {
122
margin: 0;
includes/admin.php CHANGED
@@ -8,43 +8,47 @@
8
* @license GNU General Public License version 2
9
* @link https://publishpress.com
10
*
11
12
- Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
13
- Modifications Copyright 2019, PublishPress <help@publishpress.com>
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- version 2 as published by the Free Software Foundation.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
24
- You should have received a copy of the GNU General Public License
25
- along with this program. If not, see <http://www.gnu.org/licenses/>.
26
- */
27
28
- if ( in_array( $this->current, $this->core_roles ) ) {
29
- $role_obj = get_role( $this->current );
30
-
31
- if ( empty( $role_obj->capabilities['read'] ) ) {
32
- ak_admin_error( sprintf( __( 'Warning: This role may not work correctly because it does not have the read capability. %1$sClick here to fix this now%2$s.', 'capsman-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
33
}
34
}
35
-
36
- $roles = $this->roles;
37
- $default = $this->current;
38
39
- if( defined('PP_ACTIVE') ) {
40
- require_once( dirname(__FILE__).'/pp-ui.php' );
41
- $pp_ui = new Capsman_PP_UI();
42
$pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
43
- } else
44
$pp_metagroup_caps = array();
45
?>
46
<div class="wrap">
47
- <?php if( defined('PP_ACTIVE') ) :
48
pp_icon();
49
$style = 'style="height:60px;"';
50
?>
@@ -68,111 +72,112 @@ if( defined('PP_ACTIVE') ) {
68
<div style="float:right">
69
<input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
70
</div>
71
-
72
- <div>
73
- <?php _e( 'View and modify capabilities WordPress associates with each role. Changes <strong>remain in the database</strong> even if you deactivate this plugin.', 'capsman-enhanced' ); ?>
74
- </div>
75
76
<?php
77
- if ( defined( 'PP_ACTIVE' ) ) {
78
$pp_ui->show_capability_hints( $default );
79
- }
80
-
81
- global $capsman;
82
- $img_url = $capsman->mod_url . '/images/';
83
- ?>
84
- <div style="margin-top:5px">
85
- <span class="publishpress"><?php printf( __( 'Thanks for using the %1$sPublishPress%2$s family of professional publishing tools.', 'capsman-enhanced'), '<a href="https://publishpress.com/" target="_blank">', '</a>' );?></span>
86
- </div>
87
-
88
- <script type="text/javascript">
89
- /* <![CDATA[ */
90
- jQuery(document).ready( function($) {
91
- $('a[href="#pp-more"]').click( function() {
92
- $('#pp_features').show();
93
- return false;
94
- });
95
- $('a[href="#pp-hide"]').click( function() {
96
- $('#pp_features').hide();
97
- return false;
98
- });
99
});
100
- /* ]]> */
101
- </script>
102
- <style>
103
- #pp_features {display:none;border:1px solid #eee;padding:5px;text-align:center;min-width:600px}
104
- div.pp-logo { text-align: center }
105
- div.features-wrap { margin-left: auto; margin-right: auto; text-align: center; width: 540px; }
106
- ul.pp-features { list-style: none; padding-top:10px; text-align:left; margin-left: auto }
107
- ul.pp-features li:before { content: "\2713\0020"; }
108
- ul.pp-features li { padding-bottom: 5px }
109
- img.cme-play { margin-bottom: -3px; margin-left: 5px;}
110
- </style>
111
-
112
- <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
113
-
114
- <br /><div id="pp_features"><div class="pp-logo"><a href="http://presspermit.com"><img src="<?php echo $img_url;?>pp-logo.png" /></a></div><div class="features-wrap"><ul class="pp-features">
115
- <li>
116
- <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
117
- <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
118
-
119
- <li>
120
- <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
121
- <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
122
-
123
- <li>
124
- <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
125
- <a href="http://presspermit.com/tutorial/custom-role-usage" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
126
-
127
- <li>
128
- <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
129
- <a href="http://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
130
-
131
- <li>
132
- <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
133
- <a href="http://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
134
-
135
- <li>
136
- <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
137
- <a href="http://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
138
-
139
- <li>
140
- <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
141
- <a href="http://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
142
-
143
- <li>
144
- <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
145
- <a href="http://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
146
-
147
- <li>
148
- <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
149
- <a href="http://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
150
-
151
- <li>
152
- <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
153
- <a href="http://presspermit.com/tutorial/bbpress-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
154
-
155
- <li>
156
- <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
157
- <a href="http://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
158
-
159
- <li>
160
- <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
161
- </li>
162
-
163
- <li>
164
- <?php _e( "Member support forum", 'capsman-enhanced' );?>
165
- </li>
166
-
167
- </ul></div>
168
- <?php
169
- echo '<div>';
170
- printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Press Permit Core' ) . '">Press&nbsp;Permit&nbsp;Core</a></span>' );
171
- echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
172
- printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="http://presspermit.com" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Press Permit Pro' ) . '">Press&nbsp;Permit&nbsp;Pro</a>' );
173
- echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
174
- echo '<a href="#pp-hide">hide</a>';
175
- echo '</div></div>';
176
177
if ( MULTISITE ) {
178
global $wp_roles;
@@ -185,26 +190,26 @@ if( defined('PP_ACTIVE') ) {
185
186
( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
187
}
188
-
189
- global $capsman;
190
$capsman->reinstate_db_roles();
191
192
$current = get_role($default);
193
194
$rcaps = $current->capabilities;
195
196
- // ========= Begin Kevin B mod ===========
197
$is_administrator = current_user_can( 'administrator' );
198
199
$custom_types = get_post_types( array( '_builtin' => false ), 'names' );
200
$custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
201
202
$defined = array();
203
- $defined['type'] = get_post_types( array( 'public' => true ), 'object' );
204
$defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
205
206
- $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array('forum','topic','reply') ); // bbPress' dynamic role def requires additional code to enforce stored caps
207
$unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy
208
/*
209
if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
210
$cap_properties[''] = array();
@@ -228,13 +233,13 @@ if( defined('PP_ACTIVE') ) {
228
229
$cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
230
231
- if ( ! defined( 'PP_ACTIVE' ) )
232
$cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
233
234
$cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
235
$cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
236
237
- if ( ! defined( 'PP_ACTIVE' ) )
238
$cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
239
else
240
$cap_properties['delete']['taxonomy'] = array();
@@ -271,9 +276,10 @@ if( defined('PP_ACTIVE') ) {
271
$type_caps = array();
272
273
// Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
274
- if ( defined('SCOPER_VERSION') || ( defined( 'PP_ACTIVE' ) && ! defined( 'PPC_VERSION' ) ) )
275
unset( $defined['type']['attachment'] );
276
-
277
echo '<ul class="cme-listhoriz">';
278
279
// cap_types: read, edit, deletion
@@ -284,8 +290,9 @@ if( defined('PP_ACTIVE') ) {
284
285
foreach( array_keys($defined) as $item_type ) {
286
if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
287
- if ( defined('SCOPER_VERSION') || defined('PP_ACTIVE') )
288
continue;
289
290
$any_term_deletion_caps = false;
291
foreach( array_keys($defined['taxonomy']) as $_tax ) {
@@ -316,14 +323,18 @@ if( defined('PP_ACTIVE') ) {
316
$prop = str_replace( '_', '<br />', $prop );
317
$th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
318
echo "<th $tip{$th_class}>";
319
- echo ucwords($prop);
320
echo '</th>';
321
}
322
323
foreach( $defined[$item_type] as $key => $type_obj ) {
324
if ( in_array( $key, $unfiltered[$item_type] ) )
325
continue;
326
-
327
$row = "<tr class='cme_type_{$key}'>";
328
329
if ( $cap_type ) {
@@ -333,12 +344,13 @@ if( defined('PP_ACTIVE') ) {
333
$row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_obj->labels->name . '</a>';
334
$row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
335
$row .= '</td>';
336
-
337
$display_row = ! empty($force_distinct_ui);
338
339
foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
340
$td_classes = array();
341
$checkbox = '';
342
343
if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
344
|| ! in_array( $type_obj->cap->$prop, $default_caps )
@@ -347,7 +359,28 @@ if( defined('PP_ACTIVE') ) {
347
// if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
348
if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
349
&& ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
350
) {
351
$cap_name = $type_obj->cap->$prop;
352
353
if ( 'taxonomy' == $item_type )
@@ -372,17 +405,21 @@ if( defined('PP_ACTIVE') ) {
372
$type_caps [$cap_name] = true;
373
$display_row = true;
374
}
375
- } else
376
- $td_classes []= "cap-unreg";
377
378
- if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) )
379
$td_classes []= "cap-neg";
380
- } else
381
$td_classes []= "cap-unreg";
382
383
$td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
384
385
- $row .= "<td $td_class><span class='cap-x'>X</span>$checkbox";
386
387
if ( false !== strpos( $td_class, 'cap-neg' ) )
388
$row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
@@ -421,21 +458,14 @@ if( defined('PP_ACTIVE') ) {
421
/* ]]> */
422
</script>
423
<?php
424
-
425
- $core_caps = array_fill_keys( array( 'switch_themes', 'edit_themes', 'activate_plugins', 'edit_plugins', 'edit_users', 'edit_files', 'manage_options', 'moderate_comments',
426
- 'manage_links', 'upload_files', 'import', 'unfiltered_html', 'read', 'delete_users', 'create_users', 'unfiltered_upload', 'edit_dashboard',
427
- 'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes', 'install_themes',
428
- 'update_core', 'list_users', 'remove_users', 'add_users', 'promote_users', 'edit_theme_options', 'delete_themes', 'export' ), true );
429
-
430
- ksort( $core_caps );
431
432
echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
433
echo '<table width="100%" class="form-table cme-checklist"><tr>';
434
435
-
436
$checks_per_row = get_option( 'cme_form-rows', 5 );
437
$i = 0; $first_row = true;
438
439
foreach( array_keys($core_caps) as $cap_name ) {
440
if ( ! $is_administrator && ! current_user_can($cap_name) )
441
continue;
@@ -460,22 +490,26 @@ if( defined('PP_ACTIVE') ) {
460
$disabled = '';
461
$checked = checked(1, ! empty($rcaps[$cap_name]), false );
462
$lock_capability = false;
463
464
if ( 'read' == $cap_name ) {
465
- if ( in_array( $default, $this->core_roles ) ) {
466
// prevent the read capability from being removed from a core role, but don't force it to be added
467
if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
468
if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
469
$lock_capability = true;
470
$class .= ' cap-locked';
471
$disabled = 'disabled="disabled"';
472
}
473
}
474
}
475
}
476
477
?>
478
- <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label for="caps[<?php echo $cap_name; ?>]" title="<?php echo $title_text;?>"><input id=caps[<?php echo $cap_name; ?>] type="checkbox" name="caps[<?php echo $cap_name; ?>]" value="1" <?php echo $checked . $disabled;?> />
479
<span>
480
<?php
481
echo str_replace( '_', ' ', $cap_name );
@@ -633,7 +667,7 @@ if( defined('PP_ACTIVE') ) {
633
</table>
634
635
<br />
636
- <?php if ( ! defined('PP_ACTIVE') || pp_get_option('display_hints') ) :?>
637
<div class="cme-subtext">
638
<?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'capsman-enhanced' ); ?>
639
</div>
@@ -644,7 +678,7 @@ if( defined('PP_ACTIVE') ) {
644
</dl>
645
646
<?php
647
- $support_pp_only_roles = ( defined('PP_ACTIVE') ) ? $pp_ui->pp_only_roles_ui( $default ) : false;
648
cme_network_role_ui( $default );
649
?>
650
@@ -654,7 +688,7 @@ if( defined('PP_ACTIVE') ) {
654
<input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
655
656
<?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
657
- <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&amp;action=delete&amp;role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
658
<?php endif; ?>
659
</p>
660
@@ -685,7 +719,7 @@ if( defined('PP_ACTIVE') ) {
685
<dt><?php _e('Create New Role', 'capsman-enhanced'); ?></dt>
686
<dd style="text-align:center;">
687
<?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
688
- <p><input type="text" name="create-name"" class="<?php echo $class;?>" placeholder="<?php _e('Name of new role', 'capsman-enhanced') ?>" />
689
690
<?php if( $support_pp_only_roles ) : ?>
691
<label for="new_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="new_role_pp_only" id="new_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
@@ -701,7 +735,7 @@ if( defined('PP_ACTIVE') ) {
701
<dt><?php defined('WPLANG') && WPLANG ? _e('Copy this role to', 'capsman-enhanced') : printf( 'Copy %s Role', $roles[$default] ); ?></dt>
702
<dd style="text-align:center;">
703
<?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
704
- <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Name of copied role', 'capsman-enhanced') ?>" />
705
706
<?php if( $support_pp_only_roles ) : ?>
707
<label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
@@ -716,12 +750,12 @@ if( defined('PP_ACTIVE') ) {
716
<dl>
717
<dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
718
<dd style="text-align:center;">
719
- <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php _e('capability name', 'capsman-enhanced') ?>" /><br />
720
<input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
721
</dd>
722
</dl>
723
724
- <dl>
725
<dt><?php _e('Backup Tool', 'capsman-enhanced'); ?></dt>
726
<dd style="text-align:center;">
727
<p><a href="tools.php?page=capsman-tool"><?php _e('Backup / Restore Roles', 'capsman-enhanced');?></a></p>
@@ -743,11 +777,13 @@ if( defined('PP_ACTIVE') ) {
743
$url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
744
?>
745
<li><a class="thickbox" href="<?php echo $url;?>"><?php _e('Revisionary', 'capsman-enhanced');?></a></li>
746
</ul>
747
</dl>
748
749
- <?php if ( defined('PP_ACTIVE') )
750
- $pp_ui->pp_types_ui( $defined );
751
?>
752
</td>
753
</tr>
8
* @license GNU General Public License version 2
9
* @link https://publishpress.com
10
*
11
+ *
12
+ * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
13
+ * Modifications Copyright 2019, PublishPress <help@publishpress.com>
14
+ *
15
+ * This program is free software; you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License
17
+ * version 2 as published by the Free Software Foundation.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
+ **/
27
28
+ global $capsman, $cme_cap_helper;
29
30
+ $roles = $this->roles;
31
+ $default = $this->current;
32
33
+ if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
34
+ if ( $current = get_role($default) ) {
35
+ if ( empty( $current->capabilities['read'] ) ) {
36
+ ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capsman-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
37
+ }
38
}
39
}
40
41
+ require_once( dirname(__FILE__).'/pp-ui.php' );
42
+ $pp_ui = new Capsman_PP_UI();
43
+
44
+ if( defined('PRESSPERMIT_ACTIVE') ) {
45
$pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
46
+ } else {
47
$pp_metagroup_caps = array();
48
+ }
49
?>
50
<div class="wrap">
51
+ <?php if( defined('PRESSPERMIT_ACTIVE') ) :
52
pp_icon();
53
$style = 'style="height:60px;"';
54
?>
72
<div style="float:right">
73
<input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
74
</div>
75
76
<?php
77
+ global $capsman;
78
+ $img_url = $capsman->mod_url . '/images/';
79
+ ?>
80
+ <div class="publishpress-headline">
81
+ <span class="cme-subtext">
82
+ <?php _e( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' ); ?>
83
+ </span>
84
+ <span class="publishpress-thanks"> <?php printf( __( 'Thanks for using the %1$sPublishPress%2$s family of professional publishing tools.', 'capsman-enhanced'), '<a href="https://publishpress.com/" target="_blank">', '</a>' );?></span>
85
+ </div>
86
+
87
+ <?php
88
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
89
$pp_ui->show_capability_hints( $default );
90
+ }
91
+ ?>
92
+
93
+ <script type="text/javascript">
94
+ /* <![CDATA[ */
95
+ jQuery(document).ready( function($) {
96
+ $('a[href="#pp-more"]').click( function() {
97
+ $('#pp_features').show();
98
+ return false;
99
});
100
+ $('a[href="#pp-hide"]').click( function() {
101
+ $('#pp_features').hide();
102
+ return false;
103
+ });
104
+ });
105
+ /* ]]> */
106
+ </script>
107
+ <style>
108
+ #pp_features {display:none;border:1px solid #eee;padding:5px;text-align:center;min-width:600px}
109
+ div.pp-logo { text-align: center }
110
+ div.features-wrap { margin-left: auto; margin-right: auto; text-align: center; width: 540px; }
111
+ ul.pp-features { list-style: none; padding-top:10px; text-align:left; margin-left: auto }
112
+ ul.pp-features li:before { content: "\2713\0020"; }
113
+ ul.pp-features li { padding-bottom: 5px }
114
+ img.cme-play { margin-bottom: -3px; margin-left: 5px;}
115
+ </style>
116
+
117
+ <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
118
+
119
+ <br /><div id="pp_features"><div class="pp-logo"><a href="http://presspermit.com"><img src="<?php echo $img_url;?>pp-logo.png" /></a></div><div class="features-wrap"><ul class="pp-features">
120
+ <li>
121
+ <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
122
+ <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
123
+
124
+ <li>
125
+ <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
126
+ <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
127
+
128
+ <li>
129
+ <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
130
+ <a href="http://presspermit.com/tutorial/custom-role-usage" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
131
+
132
+ <li>
133
+ <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
134
+ <a href="http://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
135
+
136
+ <li>
137
+ <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
138
+ <a href="http://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
139
+
140
+ <li>
141
+ <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
142
+ <a href="http://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
143
+
144
+ <li>
145
+ <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
146
+ <a href="http://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
147
+
148
+ <li>
149
+ <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
150
+ <a href="http://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
151
+
152
+ <li>
153
+ <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
154
+ <a href="http://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
155
+
156
+ <li>
157
+ <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
158
+ <a href="http://presspermit.com/tutorial/bbpress-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
159
+
160
+ <li>
161
+ <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
162
+ <a href="http://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
163
+
164
+ <li>
165
+ <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
166
+ </li>
167
+
168
+ <li>
169
+ <?php _e( "Member support forum", 'capsman-enhanced' );?>
170
+ </li>
171
+
172
+ </ul></div>
173
+ <?php
174
+ echo '<div>';
175
+ printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Press Permit Core' ) . '">Press&nbsp;Permit&nbsp;Core</a></span>' );
176
+ echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
177
+ printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="http://presspermit.com" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Press Permit Pro' ) . '">Press&nbsp;Permit&nbsp;Pro</a>' );
178
+ echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
179
+ echo '<a href="#pp-hide">hide</a>';
180
+ echo '</div></div>';
181
182
if ( MULTISITE ) {
183
global $wp_roles;
190
191
( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
192
}
193
$capsman->reinstate_db_roles();
194
195
$current = get_role($default);
196
197
$rcaps = $current->capabilities;
198
199
$is_administrator = current_user_can( 'administrator' );
200
201
$custom_types = get_post_types( array( '_builtin' => false ), 'names' );
202
$custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
203
204
$defined = array();
205
+ $defined['type'] = get_post_types( array( 'public' => true, 'show_ui' => true ), 'object', 'or' );
206
$defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
207
208
+ $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array( 'forum','topic','reply','wp_block' ) ); // bbPress' dynamic role def requires additional code to enforce stored caps
209
$unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy
210
+
211
+ $enabled_taxonomies = cme_get_assisted_taxonomies();
212
+
213
/*
214
if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
215
$cap_properties[''] = array();
233
234
$cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
235
236
+ if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
237
$cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
238
239
$cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
240
$cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
241
242
+ if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
243
$cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
244
else
245
$cap_properties['delete']['taxonomy'] = array();
276
$type_caps = array();
277
278
// Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
279
+ if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
280
unset( $defined['type']['attachment'] );
281
+ }
282
+
283
echo '<ul class="cme-listhoriz">';
284
285
// cap_types: read, edit, deletion
290
291
foreach( array_keys($defined) as $item_type ) {
292
if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
293
+ if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
294
continue;
295
+ }
296
297
$any_term_deletion_caps = false;
298
foreach( array_keys($defined['taxonomy']) as $_tax ) {
323
$prop = str_replace( '_', '<br />', $prop );
324
$th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
325
echo "<th $tip{$th_class}>";
326
+
327
+ if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
328
+ echo ucwords($prop);
329
+ }
330
+
331
echo '</th>';
332
}
333
334
foreach( $defined[$item_type] as $key => $type_obj ) {
335
if ( in_array( $key, $unfiltered[$item_type] ) )
336
continue;
337
+
338
$row = "<tr class='cme_type_{$key}'>";
339
340
if ( $cap_type ) {
344
$row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_obj->labels->name . '</a>';
345
$row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
346
$row .= '</td>';
347
+
348
$display_row = ! empty($force_distinct_ui);
349
350
foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
351
$td_classes = array();
352
$checkbox = '';
353
+ $title = '';
354
355
if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
356
|| ! in_array( $type_obj->cap->$prop, $default_caps )
359
// if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
360
if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
361
&& ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
362
+ && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
363
+
364
+ && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
365
+ || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
366
+ || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
367
+ || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
368
+ )
369
+
370
+ && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
371
+ || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
372
+ || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
373
+ || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
374
+ || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
375
+ || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
376
+ || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
377
+ )
378
) {
379
+ // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
380
+ if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
381
+ continue;
382
+ }
383
+
384
$cap_name = $type_obj->cap->$prop;
385
386
if ( 'taxonomy' == $item_type )
405
$type_caps [$cap_name] = true;
406
$display_row = true;
407
}
408
+ } else {
409
+ //$td_classes []= "cap-unreg";
410
+ $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
411
+ }
412
413
+ if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
414
$td_classes []= "cap-neg";
415
+ }
416
+ } else {
417
$td_classes []= "cap-unreg";
418
+ }
419
420
$td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
421
422
+ $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
423
424
if ( false !== strpos( $td_class, 'cap-neg' ) )
425
$row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
458
/* ]]> */
459
</script>
460
<?php
461
462
echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
463
echo '<table width="100%" class="form-table cme-checklist"><tr>';
464
465
$checks_per_row = get_option( 'cme_form-rows', 5 );
466
$i = 0; $first_row = true;
467
468
+ $core_caps = _cme_core_caps();
469
foreach( array_keys($core_caps) as $cap_name ) {
470
if ( ! $is_administrator && ! current_user_can($cap_name) )
471
continue;
490
$disabled = '';
491
$checked = checked(1, ! empty($rcaps[$cap_name]), false );
492
$lock_capability = false;
493
+ $title = $title_text;
494
495
if ( 'read' == $cap_name ) {
496
+ if ( ! empty( $block_read_removal ) ) {
497
// prevent the read capability from being removed from a core role, but don't force it to be added
498
if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
499
if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
500
$lock_capability = true;
501
$class .= ' cap-locked';
502
$disabled = 'disabled="disabled"';
503
+ if ( 'administrator' != $this->current ) {
504
+ $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
505
+ }
506
}
507
}
508
}
509
}
510
511
?>
512
+ <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label for="caps[<?php echo $cap_name; ?>]" title="<?php echo $title;?>"><input id=caps[<?php echo $cap_name; ?>] type="checkbox" name="caps[<?php echo $cap_name; ?>]" value="1" <?php echo $checked . $disabled;?> />
513
<span>
514
<?php
515
echo str_replace( '_', ' ', $cap_name );
667
</table>
668
669
<br />
670
+ <?php if ( ! defined('PRESSPERMIT_ACTIVE') || capsman_get_pp_option('display_hints') ) :?>
671
<div class="cme-subtext">
672
<?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'capsman-enhanced' ); ?>
673
</div>
678
</dl>
679
680
<?php
681
+ $support_pp_only_roles = ( defined('PRESSPERMIT_ACTIVE') ) ? $pp_ui->pp_only_roles_ui( $default ) : false;
682
cme_network_role_ui( $default );
683
?>
684
688
<input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
689
690
<?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
691
+ <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&amp;action=delete&amp;role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
692
<?php endif; ?>
693
</p>
694
719
<dt><?php _e('Create New Role', 'capsman-enhanced'); ?></dt>
720
<dd style="text-align:center;">
721
<?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
722
+ <p><input type="text" name="create-name"" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
723
724
<?php if( $support_pp_only_roles ) : ?>
725
<label for="new_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="new_role_pp_only" id="new_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
735
<dt><?php defined('WPLANG') && WPLANG ? _e('Copy this role to', 'capsman-enhanced') : printf( 'Copy %s Role', $roles[$default] ); ?></dt>
736
<dd style="text-align:center;">
737
<?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
738
+ <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
739
740
<?php if( $support_pp_only_roles ) : ?>
741
<label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
750
<dl>
751
<dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
752
<dd style="text-align:center;">
753
+ <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
754
<input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
755
</dd>
756
</dl>
757
758
+ <dl class="cme-backup-tool">
759
<dt><?php _e('Backup Tool', 'capsman-enhanced'); ?></dt>
760
<dd style="text-align:center;">
761
<p><a href="tools.php?page=capsman-tool"><?php _e('Backup / Restore Roles', 'capsman-enhanced');?></a></p>
777
$url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
778
?>
779
<li><a class="thickbox" href="<?php echo $url;?>"><?php _e('Revisionary', 'capsman-enhanced');?></a></li>
780
+ <li class="publishpress-contact"><a href="https://publishpress.com/contact" target="_blank"><?php _e('Help / Contact Form', 'capsman-enhanced');?></a></li>
781
</ul>
782
</dl>
783
784
+ <?php
785
+ $pp_ui->pp_types_ui( $defined['type'] );
786
+ $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
787
?>
788
</td>
789
</tr>
includes/cap-helper.php ADDED
@@ -0,0 +1,348 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ // @todo: port improvements back to PP Core
5
+
6
+ class CME_Cap_Helper {
7
+ var $all_taxonomy_caps = array(); // $all_taxonomy_caps = array of capability names
8
+ var $all_type_caps = array(); // $all_type_caps = array of capability names
9
+ var $processed_types = array();
10
+ var $processed_taxonomies = array();
11
+
12
+ function __construct() {
13
+ $this->refresh();
14
+ }
15
+
16
+ function refresh() {
17
+ $this->force_distinct_post_caps();
18
+
19
+ // Work around bug in More Taxonomies (and possibly other plugins) where category taxonomy is overriden without setting it public
20
+ foreach( array( 'category', 'post_tag' ) as $taxonomy ) {
21
+ global $wp_taxonomies;
22
+ if ( isset( $wp_taxonomies[$taxonomy] ) )
23
+ $wp_taxonomies[$taxonomy]->public = true;
24
+ }
25
+
26
+ $this->force_distinct_taxonomy_caps();
27
+ }
28
+
29
+ function force_distinct_post_caps() { // for selected post types (as stored in option array pp_enabled_post_types)
30
+ global $wp_post_types, $wp_roles;
31
+
32
+ $core_meta_caps = array_fill_keys( array( 'read_post', 'edit_post', 'delete_post' ), true );
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";
40
+ }
41
+ }
42
+
43
+ foreach( cme_get_assisted_post_types() as $post_type ) {
44
+ if ( ! in_array( $post_type, array( 'post', 'page' ) ) ) {
45
+ if ( $wp_post_types[$post_type]->cap->create_posts == $wp_post_types[$post_type]->cap->edit_posts ) {
46
+ $wp_post_types[$post_type]->cap->create_posts = str_replace( 'edit_', 'create_', $wp_post_types[$post_type]->cap->edit_posts );
47
+ }
48
+ }
49
+ }
50
+
51
+ $append_caps['create_posts'] = 'create_posts';
52
+ }
53
+
54
+ // count the number of post types that use each capability
55
+ foreach( $wp_post_types as $post_type => $type_obj ) {
56
+ foreach( array_unique( (array) $type_obj->cap ) as $cap_name ) {
57
+ if ( ! isset( $this->all_type_caps[$cap_name] ) ) {
58
+ $this->all_type_caps[$cap_name] = 1;
59
+ } else {
60
+ $this->all_type_caps[$cap_name]++;
61
+ }
62
+ }
63
+ }
64
+
65
+ $post_caps = (array) $wp_post_types['post']->cap;
66
+ $page_caps = ( isset( $wp_post_types['page'] ) ) ? (array) $wp_post_types['page']->cap : array();
67
+
68
+ $enabled_types = array_diff( cme_get_assisted_post_types(), $this->processed_types );
69
+
70
+ // post types which are enabled for PP filtering must have distinct type-related cap definitions
71
+ foreach( $enabled_types as $post_type ) {
72
+ // append missing capability definitions
73
+ foreach( $append_caps as $prop => $default ) {
74
+ if ( ! isset( $wp_post_types[$post_type]->cap->$prop ) ) {
75
+ $wp_post_types[$post_type]->cap->$prop = ( 'read' == $prop ) ? 'read' : $wp_post_types[$post_type]->cap->$default;
76
+ }
77
+ }
78
+
79
+ $wp_post_types[$post_type]->map_meta_cap = true;
80
+
81
+ $type_caps = array_diff_key( (array) $wp_post_types[$post_type]->cap, $core_meta_caps );
82
+
83
+ $cap_base = ( 'attachment' == $post_type ) ? 'file' : $post_type;
84
+
85
+ $cap_properties = array_keys( $type_caps );
86
+
87
+ if ( 'attachment' == $post_type ) {
88
+ $cap_properties = array_diff( $cap_properties, array( 'publish_posts', 'edit_published_posts', 'delete_published_posts', 'edit_private_posts', 'delete_private_posts', 'read_private_posts' ) );
89
+ }
90
+
91
+ // 'read' is not converted to a type-specific equivalent, so disregard it for perf.
92
+ $cap_properties = array_diff( $cap_properties, array( 'read' ) );
93
+
94
+ foreach( $cap_properties as $k => $cap_property ) {
95
+ // If a cap property is set to one of the generic post type's caps, we will replace it
96
+ if ( ( 'post' != $post_type ) && in_array( $type_caps[$cap_property], $post_caps ) ) {
97
+ continue;
98
+ }
99
+
100
+ if ( ( 'page' != $post_type ) && in_array( $type_caps[$cap_property], $page_caps ) ) {
101
+ continue;
102
+ }
103
+
104
+ // If a cap property is non-generic and not used by any other post types, keep it as is
105
+ if ( $this->all_type_caps[ $type_caps[$cap_property] ] <= 1 ) {
106
+ unset( $cap_properties[$k] );
107
+
108
+ // If a cap property is used by any other post types, still keep it if it is the standard type-specific capability form for this post type
109
+ } elseif ( ( $type_caps[$cap_property] == str_replace( "_posts", "_{$post_type}s", $cap_property ) )
110
+ || ( $type_caps[$cap_property] == str_replace( "_pages", "_{$post_type}s", $cap_property ) ) ) {
111
+
112
+ unset( $cap_properties[$k] );
113
+
114
+ // If a cap property is used by any other post types, still keep it if it is the custom pluralized type-specific capability form for this post type
115
+ } else {
116
+ $plural_type = _cme_get_plural( $post_type, $wp_post_types[$post_type] );
117
+ if ( ( $type_caps[$cap_property] == str_replace( "_posts", "_{$plural_type}", $cap_property ) )
118
+ || ( $type_caps[$cap_property] == str_replace( "_pages", "_{$plural_type}", $cap_property ) ) ) {
119
+
120
+ unset( $cap_properties[$k] );
121
+ }
122
+ }
123
+ }
124
+
125
+ if ( ! $cap_properties ) {
126
+ // This post type has no defaulted cap properties that need to be made type-specific.
127
+ continue;
128
+ }
129
+
130
+ // Default plural slug
131
+ //$plural_type = "{$cap_base}s";
132
+
133
+ $plural_type = _cme_get_plural( $post_type, $wp_post_types[$post_type] );
134
+
135
+ if ( "{$cap_base}s" != $plural_type ) {
136
+ // If any role already has capabilities based on simple plural form, keep using that instead
137
+ foreach ( $wp_roles as $role ) {
138
+ foreach( array_keys( $type_caps ) as $cap_property ) {
139
+ $generic_type = ( strpos( $cap_property, '_pages' ) ) ? 'page' : 'post';
140
+
141
+ $simple_plural = str_replace( "_{$generic_type}s", "_{$cap_base}s", $cap_property );
142
+
143
+ if ( isset( $role->capabilities[$simple_plural] ) ) {
144
+ // A simple plural capability was manually stored to a role, so stick with that form
145
+ $plural_type = "{$cap_base}s";
146
+ break 2;
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ // Replace "edit_posts" and other post type caps with an equivalent for this post type, using pluralization determined above.
153
+ // If a this is a problem, register the post type with an array capability_type arg including the desired plural form.
154
+ // It is also possible to modify existing $wp_post_types[$post_type]->cap values by hooking to the init action at priority 40.
155
+ foreach( $cap_properties as $cap_property ) {
156
+ // create_posts capability may be defaulted to "edit_posts" / "edit_pages"
157
+ $generic_type = ( strpos( $cap_property, '_pages' ) ) ? 'page' : 'post';
158
+
159
+ $target_cap_property = ( 'create_posts' == $cap_property ) ? $wp_post_types[$generic_type]->cap->$cap_property : $cap_property;
160
+
161
+ if ( $plural_type != "{$cap_base}s" ) {
162
+ // Since plural form is not simple, first replace plurals ('edit_posts' > 'edit_doohickies')
163
+ $wp_post_types[$post_type]->cap->$cap_property = str_replace( "_{$generic_type}s", "_{$plural_type}", $target_cap_property );
164
+ } else {
165
+ // Replace based on simple plural ('edit_posts' > 'edit_doohickys')
166
+ $wp_post_types[$post_type]->cap->$cap_property = str_replace( "_{$generic_type}", "_{$cap_base}", $target_cap_property );
167
+ }
168
+ }
169
+
170
+ // Force distinct capability_type. This may be an array with plural form in second element (but not useful here if set as default 'post' / 'posts' ).
171
+ // Some caution here against changing the variable data type. Although array is supported, other plugin code may assume string.
172
+ if ( is_array( $wp_post_types[$post_type]->capability_type ) ) {
173
+ $wp_post_types[$post_type]->capability_type = array( $post_type, $plural_type );
174
+
175
+ } elseif ( in_array( $wp_post_types[$post_type]->capability_type, array('post','page') ) ) {
176
+ $wp_post_types[$post_type]->capability_type = $post_type;
177
+ }
178
+
179
+ $type_caps = array_diff_key( (array) $wp_post_types[$post_type]->cap, $core_meta_caps );
180
+
181
+ $wp_post_types[$post_type]->cap = (object) array_merge( (array) $wp_post_types[$post_type]->cap, $type_caps );
182
+
183
+ //$this->all_type_caps = array_merge( $this->all_type_caps, array_fill_keys( $type_caps, true ) );
184
+
185
+ foreach( array_unique( (array) $wp_post_types[$post_type]->cap ) as $cap_name ) {
186
+ if ( ! isset( $this->all_type_caps[$cap_name] ) ) {
187
+ $this->all_type_caps[$cap_name] = 1;
188
+ } else {
189
+ $this->all_type_caps[$cap_name]++;
190
+ }
191
+ }
192
+
193
+ } // end foreach post type
194
+
195
+ $this->processed_types = array_merge( $this->processed_types, $enabled_types );
196
+
197
+ // need this for casting to other types even if "post" type is not enabled for PP filtering
198
+ $wp_post_types['post']->cap->set_posts_status = 'set_posts_status';
199
+
200
+ if ( current_user_can( 'administrator' ) || current_user_can( 'pp_administer_content' ) ) { // @ todo: support restricted administrator
201
+ global $current_user;
202
+ $current_user->allcaps = array_merge( $current_user->allcaps, array_fill_keys( array_keys( $this->all_type_caps ), true ) );
203
+
204
+ global $pp_current_user;
205
+ if ( ! empty( $pp_current_user ) ) {
206
+ $pp_current_user->allcaps = array_merge( $pp_current_user->allcaps, array_fill_keys( array_keys( $this->all_type_caps ), true ) );
207
+ }
208
+ }
209
+
210
+ do_action( 'cme_distinct_post_capabilities', $enabled_types );
211
+ }
212
+
213
+ function force_distinct_taxonomy_caps() {
214
+ global $wp_taxonomies, $wp_roles;
215
+
216
+ $use_taxonomies = array_diff( cme_get_assisted_taxonomies(), $this->processed_taxonomies );
217
+ $detailed_taxonomies = cme_get_detailed_taxonomies();
218
+
219
+ $tx_specific_caps = array( 'manage_terms' => 'manage_terms', 'edit_terms' => 'manage_terms', 'delete_terms' => 'manage_terms' );
220
+ $tx_detail_caps = array( 'edit_terms' => 'edit_terms', 'delete_terms' => 'delete_terms', 'assign_terms' => 'assign_terms' );
221
+
222
+ $core_tx_caps = array();
223
+ $this->all_taxonomy_caps = array();
224
+
225
+ // currently, disallow category and post_tag cap use by selected custom taxonomies, but don't require category and post_tag to have different caps
226
+ $core_taxonomies = array( 'category' );
227
+ foreach( $core_taxonomies as $taxonomy ) {
228
+ foreach( array_keys($tx_specific_caps) as $cap_property ) {
229
+ $core_tx_caps[ $wp_taxonomies[$taxonomy]->cap->$cap_property ] = true;
230
+ }
231
+ }
232
+
233
+ // count the number of taxonomies that use each capability
234
+ foreach( $wp_taxonomies as $taxonomy => $tx_obj ) {
235
+ $this_tx_caps = array_unique( (array) $tx_obj->cap );
236
+
237
+ foreach( $this_tx_caps as $cap_name ) {
238
+ if ( ! isset( $this->all_taxonomy_caps[$cap_name] ) ) {
239
+ $this->all_taxonomy_caps[$cap_name] = 1;
240
+ } else {
241
+ $this->all_taxonomy_caps[$cap_name]++;
242
+ }
243
+ }
244
+ }
245
+
246
+ foreach( array_keys($wp_taxonomies) as $taxonomy ) {
247
+ if ( 'yes' == $wp_taxonomies[$taxonomy]->public ) { // clean up a GD Taxonomies quirk (otherwise wp_get_taxonomy_object will fail when filtering for public => true)
248
+ $wp_taxonomies[$taxonomy]->public = true;
249
+
250
+ } elseif ( ( '' === $wp_taxonomies[$taxonomy]->public ) && ( ! empty( $wp_taxonomies[$taxonomy]->query_var_bool ) ) ) { // clean up a More Taxonomies quirk (otherwise wp_get_taxonomy_object will fail when filtering for public => true)
251
+ $wp_taxonomies[$taxonomy]->public = true;
252
+ }
253
+
254
+ $tx_caps = (array) $wp_taxonomies[$taxonomy]->cap;
255
+
256
+ if ( ( ! in_array($taxonomy, $use_taxonomies) || empty( $wp_taxonomies[$taxonomy]->public ) ) && ( 'nav_menu' != $taxonomy ) )
257
+ continue;
258
+
259
+ if ( ! in_array( $taxonomy, $core_taxonomies ) ) {
260
+ // Default plural slug
261
+ //$plural_type = "{$taxonomy}s";
262
+
263
+ $plural_type = _cme_get_plural( $taxonomy, $wp_taxonomies[$taxonomy] );
264
+
265
+ if ( "{$taxonomy}s" != $plural_type ) {
266
+ // ... unless any role already has capabilities based on simple plural form
267
+ foreach ( $wp_roles as $role ) {
268
+ foreach( array_keys( $tx_caps ) as $cap_property ) {
269
+ $simple_plural = str_replace( "_terms", "_{$taxonomy}s", $cap_property );
270
+
271
+ if ( isset( $role->capabilities[$simple_plural] ) ) {
272
+ // A simple plural capability was manually stored to a role, so stick with that form
273
+ $plural_type = "{$taxonomy}s";
274
+ break 2;
275
+ }
276
+ }
277
+ }
278
+ }
279
+
280
+ // First, force taxonomy-specific capabilities.
281
+ // (Don't allow any capability defined for this taxonomy to match any capability defined for category or post tag (unless this IS category or post tag)
282
+ foreach( $tx_specific_caps as $cap_property => $replacement_cap_format ) {
283
+ // If this capability is also defined as another taxonomy cap, replace it
284
+ if ( ! empty($tx_caps[$cap_property]) && ( $this->all_taxonomy_caps[ $tx_caps[$cap_property] ] > 1 ) ) { // note: greater than check is on array value, not count
285
+
286
+ // ... but leave it alone if it is a standard taxonomy-specific cap for this taxonomy
287
+ if ( ( $tx_caps[$cap_property] != str_replace( '_terms', "_{$plural_type}", $cap_property ) )
288
+ && ( $tx_caps[$cap_property] != str_replace( '_terms', "_{$taxonomy}s", $cap_property ) ) ) {
289
+
290
+ $wp_taxonomies[$taxonomy]->cap->$cap_property = str_replace( '_terms', "_{$plural_type}", $replacement_cap_format );
291
+ }
292
+ }
293
+ }
294
+ $tx_caps = (array) $wp_taxonomies[$taxonomy]->cap;
295
+
296
+ // Optionally, also force edit_terms and delete_terms to be distinct from manage_terms, and force a distinct assign_terms capability
297
+ if ( in_array( $taxonomy, $detailed_taxonomies ) ) {
298
+ foreach( $tx_detail_caps as $cap_property => $replacement_cap_format ) {
299
+ if ( ! empty( $this->all_taxonomy_caps[ $tx_caps[$cap_property] ] ) ) {
300
+ // assign_terms is otherwise not forced taxonomy-distinct
301
+ $wp_taxonomies[$taxonomy]->cap->$cap_property = str_replace( '_terms', "_{$plural_type}", $replacement_cap_format );
302
+ break;
303
+ }
304
+
305
+ foreach( $tx_caps as $other_cap_property => $other_cap ) {
306
+ if ( $other_cap_property == $cap_property ) {
307
+ continue;
308
+ }
309
+
310
+ if ( $other_cap == $tx_caps[$cap_property] ) {
311
+ $wp_taxonomies[$taxonomy]->cap->$cap_property = str_replace( '_terms', "_{$plural_type}", $replacement_cap_format );
312
+ break;
313
+ }
314
+ }
315
+ }
316
+ }
317
+
318
+ $tx_caps = (array) $wp_taxonomies[$taxonomy]->cap;
319
+ }
320
+
321
+ foreach( array_unique( $tx_caps ) as $cap_name ) {
322
+ if ( ! isset( $this->all_taxonomy_caps[$cap_name] ) ) {
323
+ $this->all_taxonomy_caps[$cap_name] = 1;
324
+ } else {
325
+ $this->all_taxonomy_caps[$cap_name]++;
326
+ }
327
+ }
328
+ }
329
+
330
+ $this->all_taxonomy_caps = array_merge( $this->all_taxonomy_caps, array( 'assign_term' => true ) );
331
+
332
+ if ( current_user_can( 'administrator' ) || current_user_can( 'pp_administer_content' ) ) { // @ todo: support restricted administrator
333
+ global $current_user;
334
+ $current_user->allcaps = array_merge( $current_user->allcaps, array_fill_keys( array_keys( $this->all_taxonomy_caps ), true ) );
335
+
336
+ global $pp_current_user;
337
+ if ( ! empty( $pp_current_user ) ) {
338
+ $pp_current_user->allcaps = array_merge( $pp_current_user->allcaps, array_fill_keys( array_keys( $this->all_taxonomy_caps ), true ) );
339
+ }
340
+ }
341
+
342
+ // make sure Nav Menu Managers can also add menu items
343
+ global $wp_taxonomies;
344
+ $wp_taxonomies['nav_menu']->cap->assign_terms = 'manage_nav_menus';
345
+
346
+ $this->processed_taxonomies = array_merge( $this->processed_taxonomies, $use_taxonomies );
347
+ }
348
+ } // end class CME_Cap_Helper
includes/filters-woocommerce.php CHANGED
@@ -11,9 +11,26 @@ class CME_WooCommerce {
11
if ( ! empty( $current_user->allcaps['duplicate_products'] ) ) {
12
add_filter( 'woocommerce_duplicate_product_capability', array( &$this, 'implement_duplicate_product_cap' ) );
13
}
14
}
15
16
function implement_duplicate_product_cap( $cap ) {
17
return 'duplicate_products';
18
}
19
}
11
if ( ! empty( $current_user->allcaps['duplicate_products'] ) ) {
12
add_filter( 'woocommerce_duplicate_product_capability', array( &$this, 'implement_duplicate_product_cap' ) );
13
}
14
+
15
+ // Ensure orders can be edited or added based the edit_orders / create_orders capability
16
+ add_action( '_admin_menu', array( &$this, 'support_order_caps' ), 1 );
17
}
18
19
function implement_duplicate_product_cap( $cap ) {
20
return 'duplicate_products';
21
}
22
+
23
+ function support_order_caps() {
24
+ global $submenu;
25
+
26
+ if ( $type_obj = get_post_type_object( 'shop_order' ) ) {
27
+ $key = 'edit.php?post_type=shop_order';
28
+ if ( ! isset( $submenu[$key] ) ) {
29
+ $submenu[$key] = array();
30
+ }
31
+
32
+ $submenu[$key][5] = array( 0 => sprintf( __( 'All %s' ), $type_obj->labels->name ), 1 => $type_obj->cap->edit_posts, 2 => 'edit.php' );
33
+ $submenu[$key][10] = array( __('Add New'), 1 => $type_obj->cap->create_posts, 2 => 'post-new.php?post_type=shop_order' );
34
+ }
35
+ }
36
}
includes/filters.php CHANGED
@@ -19,7 +19,142 @@ class CME_Extensions {
19
global $cme_extensions;
20
$cme_extensions = new CME_Extensions();
21
22
if ( defined( 'WC_PLUGIN_FILE' ) ) {
23
require_once ( dirname(__FILE__) . '/filters-woocommerce.php' );
24
$cme_extensions->add( new CME_WooCommerce() );
25
- }
19
global $cme_extensions;
20
$cme_extensions = new CME_Extensions();
21
22
+ add_filter( 'map_meta_cap', '_cme_remap_term_meta_cap', 5, 4 );
23
+
24
if ( defined( 'WC_PLUGIN_FILE' ) ) {
25
require_once ( dirname(__FILE__) . '/filters-woocommerce.php' );
26
$cme_extensions->add( new CME_WooCommerce() );
27
+ }
28
+
29
+ // allow edit_terms, delete_terms, assign_terms capabilities to function separately from manage_terms
30
+ function _cme_remap_term_meta_cap ( $caps, $cap, $user_id, $args ) {
31
+ global $current_user, $cme_cap_helper;
32
+
33
+ if ( ! empty( $cme_cap_helper ) ) {
34
+ $cap_helper = $cme_cap_helper;
35
+ } else {
36
+ global $ppce_cap_helper;
37
+ if ( ! empty( $ppce_cap_helper ) ) {
38
+ $cap_helper = $ppce_cap_helper;
39
+ }
40
+ }
41
+
42
+ if ( empty($cap_helper) || empty( $cap_helper->all_taxonomy_caps[$cap] ) ) {
43
+ return $caps;
44
+ }
45
+
46
+ if ( ! $enabled_taxonomies = array_intersect( cme_get_assisted_taxonomies(), cme_get_detailed_taxonomies() ) ) {
47
+ return $caps;
48
+ }
49
+
50
+ // meta caps
51
+ switch ( $cap ) {
52
+ case 'edit_term':
53
+ case 'delete_term':
54
+ case 'assign_term':
55
+ $tx_cap = $cap . 's';
56
+
57
+ if ( ! is_array($args) || empty($args[0]) ) {
58
+ return $caps;
59
+ }
60
+
61
+ if ( $term = get_term( $args[0] ) ) {
62
+ if ( in_array( $term->taxonomy, $enabled_taxonomies ) ) {
63
+ if ( $tx_obj = get_taxonomy( $term->taxonomy ) ) {
64
+
65
+ // If this taxonomy is set for distinct capabilities, we don't want manage_terms capability to be implicitly assigned.
66
+ if ( empty( $current_user->allcaps[$tx_obj->cap->manage_terms] ) ) {
67
+ $caps = array_diff( $caps, (array) $tx_obj->cap->manage_terms );
68
+ }
69
+ $caps[]= $tx_obj->cap->$tx_cap;
70
+ }
71
+ }
72
+ }
73
+ break;
74
+ default:
75
+ }
76
+
77
+ // primitive caps
78
+ foreach( $enabled_taxonomies as $taxonomy ) {
79
+ if ( ! $tx_obj = get_taxonomy( $taxonomy ) ) {
80
+ continue;
81
+ }
82
+
83
+ foreach( array( 'edit_terms', 'delete_terms', 'assign_terms' ) as $cap_prop ) {
84
+ if ( $cap == $tx_obj->cap->$cap_prop ) {
85
+
86
+ // If this taxonomy is set for distinct capabilities, we don't want manage_terms capability to be implicitly assigned.
87
+ if ( empty( $current_user->allcaps[$tx_obj->cap->manage_terms] ) ) {
88
+ $caps = array_diff( $caps, (array) $tx_obj->cap->manage_terms );
89
+ }
90
+
91
+ $caps[]= $tx_obj->cap->$cap_prop;
92
+ return $caps;
93
+ }
94
+ }
95
+ }
96
+
97
+ return $caps;
98
+ }
99
+
100
+ // Note: this intentionally shares "pp_enabled_post_types" option with Press Permit
101
+ function cme_get_assisted_post_types() {
102
+ $type_args = array( 'public' => true, 'show_ui' => true );
103
+
104
+ $types = get_post_types( $type_args, 'names', 'or' );
105
+
106
+ if ( $omit_types = apply_filters( 'pp_unfiltered_post_types', array( 'wp_block' ) ) ) {
107
+ $post_types = array_diff_key( $types, array_fill_keys( (array) $omit_types, true ) );
108
+ }
109
+
110
+ $enabled = (array) get_option( 'pp_enabled_post_types', array( 'post' => true, 'page' => true ) );
111
+ $post_types = array_intersect( $post_types, array_keys( array_filter( $enabled ) ) );
112
+
113
+ return apply_filters( 'cme_assisted_post_types', $post_types, $type_args );
114
+ }
115
+
116
+ // Note: this intentionally does NOT share Press Permit' option name, for back compat reasons
117
+ // Enabling filtered taxonomies in PP previously did not cause the edit_terms, delete_terms, assign_terms capabilities to be enforced
118
+ function cme_get_assisted_taxonomies() {
119
+ $tx_args = array( 'public' => true );
120
+
121
+ $taxonomies = get_taxonomies( $tx_args );
122
+
123
+ if ( $omit_taxonomies = apply_filters( 'pp_unfiltered_taxonomies', array() ) ) {
124
+ $taxonomies = array_diff_key( $taxonomies, array_fill_keys( (array) $omit_taxonomies, true ) );
125
+ }
126
+
127
+ $enabled = (array) get_option( 'pp_enabled_taxonomies', array() );
128
+ $taxonomies = array_intersect( $taxonomies, array_keys( array_filter( $enabled ) ) );
129
+
130
+ return apply_filters( 'cme_assisted_taxonomies', $taxonomies, $tx_args );
131
+ }
132
+
133
+ function cme_get_detailed_taxonomies() {
134
+ $tx_args = array( 'public' => true );
135
+
136
+ $taxonomies = get_taxonomies( $tx_args );
137
+
138
+ if ( $omit_taxonomies = apply_filters( 'pp_unfiltered_taxonomies', array() ) ) {
139
+ $taxonomies = array_diff_key( $taxonomies, array_fill_keys( (array) $omit_taxonomies, true ) );
140
+ }
141
+
142
+ $enabled = (array) get_option( 'cme_detailed_taxonomies', array() );
143
+ $taxonomies = array_intersect( $taxonomies, array_keys( array_filter( $enabled ) ) );
144
+
145
+ return apply_filters( 'cme_detailed_taxonomies', $taxonomies, $tx_args );
146
+ }
147
+
148
+ function _cme_get_plural( $slug, $type_obj = false ) {
149
+ if ( $type_obj && ! empty( $type_obj->rest_base ) && ( $type_obj->rest_base != $slug ) && ( $type_obj->rest_base != "{$slug}s" ) ) {
150
+ // Use plural form from rest_base
151
+ if ( $pos = strpos( $type_obj->rest_base, '/' ) ) {
152
+ return sanitize_key( substr( $type_obj->rest_base, 0, $pos + 1 ) );
153
+ } else {
154
+ return sanitize_key( $type_obj->rest_base );
155
+ }
156
+ } else {
157
+ require_once ( dirname(__FILE__) . '/inflect-cme.php' );
158
+ return sanitize_key( CME_Inflect::pluralize( $slug ) );
159
+ }
160
+ }
includes/handler.php CHANGED
@@ -44,7 +44,7 @@ class CapsmanHandler
44
45
$this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
46
47
- if ( defined( 'PP_ACTIVE' ) ) { // log customized role caps for subsequent restoration
48
// for bbPress < 2.2, need to log customization of roles following bbPress activation
49
$plugins = ( function_exists( 'bbp_get_version' ) && version_compare( bbp_get_version(), '2.2', '<' ) ) ? array( 'bbpress.php' ) : array(); // back compat
50
@@ -86,20 +86,20 @@ class CapsmanHandler
86
$this->cm->message = __('Incorrect capability name.');
87
}
88
89
- } elseif ( ! empty($post['update_filtered_types']) ) {
90
- if ( cme_update_pp_usage() ) {
91
- ak_admin_notify(__('Capability settings saved.', 'capsman-enhanced'));
92
- } else {
93
- ak_admin_error(__('Error saving capability settings.', 'capsman-enhanced'));
94
- }
95
} else {
96
// TODO: Implement exceptions. This must be a fatal error.
97
ak_admin_error(__('Bad form received.', 'capsman-enhanced'));
98
}
99
100
- if ( ! empty($newrole) && defined('PP_ACTIVE') ) {
101
if ( ( ! empty($post['CreateRole']) && ! empty( $_REQUEST['new_role_pp_only'] ) ) || ( ! empty($post['CopyRole']) && ! empty( $_REQUEST['copy_role_pp_only'] ) ) ) {
102
- $pp_only = (array) pp_get_option( 'supplemental_role_defs' );
103
$pp_only[]= $newrole;
104
pp_update_option( 'supplemental_role_defs', $pp_only );
105
_cme_pp_default_pattern_role( $newrole );
@@ -210,7 +210,7 @@ class CapsmanHandler
210
}
211
212
// additional safeguard against removal of read capability
213
- if ( isset( $del_caps['read'] ) && in_array( $role_name, $this->cm->core_roles ) ) {
214
unset( $del_caps['read'] );
215
}
216
44
45
$this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
46
47
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) ) { // log customized role caps for subsequent restoration
48
// for bbPress < 2.2, need to log customization of roles following bbPress activation
49
$plugins = ( function_exists( 'bbp_get_version' ) && version_compare( bbp_get_version(), '2.2', '<' ) ) ? array( 'bbpress.php' ) : array(); // back compat
50
86
$this->cm->message = __('Incorrect capability name.');
87
}
88
89
+ } elseif ( ! empty($post['update_filtered_types']) || ! empty($post['update_filtered_taxonomies']) || ! empty($post['update_detailed_taxonomies']) ) {
90
+ //if ( /* settings saved successfully on plugins_loaded action */ ) {
91
+ ak_admin_notify(__('Type / Taxonomy settings saved.', 'capsman-enhanced'));
92
+ //} else {
93
+ // ak_admin_error(__('Error saving capability settings.', 'capsman-enhanced'));
94
+ //}
95
} else {
96
// TODO: Implement exceptions. This must be a fatal error.
97
ak_admin_error(__('Bad form received.', 'capsman-enhanced'));
98
}
99
100
+ if ( ! empty($newrole) && defined('PRESSPERMIT_ACTIVE') ) {
101
if ( ( ! empty($post['CreateRole']) && ! empty( $_REQUEST['new_role_pp_only'] ) ) || ( ! empty($post['CopyRole']) && ! empty( $_REQUEST['copy_role_pp_only'] ) ) ) {
102
+ $pp_only = (array) capsman_get_pp_option( 'supplemental_role_defs' );
103
$pp_only[]= $newrole;
104
pp_update_option( 'supplemental_role_defs', $pp_only );
105
_cme_pp_default_pattern_role( $newrole );
210
}
211
212
// additional safeguard against removal of read capability
213
+ if ( isset( $del_caps['read'] ) && _cme_is_read_removal_blocked( $role_name ) ) {
214
unset( $del_caps['read'] );
215
}
216
includes/inflect-cme.php ADDED
@@ -0,0 +1,136 @@
1
+ <?php
2
+
3
+ /**
4
+ /* Inflect class by T. Brian Jones
5
+ /* https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b
6
+ /*
7
+ /* original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
8
+ */
9
+
10
+ /*
11
+ The MIT License (MIT)
12
+
13
+ Copyright (c) 2015
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in
23
+ all copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
+ THE SOFTWARE.
32
+ */
33
+
34
+ // ORIGINAL NOTES
35
+ //
36
+ // Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
37
+ // http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
38
+ // http://www.fortunecity.com/bally/durrus/153/gramch13.html
39
+ // http://www2.gsu.edu/~wwwesl/egw/crump.htm
40
+ //
41
+ // Changes (12/17/07)
42
+ // Major changes
43
+ // --
44
+ // Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
45
+ // (this allows for things like fireman -> firemen
46
+ // Fixed the order of the singular array, which was backwards.
47
+ //
48
+ // Minor changes
49
+ // --
50
+ // Removed incorrect pluralization rule for /([^aeiouy]|qu)ies#x2F; => $1y
51
+ // Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
52
+ // Removed dangerous singularization rule for /([^f])ves#x2F; => $1fe
53
+ // Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
54
+ // Added exception to /(us)es#x2F; => $1 rule for houses => house and blouses => blouse
55
+ // Added excpetions for feet, geese and teeth
56
+ // Added rule for deer -> deer
57
+
58
+ // Changes:
59
+ // Removed rule for virus -> viri
60
+ // Added rule for potato -> potatoes
61
+ // Added rule for *us -> *uses
62
+
63
+ // Kevin Behrens : removed singularization code (not needed for CME)
64
+ class CME_Inflect
65
+ {
66
+ static $plural = array(
67
+ '/(quiz)#x2F;i' => "$1zes",
68
+ '/^(ox)#x2F;i' => "$1en",
69
+ '/([m|l])ouse#x2F;i' => "$1ice",
70
+ '/(matr|vert|ind)ix|ex#x2F;i' => "$1ices",
71
+ '/(x|ch|ss|sh)#x2F;i' => "$1es",
72
+ '/([^aeiouy]|qu)y#x2F;i' => "$1ies",
73
+ '/(hive)#x2F;i' => "$1s",
74
+ '/(?:([^f])fe|([lr])f)#x2F;i' => "$1$2ves",
75
+ '/(shea|lea|loa|thie)f#x2F;i' => "$1ves",
76
+ '/sis#x2F;i' => "ses",
77
+ '/([ti])um#x2F;i' => "$1a",
78
+ '/(tomat|potat|ech|her|vet)o#x2F;i'=> "$1oes",
79
+ '/(bu)s#x2F;i' => "$1ses",
80
+ '/(alias)#x2F;i' => "$1es",
81
+ '/(octop)us#x2F;i' => "$1i",
82
+ '/(ax|test)is#x2F;i' => "$1es",
83
+ '/(us)#x2F;i' => "$1es",
84
+ '/s#x2F;i' => "s",
85
+ '/#x2F;' => "s"
86
+ );
87
+
88
+ static $irregular = array(
89
+ 'move' => 'moves',
90
+ 'foot' => 'feet',
91
+ 'goose' => 'geese',
92
+ 'sex' => 'sexes',
93
+ 'child' => 'children',
94
+ 'man' => 'men',
95
+ 'tooth' => 'teeth',
96
+ 'person' => 'people',
97
+ 'valve' => 'valves'
98
+ );
99
+
100
+ static $uncountable = array(
101
+ 'sheep',
102
+ 'fish',
103
+ 'deer',
104
+ 'series',
105
+ 'species',
106
+ 'money',
107
+ 'rice',
108
+ 'information',
109
+ 'equipment'
110
+ );
111
+
112
+ public static function pluralize( $string ) {
113
+ // save some time in the case that singular and plural are the same
114
+ if ( in_array( strtolower( $string ), self::$uncountable ) ) {
115
+ return $string;
116
+ }
117
+
118
+ // check for irregular singular forms
119
+ foreach ( self::$irregular as $pattern => $result ) {
120
+ $pattern = '/' . $pattern . '#x2F;i';
121
+
122
+ if ( preg_match( $pattern, $string ) ) {
123
+ return preg_replace( $pattern, $result, $string);
124
+ }
125
+ }
126
+
127
+ // check for matches using regular expressions
128
+ foreach ( self::$plural as $pattern => $result ) {
129
+ if ( preg_match( $pattern, $string ) ) {
130
+ return preg_replace( $pattern, $result, $string );
131
+ }
132
+ }
133
+
134
+ return $string;
135
+ }
136
+ }
includes/manager.php CHANGED
@@ -28,12 +28,51 @@
28
add_action( 'init', 'cme_update_pp_usage' ); // update early so resulting post type cap changes are applied for this request's UI construction
29
30
function cme_update_pp_usage() {
31
- if ( defined( 'PP_ACTIVE' ) && ( ! empty($_REQUEST['update_filtered_types']) || ! empty($_REQUEST['SaveRole']) ) ) {
32
require_once( dirname(__FILE__).'/pp-handler.php' );
33
return _cme_update_pp_usage();
34
}
35
}
36
37
38
/**
39
* Class CapabilityManager.
@@ -58,11 +97,6 @@ class CapabilityManager
58
*/
59
var $roles = array();
60
61
- /**
62
- * Roles to monitor for removal of essential capabilities
63
- */
64
- var $core_roles = array();
65
-
66
/**
67
* Current role we are managing
68
* @var string
@@ -91,8 +125,6 @@ class CapabilityManager
91
$this->ID = 'capsman';
92
$this->mod_url = plugins_url( '', CME_FILE );
93
94
- $this->core_roles = apply_filters( 'pp_caps_core_roles', array( 'administrator', 'editor', 'revisor', 'author', 'contributor', 'subscriber' ) );
95
-
96
$this->moduleLoad();
97
98
add_action('admin_menu', array($this, 'adminMenus'), 5); // execute prior to PP, to use menu hook
28
add_action( 'init', 'cme_update_pp_usage' ); // update early so resulting post type cap changes are applied for this request's UI construction
29
30
function cme_update_pp_usage() {
31
+ if ( ! empty($_REQUEST['update_filtered_types']) || ! empty($_REQUEST['update_filtered_taxonomies']) || ! empty($_REQUEST['update_detailed_taxonomies']) || ! empty($_REQUEST['SaveRole']) ) {
32
require_once( dirname(__FILE__).'/pp-handler.php' );
33
return _cme_update_pp_usage();
34
}
35
}
36
37
+ // Core WP roles to apply safeguard preventing accidental lockout from dashboard
38
+ function _cme_core_roles() {
39
+ return apply_filters( 'pp_caps_core_roles', array( 'administrator', 'editor', 'revisor', 'author', 'contributor', 'subscriber' ) );
40
+ }
41
+
42
+ function _cme_core_caps() {
43
+ $core_caps = array_fill_keys( array( 'switch_themes', 'edit_themes', 'activate_plugins', 'edit_plugins', 'edit_users', 'edit_files', 'manage_options', 'moderate_comments',
44
+ 'manage_links', 'upload_files', 'import', 'unfiltered_html', 'read', 'delete_users', 'create_users', 'unfiltered_upload', 'edit_dashboard',
45
+ 'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes', 'install_themes',
46
+ 'update_core', 'list_users', 'remove_users', 'add_users', 'promote_users', 'edit_theme_options', 'delete_themes', 'export' ), true );
47
+
48
+ ksort( $core_caps );
49
+ return $core_caps;
50
+ }
51
+
52
+ function _cme_is_read_removal_blocked( $role_name ) {
53
+ $role = get_role($role_name);
54
+ $rcaps = $role->capabilities;
55
+
56
+ $core_caps = array_diff_key( _cme_core_caps(), array_fill_keys( array( 'unfiltered_html', 'unfiltered_upload', 'upload_files', 'edit_files', 'read' ), true ) );
57
+
58
+ if ( empty( $rcaps['dashboard_lockout_ok'] ) ) {
59
+ $edit_caps = array();
60
+ foreach ( get_post_types( array( 'public' => true ), 'object' ) as $type_obj ) {
61
+ $edit_caps = array_merge( $edit_caps, array_values( array_diff_key( (array) $type_obj->cap, array( 'read_private_posts' => true ) ) ) );
62
+ }
63
+
64
+ $edit_caps = array_fill_keys( $edit_caps, true );
65
+ unset( $edit_caps['read'] );
66
+ unset( $edit_caps['upload_files'] );
67
+ unset( $edit_caps['edit_files'] );
68
+
69
+ if ( $role_has_admin_caps = in_array( $role_name, _cme_core_roles() ) && ( array_intersect_key( $rcaps, array_diff_key( $core_caps, array( 'read' => true ) ) ) || array_intersect_key( $rcaps, $edit_caps ) ) ) {
70
+ return true;
71
+ }
72
+ }
73
+
74
+ return false;
75
+ }
76
77
/**
78
* Class CapabilityManager.
97
*/
98
var $roles = array();
99
100
/**
101
* Current role we are managing
102
* @var string
125
$this->ID = 'capsman';
126
$this->mod_url = plugins_url( '', CME_FILE );
127
128
$this->moduleLoad();
129
130
add_action('admin_menu', array($this, 'adminMenus'), 5); // execute prior to PP, to use menu hook
includes/network.php CHANGED
@@ -15,8 +15,8 @@ function _cme_new_blog( $new_blog_id ) {
15
$admin_role = $wp_roles->get_role('administrator');
16
$main_admin_caps = $admin_role->capabilities;
17
18
- if ( defined('PP_ACTIVE') )
19
- $main_pp_only = (array) pp_get_option( 'supplemental_role_defs' );
20
//$pp_only[]= $newrole;
21
22
foreach( $autocreate_roles as $role_name ) {
@@ -29,9 +29,9 @@ function _cme_new_blog( $new_blog_id ) {
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();
34
- $blog_pp_only = (array) pp_get_option( 'supplemental_role_defs' );
35
}
36
37
foreach( $main_site_caps as $role_name => $caps ) {
@@ -53,7 +53,7 @@ function _cme_new_blog( $new_blog_id ) {
53
$wp_roles->add_role( $role_name, $role_captions[$role_name], $caps );
54
}
55
56
- if ( defined('PP_ACTIVE') ) {
57
if ( in_array( $role_name, $main_pp_only ) ) {
58
_cme_pp_default_pattern_role( $role_name );
59
$blog_pp_only []= $role_name;
@@ -62,13 +62,13 @@ function _cme_new_blog( $new_blog_id ) {
62
}
63
}
64
65
- if ( defined('PP_ACTIVE') )
66
pp_update_option( 'supplemental_role_defs', $blog_pp_only );
67
68
restore_current_blog();
69
( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
70
71
- if ( defined('PP_ACTIVE') )
72
pp_refresh_options();
73
}
74
}
15
$admin_role = $wp_roles->get_role('administrator');
16
$main_admin_caps = $admin_role->capabilities;
17
18
+ if ( defined('PRESSPERMIT_ACTIVE') )
19
+ $main_pp_only = (array) capsman_get_pp_option( 'supplemental_role_defs' );
20
//$pp_only[]= $newrole;
21
22
foreach( $autocreate_roles as $role_name ) {
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('PRESSPERMIT_ACTIVE') ) {
33
pp_refresh_options();
34
+ $blog_pp_only = (array) capsman_get_pp_option( 'supplemental_role_defs' );
35
}
36
37
foreach( $main_site_caps as $role_name => $caps ) {
53
$wp_roles->add_role( $role_name, $role_captions[$role_name], $caps );
54
}
55
56
+ if ( defined('PRESSPERMIT_ACTIVE') ) {
57
if ( in_array( $role_name, $main_pp_only ) ) {
58
_cme_pp_default_pattern_role( $role_name );
59
$blog_pp_only []= $role_name;
62
}
63
}
64
65
+ if ( defined('PRESSPERMIT_ACTIVE') )
66
pp_update_option( 'supplemental_role_defs', $blog_pp_only );
67
68
restore_current_blog();
69
( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
70
71
+ if ( defined('PRESSPERMIT_ACTIVE') )
72
pp_refresh_options();
73
}
74
}
includes/pp-handler.php CHANGED
@@ -3,60 +3,82 @@
3
function _cme_update_pp_usage() {
4
static $updated;
5
if ( ! empty($updated) ) { return true; }
6
-
7
- if ( ! current_user_can( 'pp_manage_settings' ) )
8
return false;
9
10
- if ( ! empty( $_REQUEST['update_filtered_types']) ) {
11
// update Press Permit "Filtered Post Types". This determines whether type-specific capability definitions are forced
12
- $options = array( 'enabled_post_types', 'enabled_taxonomies' );
13
14
foreach( $options as $option_basename ) {
15
- if ( ! isset( $_POST["{$option_basename}-options"] ) )
16
continue;
17
18
$unselected = array();
19
$value = array();
20
21
- foreach( $_POST["{$option_basename}-options"] as $key ) {
22
- if ( empty( $_POST["{$option_basename}-$key"] ) )
23
$unselected[$key] = true;
24
- else
25
$value[$key] = true;
26
}
27
28
- if ( $current = pp_get_option( $option_basename ) ) {
29
if ( $current = array_diff_key( $current, $unselected ) )
30
$value = array_merge( $current, $value ); // retain setting for any types which were previously enabled for filtering but are currently not registered
31
}
32
33
$value = stripslashes_deep($value);
34
- pp_update_option( $option_basename, $value );
35
36
$updated = true;
37
}
38
39
- if ( pp_wp_ver( '3.5' ) ) {
40
- pp_update_option( 'define_create_posts_cap', ! empty($_REQUEST['pp_define_create_posts_cap']) );
41
}
42
}
43
44
- if ( ! empty( $_REQUEST['SaveRole']) ) {
45
- if ( ! empty( $_REQUEST['role'] ) ) {
46
- $pp_only = (array) pp_get_option( 'supplemental_role_defs' );
47
-
48
- if ( empty($_REQUEST['pp_only_role']) )
49
- $pp_only = array_diff( $pp_only, array($_REQUEST['role']) );
50
- else
51
- $pp_only[]= $_REQUEST['role'];
52
53
- pp_update_option( 'supplemental_role_defs', array_unique($pp_only) );
54
- _cme_pp_default_pattern_role( $_REQUEST['role'] );
55
}
56
- }
57
-
58
- if ( $updated ) {
59
- pp_refresh_options();
60
}
61
62
return $updated;
3
function _cme_update_pp_usage() {
4
static $updated;
5
if ( ! empty($updated) ) { return true; }
6
+
7
+ if ( ! current_user_can( 'manage_capabilities' ) ) {
8
return false;
9
+ }
10
11
+ if ( ! empty( $_REQUEST['update_filtered_types']) || ! empty( $_REQUEST['update_filtered_taxonomies']) || ! empty($_REQUEST['update_detailed_taxonomies']) || ! empty( $_REQUEST['SaveRole']) ) {
12
// update Press Permit "Filtered Post Types". This determines whether type-specific capability definitions are forced
13
+ $options = array( 'enabled_post_types', 'enabled_taxonomies', 'detailed_taxonomies' );
14
+
15
+ $posted = $_POST;
16
17
foreach( $options as $option_basename ) {
18
+ if ( ! isset( $posted["{$option_basename}-options"] ) )
19
continue;
20
21
$unselected = array();
22
$value = array();
23
24
+ foreach( $posted["{$option_basename}-options"] as $key ) {
25
+ if ( ( 'enabled_taxonomies' == $option_basename ) && ! empty( $posted["detailed_taxonomies-{$key}"] ) && ! empty( $posted['update_detailed_taxonomies']) ) {
26
+ // if Detailed is selected, also select Type-Specific
27
+ $posted["enabled_taxonomies-{$key}"] = true;
28
+ $value[$key] = true;
29
+ } elseif ( ( 'detailed_taxonomies' == $option_basename ) && empty( $posted["enabled_taxonomies-{$key}"] ) && ! empty( $posted['update_filtered_taxonomies']) ) {
30
+ // if Enabled is deselected, also deselect Type-Specific
31
$unselected[$key] = true;
32
+ } elseif ( empty( $posted["{$option_basename}-$key"] ) ) {
33
+ $unselected[$key] = true;
34
+ } else {
35
$value[$key] = true;
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 ) )
44
$value = array_merge( $current, $value ); // retain setting for any types which were previously enabled for filtering but are currently not registered
45
}
46
47
$value = stripslashes_deep($value);
48
+
49
+ update_option( $option_name, $value );
50
+
51
+ if ( 'pp_enabled_post_types' == $option_name ) {
52
+ // ensure smooth transition if Press Permit Core is deactivated
53
+ update_option( 'cme_enabled_post_types', $value );
54
+ }
55
56
$updated = true;
57
}
58
59
+ if ( ! empty( $_REQUEST['update_filtered_types']) ) {
60
+ update_option( 'pp_' . 'define_create_posts_cap', ! empty($_REQUEST['pp_define_create_posts_cap']) );
61
}
62
}
63
64
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
65
+ if ( ! empty( $_REQUEST['SaveRole']) ) {
66
+ if ( ! empty( $_REQUEST['role'] ) ) {
67
+ $pp_only = (array) capsman_get_pp_option( 'supplemental_role_defs' );
68
+
69
+ if ( empty($_REQUEST['pp_only_role']) )
70
+ $pp_only = array_diff( $pp_only, array($_REQUEST['role']) );
71
+ else
72
+ $pp_only[]= $_REQUEST['role'];
73
74
+ pp_update_option( 'supplemental_role_defs', array_unique($pp_only) );
75
+ _cme_pp_default_pattern_role( $_REQUEST['role'] );
76
+ }
77
+ }
78
+
79
+ if ( $updated ) {
80
+ pp_refresh_options();
81
}
82
}
83
84
return $updated;
includes/pp-ui.php CHANGED
@@ -1,15 +1,10 @@
1
<?php
2
3
class Capsman_PP_UI {
4
-
5
- function __construct() {
6
-
7
- }
8
-
9
function get_metagroup_caps( $default ) {
10
global $wpdb;
11
12
- if ( defined( 'PPC_VERSION' ) ) {
13
$query = $wpdb->prepare( "SELECT role_name FROM $wpdb->ppc_roles AS r INNER JOIN $wpdb->pp_groups AS g ON g.ID = r.agent_id AND r.agent_type = 'pp_group' WHERE g.metagroup_type = 'wp_role' AND g.metagroup_id = %s", $default );
14
$pp_supplemental_roles = $wpdb->get_col( $query );
15
} else {
@@ -35,22 +30,24 @@ class Capsman_PP_UI {
35
}
36
37
function show_capability_hints( $default ) {
38
- if ( pp_get_option('display_hints') ) {
39
$cme_id = 'capsman';
40
41
echo '<ul class="ul-disc" style="margin-top:10px">';
42
43
- if ( defined( 'PPCE_VERSION' ) || ! defined( 'PPC_VERSION' ) || in_array( $default, array( 'subscriber', 'contributor', 'author', 'editor' ) ) ) {
44
echo '<li>';
45
- if ( defined( 'PPCE_VERSION' ) || ! defined( 'PPC_VERSION' ) ) {
46
- if ( pp_get_option( 'advanced_options' ) )
47
- $parenthetical = ' (' . sprintf( __( 'see %1$sRole Usage%2$s: "Pattern Roles"', 'capsman-enhanced' ), "<a href='" . admin_url('admin.php?page=pp-role-usage') . "'>", '</a>' ) . ')';
48
else
49
- $parenthetical = ' (' . sprintf( __( 'activate %1$sAdvanced settings%2$s, see Role Usage', 'capsman-enhanced' ), "<a href='" . admin_url('admin.php?page=pp-settings&pp_tab=advanced') . "'>", '</a>' ). ')';
50
} else
51
$parenthetical = '';
52
53
- if ( defined( 'PPC_VERSION' ) )
54
printf( __( '"Posts" capabilities selected here also define type-specific role assignment for Permission Groups%s.', $cme_id ), $parenthetical ) ;
55
else
56
printf( __( '"Posts" capabilities selected here also define type-specific role assignment for Permit Groups%s.', $cme_id ), $parenthetical ) ;
@@ -59,14 +56,14 @@ class Capsman_PP_UI {
59
}
60
61
$status_hint = '';
62
- if ( defined( 'PPC_VERSION' ) )
63
if ( defined( 'PPS_VERSION' ) )
64
- $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added here (see Post Statuses > Status > Capability Mapping for applicable names). However, it is usually more convenient to use Permission Groups to assign a supplemental status-specific role.', $cme_id ), "<a href='" . admin_url('?page=pp-role-usage') . "'>", '</a>' ) ;
65
- elseif ( pp_get_option( 'display_extension_hints' ) )
66
- $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added here. Or activate the PP Custom Post Statuses extension to assign status-specific supplemental roles.', $cme_id ), "<a href='" . admin_url('?page=pp-role-usage') . "'>", '</a>' ) ;
67
68
elseif ( defined( 'PP_VERSION' ) )
69
- $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added to a role here (see Conditions > Status > Capability Mapping for applicable names). However, it is usually more convenient to use Permit Groups to assign a supplemental status-specific role.', $cme_id ), "<a href='" . admin_url('?page=pp-role-usage') . "'>", '</a>' ) ;
70
71
if ( $status_hint )
72
echo "<li>$status_hint</li>";
@@ -76,14 +73,14 @@ class Capsman_PP_UI {
76
}
77
78
function pp_only_roles_ui( $default ) {
79
- $support_pp_only_roles = defined('PPC_VERSION') || version_compare( PP_VERSION, '1.0-beta1.4', '>=');
80
?>
81
82
<?php if ( $support_pp_only_roles && ! in_array( $default, array( /*'subscriber', 'contributor', 'author', 'editor',*/ 'administrator' ) ) ) : ?>
83
<div style="float:right">
84
<?php
85
pp_refresh_options();
86
- $pp_only = (array) pp_get_option( 'supplemental_role_defs' );
87
$checked = ( in_array( $default, $pp_only ) ) ? 'checked="checked"': '';
88
?>
89
<label for="pp_only_role" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"><input type="checkbox" name="pp_only_role" id="pp_only_role" value="1" <?php echo $checked;?>> <?php _e('hidden role', 'capsman-enhanced'); ?> </label>
@@ -93,81 +90,194 @@ class Capsman_PP_UI {
93
return $support_pp_only_roles;
94
}
95
96
- function pp_types_ui( $defined ) {
97
- if ( current_user_can( 'pp_manage_settings' ) ) :?>
98
<dl>
99
- <dt><?php _e('Force Type-Specific Capabilities', 'capsman-enhanced'); ?></dt>
100
<dd style="text-align:center;">
101
<?php
102
- $caption = __( 'Force unique capability names for:', 'capsman-enhanced' );
103
- echo "<p>$caption</p>";
104
105
- if ( pp_get_option( 'display_hints' ) ) :?>
106
<div class="cme-subtext" style="margin-top:0">
107
- <?php _e( '(PP Filtered Post Types, Taxonomies)', 'capsman-enhanced' );?>
108
</div>
109
<?php endif;
110
111
echo "<table style='width:100%'><tr>";
112
113
- $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array('forum','topic','reply') ); // bbPress' dynamic role def requires additional code to enforce stored caps
114
- $unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy
115
- $hidden['type'] = apply_filters( 'pp_hidden_post_types', array() );
116
- $hidden['taxonomy'] = apply_filters( 'pp_hidden_taxonomies', array() );
117
118
- foreach( array_keys($defined) as $item_type ) {
119
- echo '<td style="width:50%">';
120
- $option_name = ( 'taxonomy' == $item_type ) ? 'enabled_taxonomies' : 'enabled_post_types';
121
122
- $enabled = pp_get_option( $option_name );
123
-
124
- foreach( $defined[$item_type] as $key => $type_obj ) {
125
- if ( ! $key )
126
- continue;
127
-
128
- if ( in_array( $key, $unfiltered[$item_type] ) )
129
- continue;
130
-
131
- $id = "$option_name-" . $key;
132
- ?>
133
- <div style="text-align:left">
134
- <?php if ( ! empty( $hidden[$item_type][$key] ) ) :?>
135
- <input name="<?php echo($id);?>" type="hidden" id="<?php echo($id);?>" value="1" />
136
- <input name="<?php echo("{$option_name}-options[]");?>" type="hidden" value="<?php echo($key)?>" />
137
138
- <?php else: ?>
139
- <div class="agp-vspaced_input">
140
- <label for="<?php echo($id);?>" title="<?php echo($key);?>">
141
- <input name="<?php echo("{$option_name}-options[]");?>" type="hidden" value="<?php echo($key)?>" />
142
- <input name="<?php echo($id);?>" type="checkbox" id="<?php echo($id);?>" value="1" <?php checked('1', ! empty($enabled[$key]) );?> /> <?php echo($type_obj->label);?>
143
-
144
- <?php
145
- echo ('</label></div>');
146
-
147
- endif; // displaying checkbox UI
148
149
- echo '</div>';
150
- }
151
- echo '</td>';
152
}
153
?>
154
</tr>
155
</table>
156
157
- <?php if( pp_wp_ver( '3.5' ) ) :
158
- $define_create_posts_cap = pp_get_option( 'define_create_posts_cap' );
159
- ?>
160
- <div>
161
<label for="pp_define_create_posts_cap">
162
- <input name="pp_define_create_posts_cap" type="checkbox" id="pp_define_create_posts_cap" value="1" <?php checked('1', $define_create_posts_cap );?> /> <?php _e('Use create_posts capability');?>
163
</label>
164
</div>
165
- <?php endif; ?>
166
167
<input type="submit" name="update_filtered_types" value="<?php _e('Update', 'capsman-enhanced') ?>" class="button" />
168
</dd>
169
</dl>
170
- <?php endif;
171
}
172
}
173
1
<?php
2
3
class Capsman_PP_UI {
4
function get_metagroup_caps( $default ) {
5
global $wpdb;
6
7
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
8
$query = $wpdb->prepare( "SELECT role_name FROM $wpdb->ppc_roles AS r INNER JOIN $wpdb->pp_groups AS g ON g.ID = r.agent_id AND r.agent_type = 'pp_group' WHERE g.metagroup_type = 'wp_role' AND g.metagroup_id = %s", $default );
9
$pp_supplemental_roles = $wpdb->get_col( $query );
10
} else {
30
}
31
32
function show_capability_hints( $default ) {
33
+ if ( capsman_get_pp_option('display_hints') ) {
34
$cme_id = 'capsman';
35
36
echo '<ul class="ul-disc" style="margin-top:10px">';
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>';
42
+ if ( defined( 'PPCE_VERSION' ) || ! defined( 'PRESSPERMIT_ACTIVE' ) ) {
43
+ if ( capsman_get_pp_option( 'advanced_options' ) )
44
+ $parenthetical = ' (' . sprintf( __( 'see %1$sRole Usage%2$s: "Pattern Roles"', 'capsman-enhanced' ), "<a href='" . admin_url("admin.php?page={$pp_prefix}-role-usage") . "'>", '</a>' ) . ')';
45
else
46
+ $parenthetical = ' (' . sprintf( __( 'activate %1$sAdvanced settings%2$s, see Role Usage', 'capsman-enhanced' ), "<a href='" . admin_url("admin.php?page={$pp_prefix}-settings&pp_tab=advanced") . "'>", '</a>' ). ')';
47
} else
48
$parenthetical = '';
49
50
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) )
51
printf( __( '"Posts" capabilities selected here also define type-specific role assignment for Permission Groups%s.', $cme_id ), $parenthetical ) ;
52
else
53
printf( __( '"Posts" capabilities selected here also define type-specific role assignment for Permit Groups%s.', $cme_id ), $parenthetical ) ;
56
}
57
58
$status_hint = '';
59
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) )
60
if ( defined( 'PPS_VERSION' ) )
61
+ $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added here. (See %sPermissions > Post Statuses%s for applicable names). %sSupplemental status-specific roles%s are usually more convenient, though.', $cme_id ), "<a href='" . admin_url("admin.php?page={$pp_prefix}-statuses&show_caps=1") . "'>", '</a>', "<a href='" . admin_url("admin.php?page={$pp_prefix}-groups") . "'>", '</a>' ) ;
62
+ elseif ( capsman_get_pp_option( 'display_extension_hints' ) )
63
+ $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added here. Or activate the PP Custom Post Statuses extension to assign status-specific supplemental roles.', $cme_id ), "<a href='" . admin_url("admin.php?page={$pp_prefix}-role-usage") . "'>", '</a>' ) ;
64
65
elseif ( defined( 'PP_VERSION' ) )
66
+ $status_hint = sprintf( __( 'Capabilities for custom statuses can be manually added to a role here (see Conditions > Status > Capability Mapping for applicable names). However, it is usually more convenient to use Permit Groups to assign a supplemental status-specific role.', $cme_id ), "<a href='" . admin_url("admin.php?page={$pp_prefix}-role-usage") . "'>", '</a>' ) ;
67
68
if ( $status_hint )
69
echo "<li>$status_hint</li>";
73
}
74
75
function pp_only_roles_ui( $default ) {
76
+ $support_pp_only_roles = defined('PRESSPERMIT_ACTIVE') || version_compare( PP_VERSION, '1.0-beta1.4', '>=');
77
?>
78
79
<?php if ( $support_pp_only_roles && ! in_array( $default, array( /*'subscriber', 'contributor', 'author', 'editor',*/ 'administrator' ) ) ) : ?>
80
<div style="float:right">
81
<?php
82
pp_refresh_options();
83
+ $pp_only = (array) capsman_get_pp_option( 'supplemental_role_defs' );
84
$checked = ( in_array( $default, $pp_only ) ) ? 'checked="checked"': '';
85
?>
86
<label for="pp_only_role" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"><input type="checkbox" name="pp_only_role" id="pp_only_role" value="1" <?php echo $checked;?>> <?php _e('hidden role', 'capsman-enhanced'); ?> </label>
90
return $support_pp_only_roles;
91
}
92
93
+ // Note: CME can now impose type-specific capabilities without Press Permit Core active
94
+ function pp_types_ui( $defined_types ) {
95
+ ?>
96
<dl>
97
+ <dt><?php _e('Type-Specific Capabilities', 'capsman-enhanced'); ?></dt>
98
<dd style="text-align:center;">
99
<?php
100
+ $caption = __( 'Ensure permissions can be controlled separately from other post types.', 'capsman-enhanced' );
101
+ echo "<p class='cme-hint'>$caption</p>";
102
103
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) && capsman_get_pp_option( 'display_hints' ) ) :?>
104
<div class="cme-subtext" style="margin-top:0">
105
+ <?php /*_e( '(PP Filtered Post Types, Taxonomies)', 'capsman-enhanced' ); */?>
106
</div>
107
<?php endif;
108
109
echo "<table style='width:100%'><tr>";
110
111
+ $unfiltered = apply_filters( 'pp_unfiltered_post_types', array('forum','topic','reply','wp_block') ); // bbPress' dynamic role def requires additional code to enforce stored caps
112
+ $hidden = apply_filters( 'pp_hidden_post_types', array() );
113
+
114
+ echo '<td