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