PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 2.1
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v2.1
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / includes / admin.php
capability-manager-enhanced / includes Last commit date
features 5 years ago roles 5 years ago admin.php 5 years ago backup-handler.php 5 years ago backup.php 5 years ago cap-helper.php 6 years ago filters-admin.php 6 years ago filters-woocommerce.php 7 years ago filters-wp_rest_workarounds.php 5 years ago filters.php 5 years ago functions-admin.php 5 years ago functions.php 5 years ago handler.php 5 years ago inflect-cme.php 7 years ago manager.php 5 years ago network.php 5 years ago pp-handler.php 6 years ago pp-ui.php 5 years ago publishpress-roles.php 5 years ago settings-handler.php 5 years ago settings.php 5 years ago
admin.php
1188 lines
1 <?php
2 /**
3 * General Admin for Role Capabilities.
4 * Provides admin pages to create and manage roles and capabilities.
5 *
6 * @author Jordi Canals, Kevin Behrens
7 * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2020 PublishPress
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 2020, 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, $current_user;
29
30 do_action('publishpress-caps_manager-load');
31
32 $roles = $this->roles;
33 $default = $this->current;
34
35 if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
36 if ( $current = get_role($default) ) {
37 if ( empty( $current->capabilities['read'] ) ) {
38 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>' ) );
39 }
40 }
41 }
42
43 require_once (dirname(CME_FILE) . '/includes/roles/roles-functions.php');
44
45 require_once( dirname(__FILE__).'/pp-ui.php' );
46 $pp_ui = new Capsman_PP_UI();
47
48 if( defined('PRESSPERMIT_ACTIVE') ) {
49 $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
50 } else {
51 $pp_metagroup_caps = array();
52 }
53 ?>
54 <div class="wrap publishpress-caps-manage pressshack-admin-wrapper">
55 <?php /*if( defined('PRESSPERMIT_ACTIVE') ) :
56 pp_icon();
57 $style = 'style="height:60px;"';
58 */
59 ?>
60 <?php /* else: */
61 $style = '';
62 ?>
63 <div id="icon-capsman-admin" class="icon32"></div>
64 <?php /* endif; */ ?>
65
66 <h1 <?php echo $style;?>><?php _e('Role Capabilities', 'capsman-enhanced') ?></h1>
67
68 <?php
69 echo pp_capabilities_roles()->notify->display();
70 ?>
71
72 <script type="text/javascript">
73 /* <![CDATA[ */
74 jQuery(document).ready( function($) {
75 $('#publishpress_caps_form').attr('action', 'admin.php?page=pp-capabilities&role=' + $('select[name="role"]').val());
76
77 $('select[name="role"]').change(function(){
78 window.location = '<?php echo admin_url('admin.php?page=pp-capabilities&role='); ?>' + $(this).val() + '';
79 });
80 });
81 /* ]]> */
82 </script>
83
84 <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo $this->ID ?>">
85 <?php wp_nonce_field('capsman-general-manager'); ?>
86
87 <p>
88 <select name="role">
89 <?php
90 foreach ( $roles as $role => $name ) {
91 if (pp_capabilities_is_editable_role($role)) {
92 $name = translate_user_role($name);
93 echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' &nbsp;</option>';
94 }
95 }
96 ?>
97 </select>
98 </p>
99
100 <fieldset>
101 <table id="akmin">
102 <tr>
103 <td class="content">
104 <dl>
105 <dd>
106 <div style="float:right">
107 <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced'); ?>" class="button-primary" /> &nbsp;
108 </div>
109
110 <?php
111 global $capsman;
112 $img_url = $capsman->mod_url . '/images/';
113 ?>
114 <div class="publishpress-headline">
115 <span class="cme-subtext">
116 <?php
117 $msg = __( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' );
118
119 if (defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) {
120 if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) {
121 $msg = sprintf(
122 __('<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation. You can also configure this role as a %sPermission Group%s.', 'capsman-enhanced'),
123 '<a href="' . admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}") . '">',
124 '</a>'
125 );
126 }
127 }
128 echo $msg;
129 ?>
130 </span>
131 </div>
132
133 <?php
134 if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
135 $pp_ui->show_capability_hints( $default );
136 }
137 ?>
138
139 <script type="text/javascript">
140 /* <![CDATA[ */
141 jQuery(document).ready( function($) {
142 $('a[href="#pp-more"]').click( function() {
143 $('#pp_features').show();
144 return false;
145 });
146 $('a[href="#pp-hide"]').click( function() {
147 $('#pp_features').hide();
148 return false;
149 });
150 });
151 /* ]]> */
152 </script>
153
154 <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
155
156 <br /><div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo $img_url;?>pp-logo.png" alt="<?php _e('PublishPress Permissions', 'capsman-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features">
157 <li>
158 <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
159 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
160
161 <li>
162 <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
163 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
164
165 <li>
166 <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
167 </li>
168
169 <li>
170 <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
171 <a href="https://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
172
173 <li>
174 <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
175 <a href="https://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
176
177 <li>
178 <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
179 <a href="https://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
180
181 <li>
182 <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
183 <a href="https://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
184
185 <li>
186 <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
187 <a href="https://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
188
189 <li>
190 <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
191 <a href="https://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
192
193 <li>
194 <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
195 </li>
196
197 <li>
198 <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
199 <a href="https://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
200
201 <li>
202 <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
203 </li>
204
205 <li>
206 <?php _e( "Member support forum", 'capsman-enhanced' );?>
207 </li>
208
209 </ul></div>
210
211 <?php
212 echo '<div>';
213 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'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' );
214 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
215 printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions&nbsp;Pro</a>' );
216 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
217 echo '<a href="#pp-hide">hide</a>';
218 echo '</div></div>';
219
220 if ( MULTISITE ) {
221 global $wp_roles;
222 global $wpdb;
223
224 if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
225 $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
226 switch_to_blog($main_site_id);
227 wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
228 }
229
230 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
231 }
232 $capsman->reinstate_db_roles();
233
234 $current = get_role($default);
235
236 $rcaps = $current->capabilities;
237
238 $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin());
239
240 $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
241 $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
242
243 $defined = [];
244 $defined['type'] = apply_filters('cme_filterable_post_types', get_post_types(['public' => true, 'show_ui' => true], 'object', 'or'));
245 $defined['taxonomy'] = apply_filters('cme_filterable_taxonomies', get_taxonomies(['public' => true, 'show_ui' => true], 'object', 'or'));
246
247 // bbPress' dynamic role def requires additional code to enforce stored caps
248 $unfiltered['type'] = apply_filters('presspermit_unfiltered_post_types', ['forum','topic','reply','wp_block']);
249 $unfiltered['type'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['type'] : apply_filters('pp_unfiltered_post_types', $unfiltered['type']);
250
251 $unfiltered['taxonomy'] = apply_filters('presspermit_unfiltered_post_types', ['post_status', 'topic-tag']); // avoid confusion with Edit Flow administrative taxonomy
252 $unfiltered['taxonomy'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['taxonomy'] : apply_filters('pp_unfiltered_taxonomies', $unfiltered['taxonomy']);
253
254 $enabled_taxonomies = cme_get_assisted_taxonomies();
255
256 /*
257 if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
258 $cap_properties[''] = array();
259 $force_distinct_ui = true;
260 }
261 */
262
263 $cap_properties['edit']['type'] = array( 'edit_posts' );
264
265 foreach( $defined['type'] as $type_obj ) {
266 if ( 'attachment' != $type_obj->name ) {
267 if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
268 $cap_properties['edit']['type'][]= 'create_posts';
269 break;
270 }
271 }
272 }
273
274 $cap_properties['edit']['type'][]= 'edit_others_posts';
275 $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
276
277 $cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
278
279 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
280 $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
281
282 $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
283 $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
284
285 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
286 $cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
287 else
288 $cap_properties['delete']['taxonomy'] = array();
289
290 $cap_properties['read']['type'] = array( 'read_private_posts' );
291 $cap_properties['read']['taxonomy'] = array();
292
293 $stati = get_post_stati( array( 'internal' => false ) );
294
295 $cap_type_names = array(
296 '' => __( '&nbsp;', 'capsman-enhanced' ),
297 'read' => __( 'Reading', 'capsman-enhanced' ),
298 'edit' => __( 'Editing Capabilities', 'capsman-enhanced' ),
299 'delete' => __( 'Deletion Capabilities', 'capsman-enhanced' )
300 );
301
302 $cap_tips = array(
303 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ),
304 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
305 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ),
306 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ),
307 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ),
308 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ),
309 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
310 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ),
311 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ),
312 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ),
313 );
314
315 $default_caps = array( 'read_private_posts', 'edit_posts', 'edit_others_posts', 'edit_published_posts', 'edit_private_posts', 'publish_posts', 'delete_posts', 'delete_others_posts', 'delete_published_posts', 'delete_private_posts',
316 'read_private_pages', 'edit_pages', 'edit_others_pages', 'edit_published_pages', 'edit_private_pages', 'publish_pages', 'delete_pages', 'delete_others_pages', 'delete_published_pages', 'delete_private_pages',
317 'manage_categories'
318 );
319 $type_caps = array();
320 $type_metacaps = array();
321
322 // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
323 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
324 unset( $defined['type']['attachment'] );
325 }
326
327 echo '<ul class="cme-listhoriz">';
328
329 // cap_types: read, edit, deletion
330 foreach( array_keys($cap_properties) as $cap_type ) {
331 echo '<li>';
332 echo '<h3>' . $cap_type_names[$cap_type] . '</h3>';
333
334 echo "<div class='cme-cap-type-tables cme-cap-type-tables-$cap_type'>";
335
336 foreach( array_keys($defined) as $item_type ) {
337 if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
338 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
339 continue;
340 }
341
342 $any_term_deletion_caps = false;
343 foreach( array_keys($defined['taxonomy']) as $_tax ) {
344 if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) {
345 $any_term_deletion_caps = true;
346 break;
347 }
348 }
349
350 if ( ! $any_term_deletion_caps )
351 continue;
352 }
353
354 if ( ! count( $cap_properties[$cap_type][$item_type] ) )
355 continue;
356
357 echo "<table class='cme-typecaps cme-typecaps-$cap_type'>";
358
359 echo '<tr><th></th>';
360
361 // label cap properties
362 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
363 $prop = str_replace( '_posts', '', $prop );
364 $prop = str_replace( '_pages', '', $prop );
365 $prop = str_replace( '_terms', '', $prop );
366 $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
367 $prop = str_replace( '_', '<br />', $prop );
368 $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
369 echo "<th $tip{$th_class}>";
370
371 if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
372 echo ucwords($prop);
373 }
374
375 echo '</th>';
376 }
377
378 echo '</tr>';
379
380 foreach( $defined[$item_type] as $key => $type_obj ) {
381 if ( in_array( $key, $unfiltered[$item_type] ) )
382 continue;
383
384 $row = "<tr class='cme_type_{$key}'>";
385
386 if ( $cap_type ) {
387 if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) )
388 continue;
389
390 $type_label = (defined('CME_LEGACY_MENU_NAME_LABEL') && !empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name;
391
392 $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_label . '</a>';
393 $row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
394 $row .= '</td>';
395
396 $display_row = ! empty($force_distinct_ui);
397
398 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
399 $td_classes = array();
400 $checkbox = '';
401 $title = '';
402
403 if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
404 || ! in_array( $type_obj->cap->$prop, $default_caps )
405 || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
406
407 // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
408 if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
409 && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
410 && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
411
412 && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
413 || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop])
414 || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
415 || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
416 || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
417 )
418
419 && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
420 || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop])
421 || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
422 || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
423 || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
424 || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
425 || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
426 || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
427 )
428 ) {
429 // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
430 if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
431 continue;
432 }
433
434 $cap_name = $type_obj->cap->$prop;
435
436 if ( 'taxonomy' == $item_type )
437 $td_classes []= "term-cap";
438 else
439 $td_classes []= "post-cap";
440
441 if ( ! empty($pp_metagroup_caps[$cap_name]) )
442 $td_classes []='cm-has-via-pp';
443
444 if ( $is_administrator || current_user_can($cap_name) ) {
445 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
446 $title = ' title="' . sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ) . '"';
447 } else {
448 $title = ' title="' . $cap_name . '"';
449 }
450
451 $disabled = '';
452 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
453
454 $checkbox = '<input type="checkbox"' . $title . ' name="caps[' . $cap_name . ']" autocomplete="off" value="1" ' . $checked . $disabled . ' />';
455
456 $type_caps [$cap_name] = true;
457 $display_row = true;
458 }
459 } else {
460 //$td_classes []= "cap-unreg";
461 $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
462 }
463
464 if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
465 $td_classes []= "cap-neg";
466 }
467 } else {
468 $td_classes []= "cap-unreg";
469 }
470
471 $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
472
473 $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
474
475 if ( false !== strpos( $td_class, 'cap-neg' ) )
476 $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
477
478 $row .= "</td>";
479 }
480
481 if (!empty($type_obj->map_meta_cap) && !defined('PP_CAPABILITIES_NO_INVALID_SECTION')) {
482 if ('type' == $item_type) {
483 $type_metacaps[$type_obj->cap->read_post] = true;
484 $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts);
485 $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts);
486
487 } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) {
488 $type_metacaps[$type_obj->cap->edit_term] = true;
489 $type_metacaps[$type_obj->cap->delete_term] = true;
490 }
491 }
492 }
493
494 if ( $display_row ) {
495 $row .= '</tr>';
496 echo $row;
497 }
498 }
499
500 echo '</table>';
501
502 } // end foreach item type
503
504 echo '</div>';
505
506 echo '</li>';
507 }
508
509
510 do_action('publishpress-caps_manager_postcaps_section', compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps'));
511
512 $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps);
513
514 echo '</ul>';
515
516 // clicking on post type name toggles corresponding checkbox selections
517 ?>
518 <script type="text/javascript">
519 /* <![CDATA[ */
520 jQuery(document).ready( function($) {
521 $('a[href="#toggle_type_caps"]').click( function() {
522 var chks = $(this).closest('tr').find('input');
523 var set_checked = ! $(chks).first().is(':checked');
524
525 $(chks).each(function(i,e) {
526 $('input[name="' + $(this).attr('name') + '"]').prop('checked', set_checked);
527 });
528
529 return false;
530 });
531
532 $('input[name^="caps["]').click(function() {
533 $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked'));
534 });
535 });
536 /* ]]> */
537 </script>
538 <?php
539
540 echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
541 echo '<table class="form-table cme-checklist"><tr>';
542
543 $checks_per_row = get_option( 'cme_form-rows', 5 );
544 $i = 0; $first_row = true;
545
546 $core_caps = _cme_core_caps();
547 foreach( array_keys($core_caps) as $cap_name ) {
548 if ( ! $is_administrator && ! current_user_can($cap_name) )
549 continue;
550
551 if ( $i == $checks_per_row ) {
552 echo '</tr><tr>';
553 $i = 0;
554 }
555
556 if ( ! isset( $rcaps[$cap_name] ) )
557 $class = 'cap-no';
558 else
559 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
560
561 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
562 $class .= ' cap-metagroup';
563 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
564 } else {
565 $title_text = $cap_name;
566 }
567
568 $disabled = '';
569 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
570 $lock_capability = false;
571 $title = $title_text;
572
573 if ( 'read' == $cap_name ) {
574 if ( ! empty( $block_read_removal ) ) {
575 // prevent the read capability from being removed from a core role, but don't force it to be added
576 if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
577 if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
578 $lock_capability = true;
579 $class .= ' cap-locked';
580 $disabled = 'disabled="disabled"';
581 if ( 'administrator' != $this->current ) {
582 $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
583 }
584 }
585 }
586 }
587 }
588
589 ?>
590 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
591 <span>
592 <?php
593 echo str_replace( '_', ' ', $cap_name );
594 ?>
595 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
596 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
597 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
598 <?php endif; ?>
599 </td>
600
601 <?php
602
603 if ( $lock_capability ) {
604 echo '<input type="hidden" name="caps[' . $cap_name . ']" value="1" />';
605 }
606
607 ++$i;
608 }
609
610 if ( $i == $checks_per_row ) {
611 echo '</tr>';
612 $i = 0;
613 } elseif ( ! $first_row ) {
614 // Now close a wellformed table
615 for ( $i; $i < $checks_per_row; $i++ ){
616 echo '<td>&nbsp;</td>';
617 }
618 echo '</tr>';
619 }
620 ?>
621
622 <tr class="cme-bulk-select">
623 <td colspan="<?php echo $checks_per_row;?>">
624 <span style="float:right">
625 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
626 </span>
627 </td></tr>
628
629 </table>
630 <?php
631 $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
632 $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
633
634 /*
635 $publishpress_status_change_caps = array();
636 foreach( $all_capabilities as $cap_name ) {
637 if (0 === strpos($cap_name, 'status_change_')) {
638 $publishpress_status_change_caps []= $cap_name;
639 }
640 }
641 */
642
643 $plugin_caps = [];
644
645 if (defined('PUBLISHPRESS_VERSION')) {
646 $plugin_caps['PublishPress'] = apply_filters('cme_publishpress_capabilities',
647 array(
648 'edit_metadata',
649 'edit_post_subscriptions',
650 'pp_manage_roles',
651 'pp_set_notification_channel',
652 'pp_view_calendar',
653 'pp_view_content_overview',
654 )
655 );
656 }
657
658 if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) {
659 if ($_caps = apply_filters('cme_multiple_authors_capabilities', array())) {
660 $plugin_caps['PublishPress Authors'] = $_caps;
661 }
662 }
663
664 if (defined('PRESSPERMIT_VERSION')) {
665 $plugin_caps['PublishPress Permissions'] = apply_filters('cme_presspermit_capabilities',
666 array(
667 'edit_own_attachments',
668 'list_others_unattached_files',
669 'pp_administer_content',
670 'pp_assign_roles',
671 'pp_associate_any_page',
672 'pp_create_groups',
673 'pp_create_network_groups',
674 'pp_define_moderation',
675 'pp_define_post_status',
676 'pp_define_privacy',
677 'pp_delete_groups',
678 'pp_edit_groups',
679 'pp_exempt_edit_circle',
680 'pp_exempt_read_circle',
681 'pp_force_quick_edit',
682 'pp_list_all_files',
683 'pp_manage_capabilities',
684 'pp_manage_members',
685 'pp_manage_network_members',
686 'pp_manage_settings',
687 'pp_moderate_any',
688 'pp_set_associate_exceptions',
689 'pp_set_edit_exceptions',
690 'pp_set_read_exceptions',
691 'pp_set_revise_exceptions',
692 'pp_set_term_assign_exceptions',
693 'pp_set_term_associate_exceptions',
694 'pp_set_term_manage_exceptions',
695 'pp_unfiltered',
696 'set_posts_status',
697 )
698 );
699 }
700
701 if (defined('WC_PLUGIN_FILE')) {
702 $plugin_caps['WooCommerce'] = apply_filters('cme_woocommerce_capabilities',
703 array(
704 'assign_product_terms',
705 'assign_shop_coupon_terms',
706 'assign_shop_discount_terms',
707 'assign_shop_order_terms',
708 'assign_shop_payment_terms',
709 'create_shop_orders',
710 'delete_others_products',
711 'delete_others_shop_coupons',
712 'delete_others_shop_discounts',
713 'delete_others_shop_orders',
714 'delete_others_shop_payments',
715 'delete_private_products',
716 'delete_private_shop_coupons',
717 'delete_private_shop_orders',
718 'delete_private_shop_discounts',
719 'delete_private_shop_payments',
720 'delete_product_terms',
721 'delete_products',
722 'delete_published_products',
723 'delete_published_shop_coupons',
724 'delete_published_shop_discounts',
725 'delete_published_shop_orders',
726 'delete_published_shop_payments',
727 'delete_shop_coupons',
728 'delete_shop_coupon_terms',
729 'delete_shop_discount_terms',
730 'delete_shop_discounts',
731 'delete_shop_order_terms',
732 'delete_shop_orders',
733 'delete_shop_payments',
734 'delete_shop_payment_terms',
735 'edit_others_products',
736 'edit_others_shop_coupons',
737 'edit_others_shop_discounts',
738 'edit_others_shop_orders',
739 'edit_others_shop_payments',
740 'edit_private_products',
741 'edit_private_shop_coupons',
742 'edit_private_shop_discounts',
743 'edit_private_shop_orders',
744 'edit_private_shop_payments',
745 'edit_product_terms',
746 'edit_products',
747 'edit_published_products',
748 'edit_published_shop_coupons',
749 'edit_published_shop_discounts',
750 'edit_published_shop_orders',
751 'edit_published_shop_payments',
752 'edit_shop_coupon_terms',
753 'edit_shop_coupons',
754 'edit_shop_discounts',
755 'edit_shop_discount_terms',
756 'edit_shop_order_terms',
757 'edit_shop_orders',
758 'edit_shop_payments',
759 'edit_shop_payment_terms',
760 'export_shop_payments',
761 'export_shop_reports',
762 'import_shop_discounts',
763 'import_shop_payments',
764 'manage_product_terms',
765 'manage_shop_coupon_terms',
766 'manage_shop_discounts',
767 'manage_shop_discount_terms',
768 'manage_shop_payment_terms',
769 'manage_shop_order_terms',
770 'manage_shop_settings',
771 'manage_woocommerce',
772 'publish_products',
773 'publish_shop_coupons',
774 'publish_shop_discounts',
775 'publish_shop_orders',
776 'publish_shop_payments',
777 'read_private_products',
778 'read_private_shop_coupons',
779 'read_private_shop_discounts',
780 'read_private_shop_payments',
781 'read_private_shop_orders',
782 'view_admin_dashboard',
783 'view_shop_discount_stats',
784 'view_shop_payment_stats',
785 'view_shop_reports',
786 'view_shop_sensitive_data',
787 'view_woocommerce_reports',
788 )
789 );
790 }
791
792 $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
793
794 foreach($plugin_caps as $plugin => $__plugin_caps) {
795 $_plugin_caps = array_fill_keys($__plugin_caps, true);
796
797 echo '<h3 class="cme-cap-section">' . sprintf(__( '%s Capabilities', 'capsman-enhanced' ), str_replace('_', ' ', $plugin )) . '</h3>';
798 echo '<table class="form-table cme-checklist"><tr>';
799
800 $checks_per_row = get_option( 'cme_form-rows', 5 );
801 $i = 0; $first_row = true;
802
803 foreach( array_keys($_plugin_caps) as $cap_name ) {
804 if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) || isset($type_metacaps[$cap_name]) ) {
805 continue;
806 }
807
808 if ( ! $is_administrator && ! current_user_can($cap_name) )
809 continue;
810
811 if ( $i == $checks_per_row ) {
812 echo '</tr><tr>';
813 $i = 0;
814 }
815
816 if ( ! isset( $rcaps[$cap_name] ) )
817 $class = 'cap-no';
818 else
819 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
820
821 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
822 $class .= ' cap-metagroup';
823 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
824 } else {
825 $title_text = $cap_name;
826 }
827
828 $disabled = '';
829 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
830 $title = $title_text;
831 ?>
832 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
833 <span>
834 <?php
835 echo str_replace( '_', ' ', $cap_name );
836 ?>
837 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
838 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
839 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
840 <?php endif; ?>
841 </td>
842
843 <?php
844 ++$i;
845 }
846
847 if ( $i == $checks_per_row ) {
848 echo '</tr>';
849 $i = 0;
850 } elseif ( ! $first_row ) {
851 // Now close a wellformed table
852 for ( $i; $i < $checks_per_row; $i++ ){
853 echo '<td>&nbsp;</td>';
854 }
855 echo '</tr>';
856 }
857 ?>
858
859 <tr class="cme-bulk-select">
860 <td colspan="<?php echo $checks_per_row;?>">
861 <span style="float:right">
862 <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
863 </span>
864 </td></tr>
865
866 </table>
867 <?php
868 }
869
870
871 if (array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities) && array_intersect_key($type_metacaps, array_filter($rcaps))) {
872
873 echo '<h3 class="cme-cap-section">' . __( 'Invalid Capabilities', 'capsman-enhanced' ) . '</h3>';
874 ?>
875
876 <div>
877 <span class="cme-subtext">
878 <?php _e('The following entries have no effect. Please assign desired capabilities in the Read / Edit / Delete grid above.', 'capsman-enhanced');?>
879 </span>
880 </div>
881
882 <table class="form-table cme-checklist">
883 <tr>
884 <?php
885 $i = 0; $first_row = true;
886
887 foreach( $all_capabilities as $cap_name ) {
888 if ( ! isset($this->capabilities[$cap_name]) )
889 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
890 }
891
892 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
893
894 foreach ( $this->capabilities as $cap_name => $cap ) :
895 if (!isset($type_metacaps[$cap_name]) || empty($rcaps[$cap_name])) {
896 continue;
897 }
898
899 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
900 continue;
901 }
902
903 if ( $i == $checks_per_row ) {
904 echo '</tr><tr>';
905 $i = 0; $first_row = false;
906 }
907
908 if ( ! isset( $rcaps[$cap_name] ) )
909 $class = 'cap-no';
910 else
911 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
912
913 $title_text = $cap_name;
914
915 $disabled = '';
916 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
917 ?>
918 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
919 <span>
920 <?php
921 echo str_replace( '_', ' ', $cap );
922 ?>
923 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
924 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
925 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
926 <?php endif; ?>
927 </td>
928 <?php
929 $i++;
930 endforeach;
931
932 if ( ! empty($lock_manage_caps_capability) ) {
933 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
934 }
935
936 if ( $i == $checks_per_row ) {
937 echo '</tr><tr>';
938 $i = 0;
939 } else {
940 if ( ! $first_row ) {
941 // Now close a wellformed table
942 for ( $i; $i < $checks_per_row; $i++ ){
943 echo '<td>&nbsp;</td>';
944 }
945 echo '</tr>';
946 }
947 }
948 ?>
949
950 </table><p>&nbsp;</p>
951 <?php
952 } // endif any invalid caps
953
954
955 echo '<p>&nbsp;</p><h3 class="cme-cap-section">' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>';
956
957 ?>
958 <table class="form-table cme-checklist">
959 <tr>
960 <?php
961 $i = 0; $first_row = true;
962
963 foreach( $all_capabilities as $cap_name ) {
964 if ( ! isset($this->capabilities[$cap_name]) )
965 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
966 }
967
968 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
969
970 $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities);
971
972 foreach ($additional_caps as $cap_name => $cap) :
973
974 if ((isset($type_caps[$cap_name]) && !isset($type_metacaps[$cap_name]))
975 || isset($core_caps[$cap_name])
976 || (isset($type_metacaps[$cap_name]) && !empty($rcaps[$cap_name])) ) {
977 continue;
978 }
979
980 if (!isset($type_metacaps[$cap_name]) || !empty($rcaps[$cap_name])) {
981 foreach(array_keys($plugin_caps) as $plugin) {
982 if ( in_array( $cap_name, $plugin_caps[$plugin]) ) {
983 continue 2;
984 }
985 }
986 }
987
988 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
989 continue;
990 }
991
992 // Levels are not shown.
993 if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
994 continue;
995 }
996
997 if ( $i == $checks_per_row ) {
998 echo '</tr><tr>';
999 $i = 0; $first_row = false;
1000 }
1001
1002 if ( ! isset( $rcaps[$cap_name] ) )
1003 $class = 'cap-no';
1004 else
1005 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1006
1007 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1008 $class .= ' cap-metagroup';
1009 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
1010 } else {
1011 $title_text = $cap_name;
1012 }
1013
1014 $disabled = '';
1015 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
1016
1017 if ( 'manage_capabilities' == $cap_name ) {
1018 if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) {
1019 continue;
1020 } elseif ( 'administrator' == $default ) {
1021 $class .= ' cap-locked';
1022 $lock_manage_caps_capability = true;
1023 $disabled = 'disabled="disabled"';
1024 }
1025 }
1026 ?>
1027 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
1028 <span>
1029 <?php
1030 echo str_replace( '_', ' ', $cap );
1031 ?>
1032 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
1033 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1034 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
1035 <?php endif; ?>
1036 </td>
1037 <?php
1038 $i++;
1039 endforeach;
1040
1041 if ( ! empty($lock_manage_caps_capability) ) {
1042 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1043 }
1044
1045 if ( $i == $checks_per_row ) {
1046 echo '</tr><tr>';
1047 $i = 0;
1048 } else {
1049 if ( ! $first_row ) {
1050 // Now close a wellformed table
1051 for ( $i; $i < $checks_per_row; $i++ ){
1052 echo '<td>&nbsp;</td>';
1053 }
1054 echo '</tr>';
1055 }
1056 }
1057 ?>
1058
1059 <tr class="cme-bulk-select">
1060 <td colspan="<?php echo $checks_per_row;?>">
1061 <span style="float:right">
1062 <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
1063 </span>
1064 </td></tr>
1065
1066 </table>
1067
1068 <div>
1069 <?php
1070 $level = ak_caps2level($rcaps);
1071 ?>
1072 <span title="<?php _e('Role level is mostly deprecated. However, it still determines eligibility for Post Author assignment and limits the application of user editing capabilities.', 'capsman-enhanced');?>">
1073
1074 <?php (in_array(get_locale(), ['en_EN', 'en_US'])) ? printf('Role Level:') : _e('Level:', 'capsman-enhanced');?> <select name="level">
1075 <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
1076 <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo $l; ?>&nbsp;</option>
1077 <?php }
1078 ?>
1079 </select>
1080 </span>
1081
1082 </div>
1083 </dd>
1084 </dl>
1085
1086 <?php
1087 $support_pp_only_roles = defined('PRESSPERMIT_ACTIVE');
1088 cme_network_role_ui( $default );
1089 ?>
1090
1091 <p class="submit">
1092 <input type="hidden" name="action" value="update" />
1093 <input type="hidden" name="current" value="<?php echo $default; ?>" />
1094 <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced');?>" class="button-primary" /> &nbsp;
1095
1096 <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
1097 <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>
1098 <?php endif; ?>
1099 </p>
1100
1101 </td>
1102 <td class="sidebar">
1103 <?php do_action('publishpress-caps_sidebar_top');?>
1104
1105 <dl>
1106 <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
1107 <dd style="text-align:center;">
1108 <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
1109 <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
1110 </dd>
1111 </dl>
1112
1113 <?php
1114 $pp_ui->pp_types_ui( $defined['type'] );
1115 $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
1116
1117 do_action('publishpress-caps_sidebar_bottom');
1118 ?>
1119
1120 <dl>
1121 <dt><?php (!in_array(get_locale(), ['en_EN', 'en_US'])) ? _e('Copy this role to', 'capsman-enhanced') : printf('Copy %s Role', translate_user_role($roles[$default])); ?></dt>
1122 <dd style="text-align:center;">
1123 <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
1124 <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
1125
1126 <?php if( $support_pp_only_roles ) : ?>
1127 <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" autocomplete="off" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
1128 <?php endif; ?>
1129
1130 <br />
1131 <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" />
1132 </p>
1133 </dd>
1134 </dl>
1135
1136 <dl>
1137 <dt><?php _e('Rename Role', 'capsman-enhanced'); ?></dt>
1138 <dd style="text-align:center;">
1139 <p><input type="text" name="rename-name" class="regular-text" placeholder="<?php _e('New Role Name', 'capsman-enhanced') ?>" />
1140
1141 <br />
1142 <input type="submit" name="RenameRole" value="<?php _e('Rename', 'capsman-enhanced') ?>" class="button" />
1143 </p>
1144 </dd>
1145 </dl>
1146 </td>
1147 </tr>
1148 </table>
1149 </fieldset>
1150 </form>
1151
1152 <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
1153 cme_publishpressFooter();
1154 }
1155 ?>
1156 </div>
1157
1158 <?php
1159 function cme_network_role_ui( $default ) {
1160 if (!is_multisite() || !is_super_admin() || !is_main_site()) {
1161 return false;
1162 }
1163 ?>
1164
1165 <div style="float:right;margin-left:10px;margin-right:10px">
1166 <?php
1167 if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
1168 $autocreate_roles = array();
1169 ?>
1170 <div style="margin-bottom: 5px">
1171 <label for="cme_autocreate_role" title="<?php _e('Create this role definition in new (future) sites', 'capsman-enhanced');?>"><input type="checkbox" name="cme_autocreate_role" id="cme_autocreate_role" autocomplete="off" value="1" <?php echo checked(in_array($default, $autocreate_roles));?>> <?php _e('include in new sites', 'capsman-enhanced'); ?> </label>
1172 </div>
1173 <div>
1174 <label for="cme_net_sync_role" title="<?php echo esc_attr(__('Copy / update this role definition to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" autocomplete="off" value="1"> <?php _e('sync role to all sites now', 'capsman-enhanced'); ?> </label>
1175 </div>
1176 <div>
1177 <label for="cme_net_sync_options" title="<?php echo esc_attr(__('Copy option settings to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_options" id="cme_net_sync_options" autocomplete="off" value="1"> <?php _e('sync options to all sites now', 'capsman-enhanced'); ?> </label>
1178 </div>
1179 </div>
1180 <?php
1181 return true;
1182 }
1183
1184 function cme_plugin_info_url( $plugin_slug ) {
1185 $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
1186 return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1187 }
1188