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