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