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