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