PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 2.12.2
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v2.12.2
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 2 years ago plugin-capabilities 2 years ago roles 2 years ago admin-load.php 2 years ago admin.php 2 years ago backup-handler.php 2 years ago backup.php 2 years ago cap-helper.php 4 years ago dashboard.php 2 years ago extractor-capabilities.php 2 years ago filters-admin.php 4 years ago filters-woocommerce.php 4 years ago filters-wp_rest_workarounds.php 4 years ago filters.php 2 years ago functions-admin.php 2 years ago functions.php 2 years ago handler.php 2 years ago inflect-cme.php 4 years ago manager.php 2 years ago network.php 4 years ago plugin-capabilities.php 2 years ago pp-handler.php 4 years ago pp-ui.php 2 years ago publishpress-roles.php 4 years ago settings-handler.php 2 years ago settings-ui.php 2 years ago settings.php 2 years ago test-user-ui.php 2 years ago test-user.php 2 years ago
admin.php
1789 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, $sidebar_metabox_state;
31
32 do_action('publishpress-caps_manager-load');
33
34 $sidebar_metabox_state = get_user_meta($current_user->ID, 'ppc_sidebar_metabox_state', true);
35 if ($sidebar_metabox_state == '' || !is_array($sidebar_metabox_state)) {
36 $sidebar_metabox_state = [];
37 $sidebar_metabox_state['how_to_user_capabilities'] = 'opened';
38 }
39
40 $roles = $this->roles;
41 $default = $this->current;
42
43 if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
44 if ( $current = get_role($default) ) {
45 if ( empty( $current->capabilities['read'] ) ) {
46 ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capability-manager-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
47 }
48 }
49 }
50
51 // include extractor plugin capabilites
52 require_once (dirname(CME_FILE) . '/includes/extractor-capabilities.php');
53
54 require_once (dirname(CME_FILE) . '/includes/roles/roles-functions.php');
55
56 require_once( dirname(__FILE__).'/pp-ui.php' );
57 $pp_ui = new Capsman_PP_UI();
58
59 if( defined('PRESSPERMIT_ACTIVE') ) {
60 $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
61 } else {
62 $pp_metagroup_caps = array();
63 }
64
65 if (defined('PUBLISHPRESS_REVISIONS_VERSION') && function_exists('rvy_get_option')) {
66 $pp_revisions_copy = rvy_get_option("copy_posts_capability");
67 $pp_revisions_revise = rvy_get_option("revise_posts_capability");
68 } else {
69 $pp_revisions_copy = false;
70 $pp_revisions_revise = false;
71 }
72
73 $cme_negate_all_tooltip_msg = '<span class="tool-tip-text">
74 <p>'. esc_html__('negate all (storing as disabled capabilities)', 'capability-manager-enhanced') .'</p>
75 <i></i>
76 </span>';
77 $cme_negate_none_tooltip_msg = '<span class="tool-tip-text">
78 <p>'. esc_html__('negate none (add/remove all capabilities normally)', 'capability-manager-enhanced') .'</p>
79 <i></i>
80 </span>';
81 ?>
82 <div class="wrap publishpress-caps-manage pressshack-admin-wrapper">
83 <div id="icon-capsman-admin" class="icon32"></div>
84
85 <h1><?php esc_html_e('Role Capabilities', 'capability-manager-enhanced') ?></h1>
86
87 <?php
88 pp_capabilities_roles()->notify->display();
89 ?>
90
91 <script type="text/javascript">
92 /* <![CDATA[ */
93 jQuery(document).ready( function($) {
94 $('#publishpress_caps_form').attr('action', 'admin.php?page=pp-capabilities&role=' + $('select[name="role"]').val());
95
96 $('select[name="role"]').change(function(){
97 window.location = '<?php echo esc_url_raw(admin_url('admin.php?page=pp-capabilities&role=')); ?>' + $(this).val() + '';
98 });
99 });
100 /* ]]> */
101 </script>
102
103 <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo esc_attr($this->ID);?>">
104 <?php wp_nonce_field('capsman-general-manager'); ?>
105
106 <?php
107 if (empty($_REQUEST['pp_caps_tab']) && !empty($_REQUEST['added'])) {
108 $pp_tab = 'additional';
109 } else {
110 $pp_tab = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit';
111 }
112 ?>
113
114 <input type="hidden" name="pp_caps_tab" value="<?php echo esc_attr($pp_tab);?>" />
115
116 <fieldset>
117 <table id="akmin" class="clear"><tr><td>
118 <div class="pp-columns-wrapper pp-enable-sidebar">
119 <div class="pp-column-left">
120 <div style="margin-bottom: 20px;">
121 <div class="pp-capabilities-submit-top" style="float:right">
122 <?php
123 $caption = (in_array(sanitize_key(get_locale()), ['en_EN', 'en_US'])) ? 'Save Capabilities' : __('Save Changes');
124 ?>
125 <input type="submit" name="SaveRole" value="<?php echo esc_attr($caption);?>" class="button-primary" />
126 </div>
127
128 <select name="role">
129 <?php
130 foreach ( $roles as $role_name => $name ) {
131 $role_name = sanitize_key($role_name);
132
133 if (pp_capabilities_is_editable_role($role_name)) {
134 $name = translate_user_role($name);
135 echo '<option value="' . esc_attr($role_name) .'"'; selected($default, $role_name); echo '> ' . esc_html($name) . ' &nbsp;</option>';
136 }
137 }
138 ?>
139 </select>
140 </div>
141 <?php
142 $img_url = $capsman->mod_url . '/images/';
143 ?>
144
145 <?php
146 if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
147 $pp_ui->show_capability_hints( $default );
148 }
149
150 if ( MULTISITE ) {
151 global $wp_roles;
152 global $wpdb;
153
154 if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
155 $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
156 switch_to_blog($main_site_id);
157 wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
158 }
159
160 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
161 }
162 $capsman->reinstate_db_roles();
163
164 $current = get_role($default);
165
166 $rcaps = $current->capabilities;
167
168 $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin());
169
170 $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
171 $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
172
173 $defined = [];
174 $defined['type'] = apply_filters('cme_filterable_post_types', get_post_types(['public' => true, 'show_ui' => true], 'object', 'or'));
175
176 if (in_array(get_locale(), ['en_EN', 'en_US'])) {
177 $defined['type']['wp_navigation']->label = __('Nav Menus (Block)', 'capability-manager-enhanced');
178 } else {
179 $defined['type']['wp_navigation']->label .= ' (' . __('Block', 'capability-manager-enhanced') . ')';
180 }
181
182 $defined['taxonomy'] = apply_filters('cme_filterable_taxonomies', get_taxonomies(['public' => true, 'show_ui' => true], 'object', 'or'));
183 $defined['taxonomy']['nav_menu'] = get_taxonomy('nav_menu');
184
185 if (in_array(get_locale(), ['en_EN', 'en_US'])) {
186 $defined['taxonomy']['nav_menu']->label = __('Nav Menus (Legacy)', 'capability-manager-enhanced');
187 } else {
188 $defined['taxonomy']['nav_menu']->label .= ' (' . __('Legacy', 'capability-manager-enhanced') . ')';
189 }
190
191 // bbPress' dynamic role def requires additional code to enforce stored caps
192 $unfiltered['type'] = apply_filters('presspermit_unfiltered_post_types', ['forum','topic','reply','wp_block']);
193 $unfiltered['type'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['type'] : apply_filters('pp_unfiltered_post_types', $unfiltered['type']);
194
195 $unfiltered['taxonomy'] = apply_filters('presspermit_unfiltered_post_types', ['post_status', 'topic-tag']); // avoid confusion with Edit Flow administrative taxonomy
196 $unfiltered['taxonomy'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['taxonomy'] : apply_filters('pp_unfiltered_taxonomies', $unfiltered['taxonomy']);
197
198 $enabled_taxonomies = cme_get_assisted_taxonomies();
199
200 $cap_properties['edit']['type'] = array( 'edit_posts' );
201
202 foreach( $defined['type'] as $type_obj ) {
203 if ( 'attachment' != $type_obj->name ) {
204 if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
205 $cap_properties['edit']['type'][]= 'create_posts';
206 break;
207 }
208 }
209 }
210
211 $cap_properties['edit']['type'][]= 'edit_others_posts';
212 $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
213
214 $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
215 $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
216
217 if (defined('PRESSPERMIT_PRO_FILE')) {
218 $cap_properties['list']['type'] = ['list_posts', 'list_others_posts', 'list_published_posts', 'list_private_posts'];
219 }
220
221 if ($pp_revisions_copy) {
222 $cap_properties['copy']['type'] = ['copy_posts', 'copy_others_posts', 'copy_published_posts', 'copy_private_posts'];
223 }
224
225 if ($pp_revisions_revise) {
226 $cap_properties['revise']['type'] = ['revise_posts', 'revise_others_posts', 'revise_published_posts', 'revise_private_posts'];
227 }
228
229 $cap_properties['read']['type'] = array( 'read_private_posts' );
230
231 $cap_properties['taxonomies']['taxonomy'] = array( 'manage_terms', 'edit_terms', 'assign_terms', 'delete_terms' );
232
233 $stati = get_post_stati( array( 'internal' => false ) );
234
235 $cap_type_names = array(
236 '' => __( '&nbsp;', 'capability-manager-enhanced' ),
237 'read' => __( 'Reading', 'capability-manager-enhanced' ),
238 'edit' => __( 'Editing', 'capability-manager-enhanced' ),
239 'delete' => __( 'Deletion', 'capability-manager-enhanced' ),
240 'taxonomies' => __( 'Taxonomies', 'capability-manager-enhanced' ),
241 );
242
243 if (defined('PRESSPERMIT_PRO_FILE')) {
244 $cap_type_names['list'] = __('Listing', 'capability-manager-enhanced');
245 }
246
247 if ($pp_revisions_copy) {
248 $cap_type_names['copy'] = __('Copy', 'capability-manager-enhanced');
249 }
250
251 if ($pp_revisions_revise) {
252 $cap_type_names['revise'] = __('Revise', 'capability-manager-enhanced');
253 }
254
255 $cap_tips = array(
256 'read_private' => esc_attr__( 'can read posts which are currently published with private visibility', 'capability-manager-enhanced' ),
257 'edit' => esc_attr__( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capability-manager-enhanced' ),
258 'edit_others' => esc_attr__( 'can edit posts which were created by other users', 'capability-manager-enhanced' ),
259 'edit_published' => esc_attr__( 'can edit posts which are currently published', 'capability-manager-enhanced' ),
260 'edit_private' => esc_attr__( 'can edit posts which are currently published with private visibility', 'capability-manager-enhanced' ),
261 'publish' => esc_attr__( 'can make a post publicly visible', 'capability-manager-enhanced' ),
262 'delete' => esc_attr__( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capability-manager-enhanced' ),
263 'delete_others' => esc_attr__( 'can delete posts which were created by other users', 'capability-manager-enhanced' ),
264 'delete_published' => esc_attr__( 'can delete posts which are currently published', 'capability-manager-enhanced' ),
265 'delete_private' => esc_attr__( 'can delete posts which are currently published with private visibility', 'capability-manager-enhanced' ),
266 );
267
268 $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',
269 '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',
270 'manage_categories'
271 );
272
273 if (defined('PRESSPERMIT_PRO_FILE')) {
274 $default_caps = array_merge($default_caps, ['list_posts', 'list_others_posts', 'list_published_posts', 'list_private_posts', 'list_pages', 'list_others_pages', 'list_published_pages', 'list_private_pages']);
275 }
276
277 if ($pp_revisions_copy) {
278 $default_caps = array_merge($default_caps, ['copy_posts', 'copy_others_posts', 'copy_pages', 'copy_others_pages']);
279 }
280
281 if ($pp_revisions_revise) {
282 $default_caps = array_merge($default_caps, ['revise_posts', 'revise_others_posts', 'revise_pages', 'revise_others_pages']);
283 }
284
285 $type_caps = array();
286 $type_metacaps = array();
287
288 // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
289 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
290 unset( $defined['type']['attachment'] );
291 }
292 ?>
293
294 <script type="text/javascript">
295 /* <![CDATA[ */
296 jQuery(document).ready( function($) {
297 if ($('.ppc-capabilities-tabs li.ppc-capabilities-tab-active').hasClass('ppc-full-width')) {
298 $('.capabilities-sidebar').hide();
299 $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr');
300 }
301
302 // Tabs and Content display
303 $('.ppc-capabilities-tabs > ul > li').click( function() {
304 var $pp_tab = $(this).attr('data-content');
305 var data_slug = $(this).attr('data-slug');
306
307 $("[name='pp_caps_tab']").val(data_slug);
308
309 // Show current Content
310 $('.ppc-capabilities-content > div').not('.capabilities-sidebar').hide();
311 $('#' + $pp_tab).show();
312
313 var post_ops = ['read', 'edit', 'delete', 'list'];
314 $('.capabilities-sidebar .ppc-post-types').toggle(post_ops.indexOf(data_slug,) != -1);
315
316 $('.capabilities-sidebar .ppc-taxonomies').toggle(data_slug == 'taxonomies');
317 $('.capabilities-sidebar .ppc-detailed-taxonomies').toggle(data_slug == 'taxonomies');
318
319 if ($(this).hasClass('ppc-full-width')) {
320 $('.capabilities-sidebar').hide();
321 $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr');
322 } else {
323 $('.capabilities-sidebar').show();
324
325 if ($(window).width() > 1199) {
326 $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr 200px 70px');
327 }
328 }
329
330 $('#' + $pp_tab + '-taxonomy').show();
331
332 // Active current Tab
333 $('.ppc-capabilities-tabs > ul > li').removeClass('ppc-capabilities-tab-active');
334 $(this).addClass('ppc-capabilities-tab-active');
335
336 // Scroll to content area (for responsive display)
337 if ($(window).width() <= 1199) {
338 $([document.documentElement, document.body]).animate({
339 scrollTop: $("#capabilities_content").offset().top - 20
340 }, 500);
341 }
342 });
343 });
344 /* ]]> */
345 </script>
346
347 <div id="ppc-capabilities-wrapper" class="postbox">
348 <div class="ppc-capabilities-tabs">
349 <ul>
350 <?php
351 $full_width_tabs = apply_filters('pp_capabilities_full_width_tabs', []);
352
353 if (empty($_REQUEST['pp_caps_tab']) && !empty($_REQUEST['added'])) {
354 $active_tab_slug = 'additional';
355 } else {
356 $active_tab_slug = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit';
357 }
358
359 $active_tab_id = "cme-cap-type-tables-{$active_tab_slug}";
360
361 $ppc_tab_active = 'ppc-capabilities-tab-active';
362
363 // caps: edit, delete, read
364 foreach( array_keys($cap_properties) as $cap_type ) {
365 $tab_id = "cme-cap-type-tables-$cap_type";
366 $classes = [];
367
368 if ($tab_id == $active_tab_id) {
369 $classes []= $ppc_tab_active;
370 }
371
372 if (!empty($full_width_tabs[$cap_type])) {
373 $classes []= 'ppc-full-width';
374 }
375
376 $class = implode(' ', $classes);
377
378 echo '<li data-slug="'. esc_attr($cap_type) . '"' . ' data-content="cme-cap-type-tables-' . esc_attr($cap_type) . '" class="' . esc_attr($class) . '">'
379 . esc_html($cap_type_names[$cap_type]) .
380 '</li>';
381 }
382
383 if ($extra_tabs = apply_filters('pp_capabilities_extra_post_capability_tabs', [])) {
384 foreach($extra_tabs as $tab_slug => $tab_caption) {
385 $tab_slug = esc_attr($tab_slug);
386
387 $tab_id = "cme-cap-type-tables-{$tab_slug}";
388
389 $classes = [];
390
391 if ($tab_id == $active_tab_id) {
392 $classes []= $ppc_tab_active;
393 }
394
395 if (!empty($full_width_tabs[$tab_slug])) {
396 $classes []= 'ppc-full-width';
397 }
398
399 $class = implode(' ', $classes);
400
401 echo '<li data-slug="' . esc_attr($tab_slug) . '"' . ' data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($class) . '">'
402 . esc_html($tab_caption) .
403 '</li>';
404 }
405 }
406
407 //grouped capabilities
408 $grouped_caps = [];
409 $grouped_caps_lists = [];
410
411 //add media related caps
412 $grouped_caps['Media'] = [
413 'edit_files',
414 'upload_files',
415 'unfiltered_upload',
416 ];
417 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Media']);
418
419 //add comments related caps
420 $grouped_caps['Comments'] = [
421 'moderate_comments'
422 ];
423 if (isset($rcaps['edit_comment'])) {
424 $type_metacaps['edit_comment'] = 1;
425 }
426 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Comments']);
427
428 //add users related caps
429 $grouped_caps['Users'] = [
430 'create_users',
431 'delete_users',
432 'edit_users',
433 'list_users',
434 'promote_users',
435 'remove_users',
436 ];
437 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Users']);
438
439 //add admin options related caps
440 $grouped_caps['Admin'] = [
441 'manage_options',
442 'edit_dashboard',
443 'export',
444 'import',
445 'read',
446 'update_core',
447 'unfiltered_html',
448 ];
449 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Admin']);
450
451 //add themes related caps
452 $grouped_caps['Themes'] = [
453 'delete_themes',
454 'edit_themes',
455 'install_themes',
456 'switch_themes',
457 'update_themes',
458 'edit_theme_options',
459 'manage_links',
460 ];
461 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Themes']);
462
463 //add plugin related caps
464 $grouped_caps['Plugins'] = [
465 'activate_plugins',
466 'delete_plugins',
467 'edit_plugins',
468 'install_plugins',
469 'update_plugins',
470 ];
471 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Plugins']);
472
473 if (is_multisite()) {
474 //add multisite caps
475 $grouped_caps['Multisite'] = [
476 'create_sites',
477 'delete_sites',
478 'manage_network',
479 'manage_sites',
480 'manage_network_users',
481 'manage_network_plugins',
482 'manage_network_themes',
483 'manage_network_options',
484 'upgrade_network',
485 'setup_network',
486 ];
487 $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Multisite']);
488 }
489
490 $grouped_caps = apply_filters('cme_grouped_capabilities', $grouped_caps);
491
492 foreach($grouped_caps as $grouped_title => $__grouped_caps) {
493 switch ($grouped_title) {
494 case 'Comments' :
495 $grouped_title = __('Comments');
496 break;
497
498 case 'Media' :
499 $grouped_title = __('Media');
500 break;
501
502 case 'Users' :
503 $grouped_title = __('Users');
504 break;
505
506 case 'Themes' :
507 $grouped_title = __('Themes');
508 break;
509
510 case 'Plugins' :
511 $grouped_title = __('Plugins');
512 break;
513
514 case 'Multisite' :
515 $grouped_title = esc_html__('Multisite', 'capability-manager-enhanced');
516 break;
517
518 case 'Admin' :
519 $grouped_title = esc_html__('Admin', 'capability-manager-enhanced');
520 break;
521
522 default:
523 $grouped_title = esc_html($grouped_title);
524 }
525
526 $tab_slug = pp_capabilities_convert_to_slug(sanitize_title($grouped_title));
527 $tab_id = 'cme-cap-type-tables-' . $tab_slug;
528 $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
529
530 echo '<li data-slug="' . esc_attr($tab_slug) . '" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">'
531 . esc_html(str_replace('_', ' ', $grouped_title)) .
532 '</li>';
533 }
534
535 // caps: plugins
536 $plugin_caps = apply_filters('cme_plugin_capabilities', []);
537
538 foreach($plugin_caps as $plugin_title => $__plugin_caps) {
539 $plugin_title = esc_html($plugin_title);
540
541 $tab_slug = pp_capabilities_convert_to_slug(sanitize_title($plugin_title));
542 $tab_id = 'cme-cap-type-tables-' . $tab_slug;
543 $tab_name = esc_html(str_replace('_', ' ', $plugin_title));
544 // support extractor staging label
545 $tab_name = str_replace('(CAPABILITYEXTRACTOR)', '<span class="capability-extractor-label">CE</span>', $tab_name);
546 $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
547
548 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
549 echo '<li data-slug="' . esc_attr($tab_slug) . '" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">'
550 . $tab_name .
551 '</li>';
552 }
553
554 $tab_id = "cme-cap-type-tables-invalid";
555 $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
556 $tab_caption = esc_html__( 'Invalid Capabilities', 'capability-manager-enhanced' );
557 echo '<li id="cme_tab_invalid_caps" data-slug="invalid" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '" style="display:none;">' . esc_html($tab_caption) . '</li>';
558
559 $tab_id = "cme-cap-type-tables-additional";
560 $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
561 $tab_caption = esc_html__( 'Additional', 'capability-manager-enhanced' );
562 echo '<li data-slug="additional" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">' . esc_html($tab_caption) . '</li>';
563 ?>
564 </ul>
565 </div>
566
567 <div id="capabilities_content" class="ppc-capabilities-content">
568 <?php
569 // caps: read, edit, deletion
570 foreach( array_keys($cap_properties) as $cap_type ) {
571
572 foreach( array_keys($defined) as $item_type ) {
573
574
575 if (!isset($cap_properties[$cap_type][$item_type])) {
576 continue;
577 }
578 if ( ! count( $cap_properties[$cap_type][$item_type] ) )
579 continue;
580
581 $tab_id = "cme-cap-type-tables-" . pp_capabilities_convert_to_slug($cap_type);
582 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
583
584 $any_caps = false;
585
586 if ($item_type == 'taxonomy') {
587 $tab_id .= '-taxonomy';
588
589 ob_start();
590 }
591
592 echo "<div id='" . esc_attr($tab_id) . "' style='display:" . esc_attr($div_display) . ";'>";
593
594 $caption_pattern = ('taxonomy' == $item_type) ? esc_html__('Term %s Capabilities', 'capability-manager-enhanced') : esc_html__('Post %s Capabilities', 'capability-manager-enhanced');
595
596 echo '<h3>' . sprintf($caption_pattern, esc_html($cap_type_names[$cap_type])) . '</h3>';
597
598 echo '<div class="ppc-filter-wrapper">';
599 echo '<select class="ppc-filter-select">';
600 $filter_caption = ('taxonomy' == $item_type) ? __('Filter by taxonomy', 'capability-manager-enhanced') : __('Filter by post type', 'capability-manager-enhanced');
601 echo '<option value="">' . esc_html($filter_caption) . '</option>';
602 echo '</select>';
603 echo ' <button class="button secondary-button ppc-filter-select-reset" type="button">' . esc_html__('Clear') . '</button>';
604 echo '</div>';
605
606 echo "<table class='widefat striped cme-typecaps cme-typecaps-basic cme-typecaps-" . esc_attr($cap_type) . "'>";
607
608 echo '<thead><tr><th class="pp-header-checkall">';
609 echo '<input type="checkbox" name="pp_toggle_all" class="excluded-input" autocomplete="off"> &nbsp;';
610 echo '</th>';
611
612 // label cap properties
613 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
614 $prop = str_replace( '_posts', '', $prop );
615 $prop = str_replace( '_pages', '', $prop );
616 $prop = str_replace( '_terms', '', $prop );
617
618 if (in_array($prop, ['copy_published', 'copy_private', 'revise_published', 'revise_private'])) {
619 echo "<th></th>";
620 continue;
621 }
622
623 $tip = ( isset( $cap_tips[$prop] ) ) ? $cap_tips[$prop] : '';
624 $th_class = ( 'taxonomy' == $item_type ) ? 'term-cap' : 'post-cap';
625 echo "<th style='text-align:center;' title='" . esc_attr($tip) . "' class='" . esc_attr($th_class) . "'>";
626
627 if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
628 echo str_replace('_', '<br />', esc_html(ucwords($prop)));
629 }
630
631 echo '</th>';
632 }
633
634 echo '</tr></thead>';
635 $attachement_cap_position = 0;
636 foreach( $defined[$item_type] as $key => $type_obj ) {
637 if ( in_array( $key, $unfiltered[$item_type] ) )
638 continue;
639
640 if (in_array($cap_type, ['copy', 'revise'])) {
641 global $revisionary;
642
643 if (!empty($revisionary) && !empty($revisionary->enabled_post_types) && empty($revisionary->enabled_post_types[$key])) {
644 continue;
645 }
646 }
647
648 $row = "<tr class='cme_type_" . esc_attr($key) . "'>";
649
650 if ( $cap_type ) {
651
652 if (empty($force_distinct_ui) && empty($cap_properties[$cap_type][$item_type])) {
653 continue;
654 }
655
656 if (defined('PRESSPERMIT_VERSION') || defined('PRESSPERMIT_PRO_VERSION')) {
657 //add list capabilities
658 if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->list_posts)) {
659 $type_obj->cap->list_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_posts);
660 }
661 if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->list_others_posts)) {
662 $type_obj->cap->list_others_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_others_posts);
663 }
664 if (isset($type_obj->cap->edit_published_posts) && !isset($type_obj->cap->list_published_posts)) {
665 $type_obj->cap->list_published_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_published_posts);
666 }
667 if (isset($type_obj->cap->edit_private_posts) && !isset($type_obj->cap->list_private_posts)) {
668 $type_obj->cap->list_private_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_private_posts);
669 }
670 }
671
672 if ($pp_revisions_copy) {
673 //add copy capabilities
674 if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->copy_posts)) {
675 $type_obj->cap->copy_posts = str_replace('edit_', 'copy_', $type_obj->cap->edit_posts);
676 }
677 if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->copy_others_posts)) {
678 $type_obj->cap->copy_others_posts = str_replace('edit_', 'copy_', $type_obj->cap->edit_others_posts);
679 }
680 }
681
682 if ($pp_revisions_revise) {
683 //add revise capabilities
684 if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->revise_posts)) {
685 $type_obj->cap->revise_posts = str_replace('edit_', 'revise_', $type_obj->cap->edit_posts);
686 }
687 if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->revise_others_posts)) {
688 $type_obj->cap->revise_others_posts = str_replace('edit_', 'revise_', $type_obj->cap->edit_others_posts);
689 }
690 }
691
692 if ('wp_navigation' == $type_obj->name) {
693 $type_label = __('Nav Menus (Block)', 'capability-manager-enhanced');
694 } elseif ('nav_menu' == $type_obj->name) {
695 $type_label = __('Nav Menus (Legacy)', 'capability-manager-enhanced');
696 } else {
697 $type_label = (defined('CME_LEGACY_MENU_NAME_LABEL') && !empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name;
698 }
699
700 if (!empty($type_obj->name)) {
701 if ('taxonomy' == $item_type) {
702 $type_tooltip = sprintf(__( 'The slug for this taxonomy is %s', 'capability-manager-enhanced' ), '<strong>' . esc_html($type_obj->name) . '</strong>' );
703 } else {
704 $type_tooltip = sprintf(__( 'The slug for this post type is %s', 'capability-manager-enhanced' ), '<strong>' . esc_html($type_obj->name) . '</strong>' );
705 }
706 $type_tooltip_class = 'ppc-tool-tip disabled';
707 $type_tooltip_msg = '<span class="tool-tip-text">
708 <p>'. $type_tooltip .'</p>
709 <i></i>
710 </span>';
711 } else {
712 $type_tooltip_class = '';
713 $type_tooltip_msg = '';
714 }
715
716 $row .= "<td>";
717 $row .= '<input type="checkbox" class="pp-row-action-rotate excluded-input"> &nbsp;';
718 $row .= "<span class='{$type_tooltip_class}'><a class='cap_type' href='#toggle_type_caps'>" . esc_html($type_label) . '</a> '. $type_tooltip_msg .'</span>';
719 $row .= '<a style="display: none;" href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
720 $row .= '</td>';
721
722 $display_row = ! empty($force_distinct_ui);
723 $col_count = 0;
724
725 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
726 $td_classes = array();
727 $checkbox = '';
728 $cap_title = '';
729 $disabled_cap = false;
730
731 if ($type_obj->name === 'attachment') {
732 $attachement_cap_position++;
733 }
734
735 if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
736 || ! in_array( $type_obj->cap->$prop, $default_caps )
737 || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
738
739 // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
740 if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
741 && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
742 && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
743
744 && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
745 || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop])
746 || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
747 || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
748 || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
749 )
750
751 && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
752 || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop])
753 || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
754 || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
755 || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
756 || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
757 || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
758 || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
759 )
760 && (!in_array($type_obj->cap->$prop, $grouped_caps_lists)) //capabilitiy not enforced in $grouped_caps_lists
761 && $type_obj->cap->$prop !== 'manage_post_tags'
762 ) {
763 // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
764 if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
765 continue;
766 }
767
768 $cap_name = sanitize_text_field($type_obj->cap->$prop);
769
770 if ( 'taxonomy' == $item_type )
771 $td_classes []= "term-cap";
772 else
773 $td_classes []= "post-cap";
774
775 if ( $is_administrator || current_user_can($cap_name) ) {
776 $chk_classes = [];
777
778 $cap_title = '';
779 if (! empty($pp_metagroup_caps[$cap_name]) ) {
780 $tool_tip = sprintf(__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' );
781 $chk_classes []= 'cm-has-via-pp';
782 } else {
783 $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' );
784 }
785
786 $chk_class = ( $chk_classes ) ? ' class="' . implode(' ', $chk_classes) . '"' : '';
787
788 $checkbox = '<div class="ppc-tool-tip disabled"><input type="checkbox"' . $chk_class . ' name="caps[' . esc_attr($cap_name) . ']" autocomplete="off" value="1" ' . checked(1, ! empty($rcaps[$cap_name]), false ) . ' />
789 <div class="tool-tip-text">
790 <p>'. $tool_tip .'</p>
791 <i></i>
792 </div>
793 </div>';
794
795 $type_caps [$cap_name] = true;
796 $display_row = true;
797 $any_caps = true;
798 $disabled_cap = false;
799 }
800 } else {
801
802 // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
803 if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
804 continue;
805 }
806
807 if ($type_obj->cap->$prop === 'manage_post_tags') {
808 $type_obj->cap->$prop = 'manage_categories';
809 }
810
811 $disabled_cap = true;
812 $display_row = true;
813 $cap_name = sanitize_text_field($type_obj->cap->$prop);
814 $cap_title = '';
815
816
817 if ($cap_name === 'manage_categories') {
818 $tool_tip = sprintf(__( 'This capability is controlled by %s', 'capability-manager-enhanced' ), '<strong>manage_categories</strong>' );
819
820 } else {
821 $tool_tip = sprintf(__('This capability is controlled by %s Use the sidebar settings to allow this to be controlled independently.', 'capability-manager-enhanced'), '<strong>' . $cap_name . '</strong>.<br /><br />');
822 }
823
824 $checkbox = '<div class="ppc-tool-tip disabled"><input disabled class="disabled" type="checkbox" ' . checked(1, ! empty($rcaps[$cap_name]), false ) . ' />
825 <div class="tool-tip-text">
826 <p>'. $tool_tip .'</p>
827 <i></i>
828 </div>
829 </div>';
830 }
831
832 if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
833 $td_classes []= "cap-neg";
834 }
835 } else {
836 if ($type_obj->name === 'attachment') {
837 if ($attachement_cap_position === 1 || $attachement_cap_position === 3) {
838 $tool_tip =__('Use the sidebar settings to allow this to be controlled independently.', 'capability-manager-enhanced');
839 } else {
840 $tool_tip =__('This capability is not available for this post type.', 'capability-manager-enhanced');
841 }
842
843 } else {
844 $tool_tip =__('This capability is not available for this post type.', 'capability-manager-enhanced');
845 }
846 $checkbox = '<div class="ppc-tool-tip disabled">&nbsp; &nbsp; &nbsp; &nbsp;
847 <div class="tool-tip-text">
848 <p>'. $tool_tip .'</p>
849 <i></i>
850 </div>
851 </div>';
852 $td_classes []= "cap-unreg";
853 }
854
855 $td_classes[] = 'capability-checkbox-rotate';
856 $td_classes[] = $cap_name;
857
858 $td_class = ( $td_classes ) ? implode(' ', $td_classes) : '';
859
860 $row .= '<td class="' . esc_attr($td_class) . '" title="' . esc_attr($cap_title) . '"' . "><span class='ppc-tool-tip disabled cap-x'>X</span>$checkbox";
861
862 if ( !$disabled_cap && false !== strpos( $td_class, 'cap-neg' ) )
863 $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . esc_attr($cap_name) . ']" value="" />';
864
865 $row .= "</td>";
866
867 $col_count++;
868 }
869
870 if ('taxonomy' == $item_type) {
871 for ($i = $col_count; $i < 4; $i++) {
872 $row .= "<td></td>";
873 }
874 }
875
876 if (!empty($type_obj->map_meta_cap) && !defined('PP_CAPABILITIES_NO_INVALID_SECTION')) {
877 if ('type' == $item_type) {
878 if (!in_array($type_obj->cap->read_post, $grouped_caps_lists)
879 && !in_array($type_obj->cap->edit_post, $grouped_caps_lists)
880 && !in_array($type_obj->cap->delete_post, $grouped_caps_lists)
881 ) {
882 $type_metacaps[$type_obj->cap->read_post] = true;
883 $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts);
884 $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts);
885 }
886 } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) {
887 if (!in_array($type_obj->cap->edit_term, $grouped_caps_lists)
888 && !in_array($type_obj->cap->delete_term, $grouped_caps_lists)
889 ) {
890 $type_metacaps[$type_obj->cap->edit_term] = true;
891 $type_metacaps[$type_obj->cap->delete_term] = true;
892 }
893 }
894 }
895 }
896
897 if ( $display_row ) {
898 $row .= '</tr>';
899
900 // Escaped piecemeal upstream; cannot be late-escaped until upstream UI output logic is reworked
901 echo $row;
902 }
903 }
904
905 echo '</table>';
906
907 if ($cap_type === 'list' && (defined('PRESSPERMIT_VERSION') || defined('PRESSPERMIT_PRO_VERSION'))) {
908 echo '<p class="pp-subtext"> '. esc_html__('Admin listing access is normally provided by the "Edit" capabilities. These "List" capabilities only apply if the corresponding "Edit" capability is missing. Also, these "List" capabilities can grant access, but not deny access.', 'capability-manager-enhanced') .' </p>';
909 }
910
911 do_action('publishpress-caps_manager_postcaps_table', $cap_type, $item_type, compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps', 'active_tab_id'));
912
913 echo '</div>';
914
915 if ($item_type == 'taxonomy') {
916 if ($any_caps) {
917 ob_flush();
918 } else {
919 ob_clean();
920 }
921 }
922
923 } // end foreach item type
924 }
925
926 if (empty($caps_manager_postcaps_section)) {
927 $caps_manager_postcaps_section = '';
928 }
929
930 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'));
931
932 $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps);
933
934 // clicking on post type name toggles corresponding checkbox selections
935
936 // caps: grouped
937 $grouped_caps = apply_filters('cme_grouped_capabilities', $grouped_caps);
938
939 foreach($grouped_caps as $grouped_title => $__grouped_caps) {
940 $grouped_title = esc_html($grouped_title);
941
942 $_grouped_caps = array_fill_keys($__grouped_caps, true);
943
944 $tab_id = 'cme-cap-type-tables-' . esc_attr(pp_capabilities_convert_to_slug($grouped_title));
945 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
946
947 echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '">';
948
949 echo '<h3 class="cme-cap-section">' . esc_html(str_replace('_', ' ', $grouped_title)) . '</h3>';
950
951 echo '<div class="ppc-filter-wrapper">';
952 echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">';
953 echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>';
954 echo '</div>';
955 echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>';
956
957 echo '<table class="widefat fixed striped form-table cme-checklist single-checkbox-table">';
958
959 $centinel_ = true;
960 $checks_per_row = get_option( 'cme_form-rows', 1 );
961 $i = 0; $first_row = true;
962
963 ?>
964 <tr class="cme-bulk-select">
965 <td colspan="<?php echo (int) $checks_per_row;?>">
966 <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
967 <span style="float:right">
968 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
969 </span>
970 </td>
971 </tr>
972 <?php
973 foreach( array_keys($_grouped_caps) as $cap_name ) {
974 $cap_name = sanitize_text_field($cap_name);
975
976 if ( isset( $type_caps[$cap_name] ) || isset($type_metacaps[$cap_name]) ) {
977 continue;
978 }
979
980 if ( ! $is_administrator && ! current_user_can($cap_name) )
981 continue;
982
983 // Output first <tr>
984 if ( $centinel_ == true ) {
985 echo '<tr class="' . esc_attr($cap_name) . '">';
986 $centinel_ = false;
987 }
988
989 if ( $i == $checks_per_row ) {
990 echo '</tr><tr class="' . esc_attr($cap_name) . '">';
991 $i = 0;
992 }
993
994 if ( ! isset( $rcaps[$cap_name] ) )
995 $class = 'cap-no';
996 else
997 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
998
999 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1000 $class .= ' cap-metagroup';
1001 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), $cap_name );
1002 } else {
1003 $title_text = $cap_name;
1004 }
1005
1006 $disabled = '';
1007 $checked = !empty($rcaps[$cap_name]) ? 'checked' : '';
1008 $cap_title = $title_text;
1009 ?>
1010 <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> />
1011 <span>
1012 <?php
1013 echo esc_html(str_replace( '_', ' ', $cap_name));
1014 ?>
1015 </span></label></span><a href="#" class="neg-cap" style="visibility: hidden;">&nbsp;x&nbsp;</a>
1016 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1017 <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" />
1018 <?php endif; ?>
1019 </td>
1020
1021 <?php
1022 ++$i;
1023 }
1024
1025 if ( $i == $checks_per_row ) {
1026 echo '</tr>';
1027 $i = 0;
1028 } elseif ( ! $first_row ) {
1029 // Now close a wellformed table
1030 for ( $i; $i < $checks_per_row; $i++ ){
1031 echo '<td>&nbsp;</td>';
1032 }
1033 echo '</tr>';
1034 }
1035 ?>
1036
1037 <tr class="cme-bulk-select">
1038 <td colspan="<?php echo (int) $checks_per_row;?>">
1039 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1040 <span style="float:right">
1041 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1042 </span>
1043 </td>
1044 </tr>
1045
1046 </table>
1047 </div>
1048 <?php
1049 }
1050
1051 // caps: other
1052
1053 $tab_id = "cme-cap-type-tables-other";
1054 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
1055 ?>
1056 <div id="<?php echo esc_attr($tab_id);?>" style="display:<?php echo esc_attr($div_display);?>">
1057 <?php
1058
1059 echo '<h3>' . esc_html__( 'WordPress Core Capabilities', 'capability-manager-enhanced' ) . '</h3>';
1060
1061 echo '<div class="ppc-filter-wrapper">';
1062 echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">';
1063 echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>';
1064 echo '</div>';
1065 echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>';
1066
1067 echo '<table class="widefat fixed striped form-table cme-checklist">';
1068
1069 $centinel_ = true;
1070 $checks_per_row = get_option( 'cme_form-rows', 1 );
1071 $i = 0; $first_row = true;
1072
1073 ?>
1074 <tr class="cme-bulk-select">
1075 <td colspan="<?php echo (int) $checks_per_row;?>">
1076 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1077 <span style="float:right">
1078 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1079 </span>
1080 </td>
1081 </tr>
1082
1083 <tr class="cme-bulk-select">
1084 <td colspan="<?php echo (int) $checks_per_row;?>">
1085 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1086 <span style="float:right">
1087 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1088 </span>
1089 </td>
1090 </tr>
1091
1092 </table>
1093 </div>
1094
1095 <?php
1096 $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
1097 $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
1098
1099 // caps: plugins
1100 $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
1101
1102 foreach($plugin_caps as $plugin_title => $__plugin_caps) {
1103 $plugin_title = esc_html($plugin_title);
1104
1105 $_plugin_caps = array_fill_keys($__plugin_caps, true);
1106
1107 $tab_id = 'cme-cap-type-tables-' . esc_attr(pp_capabilities_convert_to_slug($plugin_title));
1108 $tab_name = esc_html(str_replace('_', ' ', $plugin_title));
1109 // support extractor staging label
1110 $tab_name = str_replace('(CAPABILITYEXTRACTOR)', '<span class="capability-extractor-label">CE</span>', $tab_name);
1111 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
1112
1113 echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '">';
1114
1115 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1116 echo '<h3 class="cme-cap-section">' . sprintf(esc_html__( 'Plugin Capabilities &ndash; %s', 'capability-manager-enhanced' ), $tab_name) . '</h3>';
1117
1118 echo '<div class="ppc-filter-wrapper">';
1119 echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">';
1120 echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>';
1121 echo '</div>';
1122 echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>';
1123
1124 echo '<table class="widefat fixed striped form-table cme-checklist single-checkbox-table">';
1125
1126 $centinel_ = true;
1127 $checks_per_row = get_option( 'cme_form-rows', 1 );
1128 $i = 0; $first_row = true;
1129
1130 ?>
1131 <tr class="cme-bulk-select">
1132 <td colspan="<?php echo (int) $checks_per_row;?>">
1133 <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1134 <span style="float:right">
1135 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1136 </span>
1137 </td>
1138 </tr>
1139 <?php
1140 foreach( array_keys($_plugin_caps) as $cap_name ) {
1141 $cap_name = sanitize_text_field($cap_name);
1142
1143 if ( isset( $type_caps[$cap_name] ) || in_array($cap_name, $grouped_caps_lists) || isset($type_metacaps[$cap_name]) ) {
1144 continue;
1145 }
1146
1147 if ( ! $is_administrator && ! current_user_can($cap_name) )
1148 continue;
1149
1150 // Output first <tr>
1151 if ( $centinel_ == true ) {
1152 echo '<tr class="' . esc_attr($cap_name) . '">';
1153 $centinel_ = false;
1154 }
1155
1156 if ( $i == $checks_per_row ) {
1157 echo '</tr><tr class="' . esc_attr($cap_name) . '">';
1158 $i = 0;
1159 }
1160
1161 if ( ! isset( $rcaps[$cap_name] ) )
1162 $class = 'cap-no';
1163 else
1164 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1165
1166 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1167 $class .= ' cap-metagroup';
1168 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), $cap_name );
1169 } else {
1170 $title_text = $cap_name;
1171 }
1172
1173 if ($cap_name === 'manage_capabilities_user_testing') {
1174 $warning_message = '&nbsp; <span class="ppc-tool-tip"><span class="dashicons dashicons-info-outline"></span><span class="tool-tip-text"><p>'. sprintf(esc_html__('The User Testing feature also requires the %1$s edit_users %2$s capability.', 'capability-manager-enhanced'), '<strong>', '</strong>') .'</p><i></i></span></span>';
1175 } else {
1176 $warning_message = '';
1177 }
1178
1179 $disabled = '';
1180 $checked = !empty($rcaps[$cap_name]) ? 'checked' : '';
1181
1182 $cap_title = $title_text;
1183 ?>
1184 <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> />
1185 <span>
1186 <?php
1187 echo esc_html(str_replace( '_', ' ', $cap_name));
1188 ?>
1189 </span></label></span><?php echo $warning_message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><a href="#" class="neg-cap" style="visibility: hidden;">&nbsp;x&nbsp;</a>
1190 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1191 <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" />
1192 <?php endif; ?>
1193 </td>
1194
1195 <?php
1196 ++$i;
1197 }
1198
1199 if ( $i == $checks_per_row ) {
1200 echo '</tr>';
1201 $i = 0;
1202 } elseif ( ! $first_row ) {
1203 // Now close a wellformed table
1204 for ( $i; $i < $checks_per_row; $i++ ){
1205 echo '<td>&nbsp;</td>';
1206 }
1207 echo '</tr>';
1208 }
1209 ?>
1210
1211 <tr class="cme-bulk-select">
1212 <td colspan="<?php echo (int) $checks_per_row;?>">
1213 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1214 <span style="float:right">
1215 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1216 </span>
1217 </td>
1218 </tr>
1219
1220 </table>
1221 </div>
1222 <?php
1223 }
1224
1225 // caps: invalid
1226 if (array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities) && array_intersect_key($type_metacaps, array_filter($rcaps))) {
1227 $tab_id = "cme-cap-type-tables-invalid";
1228 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
1229
1230 echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '">';
1231 echo '<h3 class="cme-cap-section">' . esc_html__( 'Invalid Capabilities', 'capability-manager-enhanced' ) . '</h3>';
1232 ?>
1233
1234 <div>
1235 <span class="cme-subtext">
1236 <?php esc_html_e('The following entries have no effect. Please assign desired capabilities on the Editing / Deletion / Reading tabs.', 'capability-manager-enhanced');?>
1237 </span>
1238 </div>
1239
1240 <table class="widefat fixed striped form-table cme-checklist single-checkbox-table">
1241 <tr>
1242 <?php
1243 $i = 0; $first_row = true;
1244 $invalid_caps_capabilities = [];
1245 foreach( $all_capabilities as $cap_name ) {
1246 if ( ! isset($this->capabilities[$cap_name]) )
1247 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
1248 }
1249
1250 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
1251
1252 foreach ( $this->capabilities as $cap_name => $cap ) :
1253 $cap_name = sanitize_text_field($cap_name);
1254
1255 if (!isset($type_metacaps[$cap_name]) || empty($rcaps[$cap_name])) {
1256 continue;
1257 }
1258
1259 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
1260 continue;
1261 }
1262
1263 if ( $i == $checks_per_row ) {
1264 echo '</tr><tr>';
1265 $i = 0; $first_row = false;
1266 }
1267
1268 if ( ! isset( $rcaps[$cap_name] ) )
1269 $class = 'cap-no';
1270 else
1271 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1272
1273 $title_text = $cap_name;
1274
1275 $disabled = '';
1276 $checked = !empty($rcaps[$cap_name]) ? 'checked' : '';
1277 $invalid_caps_capabilities[] = $cap_name;
1278 ?>
1279 <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><label title="<?php echo esc_attr($title_text);?>"><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> />
1280 <span>
1281 <?php
1282 echo esc_html(str_replace( '_', ' ', $cap ));
1283 ?>
1284 </span></label><a href="#" class="neg-cap" style="visibility: hidden;">&nbsp;x&nbsp;</a>
1285 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1286 <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" />
1287 <?php endif; ?>
1288 </td>
1289 <?php
1290 $i++;
1291 endforeach;
1292
1293 if ( ! empty($lock_manage_caps_capability) ) {
1294 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1295 }
1296
1297 if ( $i == $checks_per_row ) {
1298 echo '</tr><tr>';
1299 $i = 0;
1300 } else {
1301 if ( ! $first_row ) {
1302 // Now close a wellformed table
1303 for ( $i; $i < $checks_per_row; $i++ ){
1304 echo '<td>&nbsp;</td>';
1305 }
1306 echo '</tr>';
1307 }
1308 }
1309 ?>
1310
1311 <?php if (!empty($invalid_caps_capabilities)) : ?>
1312 <script type="text/javascript">
1313 /* <![CDATA[ */
1314 jQuery(document).ready( function($) {
1315 $('#cme_tab_invalid_caps').show();
1316 });
1317 /* ]]> */
1318 </script>
1319 <?php endif; ?>
1320
1321 </table>
1322 </div>
1323 <?php
1324 } // endif any invalid caps
1325
1326 $tab_id = "cme-cap-type-tables-additional";
1327 $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none';
1328 ?>
1329 <div id="<?php echo esc_attr($tab_id);?>" style="display:<?php echo esc_attr($div_display);?>">
1330 <?php
1331 // caps: additional
1332 echo '<h3 class="cme-cap-section">' . esc_html__( 'Additional Capabilities', 'capability-manager-enhanced' ) . '</h3>';
1333
1334 echo '<div class="ppc-filter-wrapper">';
1335 echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">';
1336 echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . __('Clear') . '</button>';
1337 echo '</div>';
1338 echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>';
1339 ?>
1340 <table class="widefat fixed striped form-table cme-checklist single-checkbox-table">
1341
1342 <tr class="cme-bulk-select">
1343 <td colspan="<?php echo (int) $checks_per_row;?>">
1344 <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1345 <span style="float:right">
1346 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1347 </span>
1348 </td>
1349 </tr>
1350
1351 <?php
1352 $centinel_ = true;
1353 $i = 0; $first_row = true;
1354
1355 foreach( $all_capabilities as $cap_name ) {
1356 if ( ! isset($this->capabilities[$cap_name]) )
1357 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
1358 }
1359
1360 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
1361
1362 $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities);
1363
1364 foreach ($additional_caps as $cap_name => $cap) :
1365 $cap_name = sanitize_text_field($cap_name);
1366
1367 if ((isset($type_caps[$cap_name]) && !isset($type_metacaps[$cap_name]))
1368 || in_array($cap_name, $grouped_caps_lists)
1369 || (isset($type_metacaps[$cap_name]) && !empty($rcaps[$cap_name])) ) {
1370 continue;
1371 }
1372
1373 if (!isset($type_metacaps[$cap_name]) || !empty($rcaps[$cap_name])) {
1374 foreach(array_keys($plugin_caps) as $plugin_title) {
1375 if ( in_array( $cap_name, $plugin_caps[$plugin_title]) ) {
1376 continue 2;
1377 }
1378 }
1379 }
1380
1381 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
1382 continue;
1383 }
1384
1385 // Levels are not shown.
1386 if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
1387 continue;
1388 }
1389
1390 // Output first <tr>
1391 if ( $centinel_ == true ) {
1392 echo '<tr class="' . esc_attr($cap_name) . '">';
1393 $centinel_ = false;
1394 }
1395
1396 if ( $i == $checks_per_row ) {
1397 echo '</tr><tr class="' . esc_attr($cap_name) . '">';
1398 $i = 0; $first_row = false;
1399 }
1400
1401 if ( ! isset( $rcaps[$cap_name] ) )
1402 $class = 'cap-no';
1403 else
1404 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1405
1406 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1407 $class .= ' cap-metagroup';
1408 $title_text = sprintf( esc_html__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' );
1409 } else {
1410 $title_text = '';
1411 }
1412
1413 $disabled = '';
1414 $checked = !empty($rcaps[$cap_name]) ? 'checked' : '';
1415
1416 if ( 'manage_capabilities' == $cap_name ) {
1417 if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) {
1418 continue;
1419 } elseif ( 'administrator' == $default ) {
1420 $class .= ' cap-locked';
1421 $lock_manage_caps_capability = true;
1422 $disabled = ' disabled ';
1423 }
1424 }
1425 ?>
1426 <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . ' ' . esc_attr($disabled);?> />
1427 <span>
1428 <?php
1429 echo esc_html(str_replace( '_', ' ', $cap ));
1430 ?>
1431 </span></label><?php if ($title_text) :?><span class="tool-tip-text" style="text-align: center;">
1432 <p><?php echo $title_text; ?></p>
1433 <i></i>
1434 </span><?php endif;?></span><a href="#" class="neg-cap" style="visibility: hidden;">&nbsp;x&nbsp;</a>
1435 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1436 <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" />
1437 <?php endif; ?>
1438 </td>
1439 <?php
1440 $i++;
1441 endforeach;
1442
1443 if ( ! empty($lock_manage_caps_capability) ) {
1444 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1445 }
1446
1447 if ( $i == $checks_per_row ) {
1448 echo '</tr><tr>';
1449 $i = 0;
1450 } else {
1451 if ( ! $first_row ) {
1452 // Now close a wellformed table
1453 for ( $i; $i < $checks_per_row; $i++ ){
1454 echo '<td>&nbsp;</td>';
1455 }
1456 echo '</tr>';
1457 }
1458 }
1459 ?>
1460
1461 <tr class="cme-bulk-select">
1462 <td colspan="<?php echo (int) $checks_per_row;?>">
1463 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span>
1464 <span style="float:right">
1465 &nbsp;&nbsp;<span class="ppc-tool-tip disabled"><a class="cme-neg-all" href="#" >X</a> <?php echo $cme_negate_all_tooltip_msg; ?> </span> <span class="ppc-tool-tip disabled"><a class="cme-switch-all" href="#" >X</a> <?php echo $cme_negate_none_tooltip_msg; ?> </span>
1466 </span>
1467 </td>
1468 </tr>
1469
1470 </table>
1471 </div>
1472
1473 <div class="capabilities-sidebar pp-column-right">
1474 <?php
1475 do_action('publishpress-caps_sidebar_top');
1476
1477 $banners = new PublishPress\WordPressBanners\BannersMain;
1478
1479 $banner_messages = [];
1480 $banner_messages[] = esc_html__('Capabilities allows you change the permissions for any user role.', 'capability-manager-enhanced');
1481 $banner_messages[] = sprintf(esc_html__('%1$s = Capability granted %2$s', 'capability-manager-enhanced'), '<table class="pp-capabilities-cb-key"><tr><td class="pp-cap-icon pp-cap-icon-checked"><input type="checkbox" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'" checked disabled></td><td>', '</td></tr>');
1482 $banner_messages[] = sprintf(esc_html__('%1$s = Capability not granted %2$s', 'capability-manager-enhanced'), '<tr><td class="pp-cap-icon"><input type="checkbox" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'" disabled></td><td class="pp-cap-not-checked-definition">', '</td></tr>');
1483 $banner_messages[] = sprintf(esc_html__('%1$s = Capability denied, even if granted by another role %2$s', 'capability-manager-enhanced'), '<tr><td class="pp-cap-icon pp-cap-x"><span class="cap-x pp-cap-key" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'">X</span></td><td class="cap-x-definition">', '</td></tr></table>');
1484 if (defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) {
1485 if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) {
1486 $additional_message = sprintf(
1487 // back compat with existing language string
1488 str_replace(
1489 ['&lt;strong&gt;', '&lt;/strong&gt;'],
1490 ['<strong>', '</strong>'],
1491 esc_html__('You can also configure this role as a %sPermission Group%s.', 'capability-manager-enhanced')
1492 ),
1493 '<a href="' . esc_url_raw(admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}")) . '">',
1494 '</a>'
1495 );
1496 $banner_messages[] = '<p class="cme-subtext">' . $additional_message . '</p>';
1497 }
1498 }
1499
1500 ?>
1501 <div class="ppc-sidebar-panel-metabox meta-box-sortables">
1502 <?php $meta_box_state = (isset($sidebar_metabox_state['how_to_user_capabilities'])) ? $sidebar_metabox_state['how_to_user_capabilities'] : 'closed'; ?>
1503 <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>">
1504 <input
1505 name="ppc_metabox_state[how_to_user_capabilities]"
1506 type="hidden"
1507 class="metabox-state"
1508 value="<?php echo esc_attr($meta_box_state); ?>"
1509 />
1510 <div class="postbox-header">
1511 <h2 class="hndle ui-sortable-handle"><?php esc_html_e('How to use Capabilities', 'capability-manager-enhanced'); ?></h2>
1512 <div class="handle-actions">
1513 <button type="button" class="handlediv">
1514 <span class="toggle-indicator"></span>
1515 </button>
1516 </div>
1517 </div>
1518 <div class="inside">
1519 <?php
1520 $banners->pp_display_banner(
1521 '',
1522 '',
1523 $banner_messages,
1524 'https://publishpress.com/knowledge-base/capabilities-screen/',
1525 __('View Documentation', 'capability-manager-enhanced'),
1526 '',
1527 'button ppc-checkboxes-documentation-link'
1528 );
1529 ?>
1530 </div>
1531 </div>
1532 </div>
1533
1534 <?php
1535 $pp_ui->pp_types_ui( $defined['type'] );
1536 $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
1537 ?>
1538
1539 <div class="ppc-sidebar-panel-metabox meta-box-sortables ppc-safe">
1540 <?php $meta_box_state = (isset($sidebar_metabox_state['capabilities_safe_to_use'])) ? $sidebar_metabox_state['capabilities_safe_to_use'] : 'closed'; ?>
1541 <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>">
1542 <input
1543 name="ppc_metabox_state[capabilities_safe_to_use]"
1544 type="hidden"
1545 class="metabox-state"
1546 value="<?php echo esc_attr($meta_box_state); ?>"
1547 />
1548 <div class="postbox-header">
1549 <h2 class="hndle ui-sortable-handle"><?php esc_html_e( 'Capabilities is Safe to Use', 'capability-manager-enhanced' ); ?></h2>
1550 <div class="handle-actions">
1551 <button type="button" class="handlediv">
1552 <span class="toggle-indicator"></span>
1553 </button>
1554 </div>
1555 </div>
1556 <div class="inside">
1557 <?php
1558 $banners->pp_display_banner(
1559 '',
1560 '',
1561 array(
1562 __( 'WordPress stores role capabilities in your database, where they remain even if the plugin is deactivated.', 'capability-manager-enhanced' ),
1563 __( 'Whenever you use PublishPress Capabilities to save changes, it also creates a backup which you can use to restore a previous configuration.', 'capability-manager-enhanced' )
1564 ),
1565 admin_url( 'admin.php?page=pp-capabilities-backup' ),
1566 __( 'Go to the Backup feature', 'capability-manager-enhanced' ),
1567 '',
1568 'button'
1569 );
1570 ?>
1571 </div>
1572 </div>
1573 </div>
1574
1575 <div class="ppc-sidebar-panel-metabox meta-box-sortables ppc-add-cap">
1576 <?php $meta_box_state = (isset($sidebar_metabox_state['add_capability'])) ? $sidebar_metabox_state['add_capability'] : 'closed'; ?>
1577 <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>">
1578 <input
1579 name="ppc_metabox_state[add_capability]"
1580 type="hidden"
1581 class="metabox-state"
1582 value="<?php echo esc_attr($meta_box_state); ?>"
1583 />
1584 <div class="postbox-header">
1585 <h2 class="hndle ui-sortable-handle"><?php esc_html_e('Add a New Capability', 'capability-manager-enhanced'); ?></h2>
1586 <div class="handle-actions">
1587 <button type="button" class="handlediv">
1588 <span class="toggle-indicator"></span>
1589 </button>
1590 </div>
1591 </div>
1592 <div class="inside" style="text-align:center;">
1593 <p>
1594 <input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
1595 <input type="submit" name="AddCap" value="<?php esc_attr_e('Add to role', 'capability-manager-enhanced') ?>" class="button" />
1596 </p>
1597 <br />
1598 <div class="cme-subtext"><?php _e('New capabilities are controlled on the Additonal tab.', 'capability-manager-enhanced');?></div>
1599 </div>
1600 </div>
1601 </div>
1602
1603 <?php
1604 do_action('publishpress-caps_sidebar_bottom');
1605 ?>
1606
1607 </div><!-- right sidebar within tab panel -->
1608 </div>
1609 </div>
1610
1611
1612 <script type="text/javascript">
1613 /* <![CDATA[ */
1614 jQuery(document).ready( function($) {
1615 $('a[href="#pp-more"]').click( function() {
1616 $('#pp_features').show();
1617 return false;
1618 });
1619 $('a[href="#pp-hide"]').click( function() {
1620 $('#pp_features').hide();
1621 return false;
1622 });
1623 });
1624 /* ]]> */
1625 </script>
1626
1627 <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
1628
1629 <div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo esc_url_raw($img_url);?>pp-logo.png" alt="<?php esc_attr_e('PublishPress Permissions', 'capability-manager-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features">
1630 <li>
1631 <?php esc_html_e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capability-manager-enhanced' );?>
1632 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1633
1634 <li>
1635 <?php esc_html_e( "Assign standard WP roles supplementally for a specific post type", 'capability-manager-enhanced' );?>
1636 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1637
1638 <li>
1639 <?php esc_html_e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1640 </li>
1641
1642 <li>
1643 <?php esc_html_e( "Customize reading permissions per-category or per-post", 'capability-manager-enhanced' );?>
1644 <a href="https://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1645
1646 <li>
1647 <?php esc_html_e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1648 <a href="https://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1649
1650 <li>
1651 <?php esc_html_e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1652 <a href="https://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1653
1654 <li>
1655 <?php esc_html_e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1656 <a href="https://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1657
1658 <li>
1659 <?php esc_html_e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1660 <a href="https://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1661
1662 <li>
1663 <?php esc_html_e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1664 <a href="https://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1665
1666 <li>
1667 <?php esc_html_e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1668 </li>
1669
1670 <li>
1671 <?php esc_html_e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1672 <a href="https://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" alt="*" src="<?php echo esc_url_raw($img_url);?>play.png" /></a></li>
1673
1674 <li>
1675 <?php esc_html_e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capability-manager-enhanced' );?>
1676 </li>
1677
1678 <li>
1679 <?php esc_html_e( "Member support forum", 'capability-manager-enhanced' );?>
1680 </li>
1681
1682 </ul></div>
1683
1684 <?php
1685 echo '<div>';
1686 printf( esc_html__('%1$sgrab%2$s %3$s', 'capability-manager-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . esc_url_raw(cme_plugin_info_url('press-permit-core')) . '" class="thickbox" title="' . sprintf( esc_attr__('%s (free install)', 'capability-manager-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' );
1687 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
1688 printf( esc_html__('%1$sbuy%2$s %3$s', 'capability-manager-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( esc_attr__('%s info/purchase', 'capability-manager-enhanced'), 'Permissions Pro' ) . '">Permissions&nbsp;Pro</a>' );
1689 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
1690 echo '<a href="#pp-hide">hide</a>';
1691 echo '</div></div>';
1692
1693 ///
1694 ?>
1695 <script type="text/javascript">
1696 /* <![CDATA[ */
1697 jQuery(document).ready( function($) {
1698 $('a[href="#toggle_type_caps"]').click( function() {
1699 var chks = $(this).closest('tr').find('input');
1700 var set_checked = ! $(chks).first().is(':checked');
1701
1702 $(chks).each(function(i,e) {
1703 $('input[name="' + $(this).attr('name') + '"]').prop('checked', set_checked);
1704 });
1705
1706 return false;
1707 });
1708
1709 $('input[name^="caps["]').click(function() {
1710 $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked'));
1711 });
1712 });
1713 /* ]]> */
1714 </script>
1715
1716 <div style="display:none; float:right;">
1717 <?php
1718 $level = ak_caps2level($rcaps);
1719 ?>
1720 <span title="<?php esc_attr_e('Role level is mostly deprecated. However, it still determines eligibility for Post Author assignment and limits the application of user editing capabilities.', 'capability-manager-enhanced');?>">
1721
1722 <?php (in_array(get_locale(), ['en_EN', 'en_US'])) ? printf('Role Level:') : esc_html_e('Level:', 'capability-manager-enhanced');?> <select name="level">
1723 <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
1724 <option value="<?php echo (int) $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo (int) $l; ?>&nbsp;</option>
1725 <?php }
1726 ?>
1727 </select>
1728 </span>
1729
1730 </div>
1731
1732 <?php
1733 $support_pp_only_roles = defined('PRESSPERMIT_ACTIVE');
1734 cme_network_role_ui( $default );
1735 ?>
1736
1737 <p class="submit" style="padding-top:0;">
1738 <input type="hidden" name="action" value="update" />
1739 <input type="hidden" name="current" value="<?php echo esc_attr($default); ?>" />
1740
1741 <?php
1742 $save_caption = (in_array(sanitize_key(get_locale()), ['en_EN', 'en_US'])) ? 'Save Capabilities' : esc_html__('Save Changes');
1743 ?>
1744 <input type="submit" name="SaveRole" value="<?php echo esc_attr($save_caption);?>" class="button-primary" /> &nbsp;
1745 </p>
1746
1747 </div><!-- .pp-column-left -->
1748 </div><!-- .pp-columns-wrapper -->
1749 </td></tr></table> <!-- .akmin -->
1750 </fieldset>
1751 </form>
1752
1753 <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
1754 cme_publishpressFooter();
1755 }
1756 ?>
1757 </div>
1758
1759 <?php
1760 function cme_network_role_ui( $default ) {
1761 if (!is_multisite() || !is_super_admin() || !is_main_site()) {
1762 return false;
1763 }
1764 ?>
1765
1766 <div style="float:right;margin-left:10px;margin-right:10px">
1767 <?php
1768 if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
1769 $autocreate_roles = array();
1770 ?>
1771 <div style="margin-bottom: 5px">
1772 <label for="cme_autocreate_role" title="<?php esc_attr_e('Create this role definition in new (future) sites', 'capability-manager-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 esc_html_e('include in new sites', 'capability-manager-enhanced'); ?> </label>
1773 </div>
1774 <div>
1775 <label for="cme_net_sync_role" title="<?php echo esc_attr__('Copy / update this role definition to all sites now', 'capability-manager-enhanced');?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" autocomplete="off" value="1"> <?php esc_html_e('sync role to all sites now', 'capability-manager-enhanced'); ?> </label>
1776 </div>
1777 <div>
1778 <label for="cme_net_sync_options" title="<?php echo esc_attr__('Copy option settings to all sites now', 'capability-manager-enhanced');?>"><input type="checkbox" name="cme_net_sync_options" id="cme_net_sync_options" autocomplete="off" value="1"> <?php esc_html_e('sync options to all sites now', 'capability-manager-enhanced'); ?> </label>
1779 </div>
1780 </div>
1781 <?php
1782 return true;
1783 }
1784
1785 function cme_plugin_info_url( $plugin_slug ) {
1786 $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
1787 return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1788 }
1789