PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.10.1
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.10.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
CoreAdmin.php 6 years ago admin.php 5 years ago backup-handler.php 5 years ago backup.php 5 years ago cap-helper.php 6 years ago filters-admin.php 6 years ago filters-woocommerce.php 7 years ago filters-wp_rest_workarounds.php 6 years ago filters.php 5 years ago functions-admin.php 6 years ago functions.php 5 years ago handler.php 5 years ago inflect-cme.php 7 years ago manager.php 6 years ago network.php 6 years ago pp-handler.php 6 years ago pp-ui.php 5 years ago publishpress-roles.php 6 years ago
admin.php
1227 lines
1 <?php
2 /**
3 * General Admin for Role Capabilities.
4 * Provides admin pages to create and manage roles and capabilities.
5 *
6 * @author Jordi Canals, Kevin Behrens
7 * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2020 PublishPress
8 * @license GNU General Public License version 2
9 * @link https://publishpress.com
10 *
11 *
12 * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
13 * Modifications Copyright 2020, PublishPress <help@publishpress.com>
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * version 2 as published by the Free Software Foundation.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 **/
27
28 global $capsman, $cme_cap_helper, $current_user;
29
30 do_action('publishpress-caps_manager-load');
31
32 $roles = $this->roles;
33 $default = $this->current;
34
35 if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
36 if ( $current = get_role($default) ) {
37 if ( empty( $current->capabilities['read'] ) ) {
38 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>' ) );
39 }
40 }
41 }
42
43 require_once( dirname(__FILE__).'/pp-ui.php' );
44 $pp_ui = new Capsman_PP_UI();
45
46 if( defined('PRESSPERMIT_ACTIVE') ) {
47 $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
48 } else {
49 $pp_metagroup_caps = array();
50 }
51 ?>
52 <div class="wrap publishpress-caps-manage pressshack-admin-wrapper">
53 <?php if( defined('PRESSPERMIT_ACTIVE') ) :
54 pp_icon();
55 $style = 'style="height:60px;"';
56 ?>
57 <?php else:
58 $style = '';
59 ?>
60 <div id="icon-capsman-admin" class="icon32"></div>
61 <?php endif; ?>
62
63 <h1 <?php echo $style;?>><?php _e('Role Capabilities', 'capsman-enhanced') ?></h1>
64
65 <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo $this->ID ?>">
66 <?php wp_nonce_field('capsman-general-manager'); ?>
67 <fieldset>
68 <table id="akmin">
69 <tr>
70 <td class="content">
71 <dl>
72 <dt>
73 <?php
74 $role_caption = (defined('PUBLISHPRESS_VERSION'))
75 ? '<a href="' . admin_url("admin.php?page=pp-manage-roles&action=edit-role&role-id={$this->current}") . '">' . translate_user_role($roles[$default]) . '</a>'
76 : translate_user_role($roles[$default]);
77
78 printf(__('Capabilities for %s', 'capsman-enhanced'), $role_caption);
79 ?>
80 </dt>
81
82 <dd>
83 <div style="float:right">
84 <input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
85 </div>
86
87 <?php
88 global $capsman;
89 $img_url = $capsman->mod_url . '/images/';
90 ?>
91 <div class="publishpress-headline">
92 <span class="cme-subtext">
93 <?php
94 $msg = __( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' );
95
96 if (defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) {
97 if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) {
98 $msg = sprintf(
99 __('<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'),
100 '<a href="' . admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}") . '">',
101 '</a>'
102 );
103 }
104 }
105 echo $msg;
106 ?>
107 </span>
108 </div>
109
110 <?php
111 if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
112 $pp_ui->show_capability_hints( $default );
113 }
114 ?>
115
116 <script type="text/javascript">
117 /* <![CDATA[ */
118 jQuery(document).ready( function($) {
119 $('a[href="#pp-more"]').click( function() {
120 $('#pp_features').show();
121 return false;
122 });
123 $('a[href="#pp-hide"]').click( function() {
124 $('#pp_features').hide();
125 return false;
126 });
127 });
128 /* ]]> */
129 </script>
130
131 <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
132
133 <br /><div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo $img_url;?>pp-logo.png" alt="<?php _e('PublishPress Permissions', 'capsman-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features">
134 <li>
135 <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
136 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
137
138 <li>
139 <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
140 <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
141
142 <li>
143 <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
144 </li>
145
146 <li>
147 <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
148 <a href="https://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
149
150 <li>
151 <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
152 <a href="https://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
153
154 <li>
155 <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
156 <a href="https://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
157
158 <li>
159 <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
160 <a href="https://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
161
162 <li>
163 <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
164 <a href="https://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
165
166 <li>
167 <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
168 <a href="https://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
169
170 <li>
171 <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
172 </li>
173
174 <li>
175 <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
176 <a href="https://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
177
178 <li>
179 <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
180 </li>
181
182 <li>
183 <?php _e( "Member support forum", 'capsman-enhanced' );?>
184 </li>
185
186 </ul></div>
187
188 <?php
189 echo '<div>';
190 printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' );
191 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
192 printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions&nbsp;Pro</a>' );
193 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
194 echo '<a href="#pp-hide">hide</a>';
195 echo '</div></div>';
196
197 if ( MULTISITE ) {
198 global $wp_roles;
199 global $wpdb;
200
201 if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
202 switch_to_blog(1);
203 wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
204 }
205
206 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
207 }
208 $capsman->reinstate_db_roles();
209
210 $current = get_role($default);
211
212 $rcaps = $current->capabilities;
213
214 $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin());
215
216 $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
217 $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
218
219 $defined = array();
220 $defined['type'] = apply_filters('cme_filterable_post_types', get_post_types( array( 'public' => true, 'show_ui' => true), 'object', 'or' ));
221 $defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
222
223 $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array( 'forum','topic','reply','wp_block' ) ); // bbPress' dynamic role def requires additional code to enforce stored caps
224 $unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy
225
226 $enabled_taxonomies = cme_get_assisted_taxonomies();
227
228 /*
229 if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
230 $cap_properties[''] = array();
231 $force_distinct_ui = true;
232 }
233 */
234
235 $cap_properties['edit']['type'] = array( 'edit_posts' );
236
237 foreach( $defined['type'] as $type_obj ) {
238 if ( 'attachment' != $type_obj->name ) {
239 if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
240 $cap_properties['edit']['type'][]= 'create_posts';
241 break;
242 }
243 }
244 }
245
246 $cap_properties['edit']['type'][]= 'edit_others_posts';
247 $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
248
249 $cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
250
251 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
252 $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
253
254 $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
255 $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
256
257 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
258 $cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
259 else
260 $cap_properties['delete']['taxonomy'] = array();
261
262 $cap_properties['read']['type'] = array( 'read_private_posts' );
263 $cap_properties['read']['taxonomy'] = array();
264
265 $stati = get_post_stati( array( 'internal' => false ) );
266
267 $cap_type_names = array(
268 '' => __( '&nbsp;', 'capsman-enhanced' ),
269 'read' => __( 'Reading', 'capsman-enhanced' ),
270 'edit' => __( 'Editing Capabilities', 'capsman-enhanced' ),
271 'delete' => __( 'Deletion Capabilities', 'capsman-enhanced' )
272 );
273
274 $cap_tips = array(
275 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ),
276 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
277 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ),
278 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ),
279 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ),
280 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ),
281 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
282 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ),
283 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ),
284 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ),
285 );
286
287 $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',
288 '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',
289 'manage_categories'
290 );
291 $type_caps = array();
292 $type_metacaps = array();
293
294 // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
295 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
296 unset( $defined['type']['attachment'] );
297 }
298
299 echo '<ul class="cme-listhoriz">';
300
301 // cap_types: read, edit, deletion
302 foreach( array_keys($cap_properties) as $cap_type ) {
303 echo '<li>';
304 echo '<h3>' . $cap_type_names[$cap_type] . '</h3>';
305
306 echo "<div class='cme-cap-type-tables cme-cap-type-tables-$cap_type'>";
307
308 foreach( array_keys($defined) as $item_type ) {
309 if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
310 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
311 continue;
312 }
313
314 $any_term_deletion_caps = false;
315 foreach( array_keys($defined['taxonomy']) as $_tax ) {
316 if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) {
317 $any_term_deletion_caps = true;
318 break;
319 }
320 }
321
322 if ( ! $any_term_deletion_caps )
323 continue;
324 }
325
326 if ( ! count( $cap_properties[$cap_type][$item_type] ) )
327 continue;
328
329 echo "<table class='cme-typecaps cme-typecaps-$cap_type'>";
330
331 echo '<tr><th></th>';
332
333 // label cap properties
334 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
335 $prop = str_replace( '_posts', '', $prop );
336 $prop = str_replace( '_pages', '', $prop );
337 $prop = str_replace( '_terms', '', $prop );
338 $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
339 $prop = str_replace( '_', '<br />', $prop );
340 $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
341 echo "<th $tip{$th_class}>";
342
343 if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
344 echo ucwords($prop);
345 }
346
347 echo '</th>';
348 }
349
350 echo '</tr>';
351
352 foreach( $defined[$item_type] as $key => $type_obj ) {
353 if ( in_array( $key, $unfiltered[$item_type] ) )
354 continue;
355
356 $row = "<tr class='cme_type_{$key}'>";
357
358 if ( $cap_type ) {
359 if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) )
360 continue;
361
362 $type_label = (!empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name;
363
364 $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_label . '</a>';
365 $row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
366 $row .= '</td>';
367
368 $display_row = ! empty($force_distinct_ui);
369
370 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
371 $td_classes = array();
372 $checkbox = '';
373 $title = '';
374
375 if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
376 || ! in_array( $type_obj->cap->$prop, $default_caps )
377 || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
378
379 // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
380 if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
381 && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
382 && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
383
384 && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
385 || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop])
386 || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
387 || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
388 || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
389 )
390
391 && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
392 || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop])
393 || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
394 || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
395 || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
396 || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
397 || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
398 || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
399 )
400 ) {
401 // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
402 if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
403 continue;
404 }
405
406 $cap_name = $type_obj->cap->$prop;
407
408 if ( 'taxonomy' == $item_type )
409 $td_classes []= "term-cap";
410 else
411 $td_classes []= "post-cap";
412
413 if ( ! empty($pp_metagroup_caps[$cap_name]) )
414 $td_classes []='cm-has-via-pp';
415
416 if ( $is_administrator || current_user_can($cap_name) ) {
417 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
418 $title = ' title="' . sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ) . '"';
419 } else {
420 $title = ' title="' . $cap_name . '"';
421 }
422
423 $disabled = '';
424 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
425
426 $checkbox = '<input type="checkbox"' . $title . ' name="caps[' . $cap_name . ']" autocomplete="off" value="1" ' . $checked . $disabled . ' />';
427
428 $type_caps [$cap_name] = true;
429 $display_row = true;
430 }
431 } else {
432 //$td_classes []= "cap-unreg";
433 $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
434 }
435
436 if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
437 $td_classes []= "cap-neg";
438 }
439 } else {
440 $td_classes []= "cap-unreg";
441 }
442
443 $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
444
445 $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
446
447 if ( false !== strpos( $td_class, 'cap-neg' ) )
448 $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
449
450 $row .= "</td>";
451 }
452
453 if ('type' == $item_type) {
454 $type_metacaps[$type_obj->cap->read_post] = true;
455 $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts);
456 $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts);
457
458 } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) {
459 $type_metacaps[$type_obj->cap->edit_term] = true;
460 $type_metacaps[$type_obj->cap->delete_term] = true;
461 }
462 }
463
464 if ( $display_row ) {
465 $row .= '</tr>';
466 echo $row;
467 }
468 }
469
470 echo '</table>';
471
472 } // end foreach item type
473
474 echo '</div>';
475
476 echo '</li>';
477 }
478
479
480 do_action('publishpress-caps_manager_postcaps_section', compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps'));
481
482 $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps);
483
484 echo '</ul>';
485
486 // clicking on post type name toggles corresponding checkbox selections
487 ?>
488 <script type="text/javascript">
489 /* <![CDATA[ */
490 jQuery(document).ready( function($) {
491 $('a[href="#toggle_type_caps"]').click( function() {
492 var chks = $(this).closest('tr').find('input');
493 $(chks).prop( 'checked', ! $(chks).first().is(':checked') );
494 return false;
495 });
496
497 $('input[name^="caps["]').click(function() {
498 $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked'));
499 });
500 });
501 /* ]]> */
502 </script>
503 <?php
504
505 echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
506 echo '<table class="form-table cme-checklist"><tr>';
507
508 $checks_per_row = get_option( 'cme_form-rows', 5 );
509 $i = 0; $first_row = true;
510
511 $core_caps = _cme_core_caps();
512 foreach( array_keys($core_caps) as $cap_name ) {
513 if ( ! $is_administrator && ! current_user_can($cap_name) )
514 continue;
515
516 if ( $i == $checks_per_row ) {
517 echo '</tr><tr>';
518 $i = 0;
519 }
520
521 if ( ! isset( $rcaps[$cap_name] ) )
522 $class = 'cap-no';
523 else
524 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
525
526 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
527 $class .= ' cap-metagroup';
528 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
529 } else {
530 $title_text = $cap_name;
531 }
532
533 $disabled = '';
534 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
535 $lock_capability = false;
536 $title = $title_text;
537
538 if ( 'read' == $cap_name ) {
539 if ( ! empty( $block_read_removal ) ) {
540 // prevent the read capability from being removed from a core role, but don't force it to be added
541 if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
542 if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
543 $lock_capability = true;
544 $class .= ' cap-locked';
545 $disabled = 'disabled="disabled"';
546 if ( 'administrator' != $this->current ) {
547 $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
548 }
549 }
550 }
551 }
552 }
553
554 ?>
555 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
556 <span>
557 <?php
558 echo str_replace( '_', ' ', $cap_name );
559 ?>
560 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
561 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
562 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
563 <?php endif; ?>
564 </td>
565
566 <?php
567
568 if ( $lock_capability ) {
569 echo '<input type="hidden" name="caps[' . $cap_name . ']" value="1" />';
570 }
571
572 ++$i;
573 }
574
575 if ( $i == $checks_per_row ) {
576 echo '</tr>';
577 $i = 0;
578 } elseif ( ! $first_row ) {
579 // Now close a wellformed table
580 for ( $i; $i < $checks_per_row; $i++ ){
581 echo '<td>&nbsp;</td>';
582 }
583 echo '</tr>';
584 }
585 ?>
586
587 <tr class="cme-bulk-select">
588 <td colspan="<?php echo $checks_per_row;?>">
589 <span style="float:right">
590 <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
591 </span>
592 </td></tr>
593
594 </table>
595 <?php
596 $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
597 $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
598
599 /*
600 $publishpress_status_change_caps = array();
601 foreach( $all_capabilities as $cap_name ) {
602 if (0 === strpos($cap_name, 'status_change_')) {
603 $publishpress_status_change_caps []= $cap_name;
604 }
605 }
606 */
607
608 $plugin_caps = [];
609
610 if (defined('PUBLISHPRESS_VERSION')) {
611 $plugin_caps['PublishPress'] = apply_filters('cme_publishpress_capabilities',
612 array(
613 'edit_metadata',
614 'edit_post_subscriptions',
615 'ppma_edit_orphan_post',
616 'pp_manage_roles',
617 'pp_set_notification_channel',
618 'pp_view_calendar',
619 'pp_view_content_overview',
620 'status_change',
621 )
622 );
623 }
624
625 if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) {
626 if ($_caps = apply_filters('cme_multiple_authors_capabilities', array())) {
627 $plugin_caps['PublishPress Authors'] = $_caps;
628 }
629 }
630
631 if (defined('PRESSPERMIT_VERSION')) {
632 $plugin_caps['PublishPress Permissions'] = apply_filters('cme_presspermit_capabilities',
633 array(
634 'edit_own_attachments',
635 'list_others_unattached_files',
636 'pp_administer_content',
637 'pp_assign_roles',
638 'pp_associate_any_page',
639 'pp_create_groups',
640 'pp_create_network_groups',
641 'pp_define_moderation',
642 'pp_define_post_status',
643 'pp_define_privacy',
644 'pp_delete_groups',
645 'pp_edit_groups',
646 'pp_exempt_edit_circle',
647 'pp_exempt_read_circle',
648 'pp_force_quick_edit',
649 'pp_list_all_files',
650 'pp_manage_capabilities',
651 'pp_manage_members',
652 'pp_manage_network_members',
653 'pp_manage_settings',
654 'pp_moderate_any',
655 'pp_set_associate_exceptions',
656 'pp_set_edit_exceptions',
657 'pp_set_read_exceptions',
658 'pp_set_revise_exceptions',
659 'pp_set_term_assign_exceptions',
660 'pp_set_term_associate_exceptions',
661 'pp_set_term_manage_exceptions',
662 'pp_unfiltered',
663 'set_posts_status',
664 )
665 );
666 }
667
668 if (defined('WC_PLUGIN_FILE')) {
669 $plugin_caps['WooCommerce'] = apply_filters('cme_woocommerce_capabilities',
670 array(
671 'assign_product_terms',
672 'assign_shop_coupon_terms',
673 'assign_shop_discount_terms',
674 'assign_shop_order_terms',
675 'assign_shop_payment_terms',
676 'create_shop_orders',
677 'delete_others_products',
678 'delete_others_shop_coupons',
679 'delete_others_shop_discounts',
680 'delete_others_shop_orders',
681 'delete_others_shop_payments',
682 'delete_private_products',
683 'delete_private_shop_coupons',
684 'delete_private_shop_orders',
685 'delete_private_shop_discounts',
686 'delete_private_shop_payments',
687 'delete_product_terms',
688 'delete_products',
689 'delete_published_products',
690 'delete_published_shop_coupons',
691 'delete_published_shop_discounts',
692 'delete_published_shop_orders',
693 'delete_published_shop_payments',
694 'delete_shop_coupons',
695 'delete_shop_coupon_terms',
696 'delete_shop_discount_terms',
697 'delete_shop_discounts',
698 'delete_shop_order_terms',
699 'delete_shop_orders',
700 'delete_shop_payments',
701 'delete_shop_payment_terms',
702 'edit_others_products',
703 'edit_others_shop_coupons',
704 'edit_others_shop_discounts',
705 'edit_others_shop_orders',
706 'edit_others_shop_payments',
707 'edit_private_products',
708 'edit_private_shop_coupons',
709 'edit_private_shop_discounts',
710 'edit_private_shop_orders',
711 'edit_private_shop_payments',
712 'edit_product_terms',
713 'edit_products',
714 'edit_published_products',
715 'edit_published_shop_coupons',
716 'edit_published_shop_discounts',
717 'edit_published_shop_orders',
718 'edit_published_shop_payments',
719 'edit_shop_coupon_terms',
720 'edit_shop_coupons',
721 'edit_shop_discounts',
722 'edit_shop_discount_terms',
723 'edit_shop_order_terms',
724 'edit_shop_orders',
725 'edit_shop_payments',
726 'edit_shop_payment_terms',
727 'export_shop_payments',
728 'export_shop_reports',
729 'import_shop_discounts',
730 'import_shop_payments',
731 'manage_product_terms',
732 'manage_shop_coupon_terms',
733 'manage_shop_discounts',
734 'manage_shop_discount_terms',
735 'manage_shop_payment_terms',
736 'manage_shop_order_terms',
737 'manage_shop_settings',
738 'manage_woocommerce',
739 'publish_products',
740 'publish_shop_coupons',
741 'publish_shop_discounts',
742 'publish_shop_orders',
743 'publish_shop_payments',
744 'read_private_products',
745 'read_private_shop_coupons',
746 'read_private_shop_discounts',
747 'read_private_shop_payments',
748 'read_private_shop_orders',
749 'view_admin_dashboard',
750 'view_shop_discount_stats',
751 'view_shop_payment_stats',
752 'view_shop_reports',
753 'view_shop_sensitive_data',
754 'view_woocommerce_reports',
755 )
756 );
757 }
758
759 $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
760
761 foreach($plugin_caps as $plugin => $__plugin_caps) {
762 $_plugin_caps = array_fill_keys($__plugin_caps, true);
763
764 echo '<h3 class="cme-cap-section">' . sprintf(__( '%s Capabilities', 'capsman-enhanced' ), str_replace('_', ' ', $plugin )) . '</h3>';
765 echo '<table class="form-table cme-checklist"><tr>';
766
767 $checks_per_row = get_option( 'cme_form-rows', 5 );
768 $i = 0; $first_row = true;
769
770 foreach( array_keys($_plugin_caps) as $cap_name ) {
771 if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) || isset($type_metacaps[$cap_name]) ) {
772 continue;
773 }
774
775 if ( ! $is_administrator && ! current_user_can($cap_name) )
776 continue;
777
778 if ( $i == $checks_per_row ) {
779 echo '</tr><tr>';
780 $i = 0;
781 }
782
783 if ( ! isset( $rcaps[$cap_name] ) )
784 $class = 'cap-no';
785 else
786 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
787
788 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
789 $class .= ' cap-metagroup';
790 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
791 } else {
792 $title_text = $cap_name;
793 }
794
795 $disabled = '';
796 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
797 $title = $title_text;
798 ?>
799 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
800 <span>
801 <?php
802 echo str_replace( '_', ' ', $cap_name );
803 ?>
804 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
805 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
806 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
807 <?php endif; ?>
808 </td>
809
810 <?php
811 ++$i;
812 }
813
814 if ( $i == $checks_per_row ) {
815 echo '</tr>';
816 $i = 0;
817 } elseif ( ! $first_row ) {
818 // Now close a wellformed table
819 for ( $i; $i < $checks_per_row; $i++ ){
820 echo '<td>&nbsp;</td>';
821 }
822 echo '</tr>';
823 }
824 ?>
825
826 <tr class="cme-bulk-select">
827 <td colspan="<?php echo $checks_per_row;?>">
828 <span style="float:right">
829 <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
830 </span>
831 </td></tr>
832
833 </table>
834 <?php
835 }
836
837 echo '<p>&nbsp;</p><h3 class="cme-cap-section">' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>';
838
839 ?>
840 <table class="form-table cme-checklist">
841 <tr>
842 <?php
843 $i = 0; $first_row = true;
844
845 foreach( $all_capabilities as $cap_name ) {
846 if ( ! isset($this->capabilities[$cap_name]) )
847 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
848 }
849
850 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
851
852 $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities);
853
854 foreach ($additional_caps as $cap_name => $cap) :
855 if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) || isset($type_metacaps[$cap_name]) )
856 continue;
857
858 foreach(array_keys($plugin_caps) as $plugin) {
859 if ( in_array( $cap_name, $plugin_caps[$plugin]) ) {
860 continue 2;
861 }
862 }
863
864 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
865 continue;
866 }
867
868 // Levels are not shown.
869 if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
870 continue;
871 }
872
873 if ( $i == $checks_per_row ) {
874 echo '</tr><tr>';
875 $i = 0; $first_row = false;
876 }
877
878 if ( ! isset( $rcaps[$cap_name] ) )
879 $class = 'cap-no';
880 else
881 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
882
883 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
884 $class .= ' cap-metagroup';
885 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
886 } else {
887 $title_text = $cap_name;
888 }
889
890 $disabled = '';
891 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
892
893 if ( 'manage_capabilities' == $cap_name ) {
894 if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) {
895 continue;
896 } elseif ( 'administrator' == $default ) {
897 $class .= ' cap-locked';
898 $lock_manage_caps_capability = true;
899 $disabled = 'disabled="disabled"';
900 }
901 }
902 ?>
903 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
904 <span>
905 <?php
906 echo str_replace( '_', ' ', $cap );
907 ?>
908 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
909 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
910 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
911 <?php endif; ?>
912 </td>
913 <?php
914 $i++;
915 endforeach;
916
917 if ( ! empty($lock_manage_caps_capability) ) {
918 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
919 }
920
921 if ( $i == $checks_per_row ) {
922 echo '</tr><tr>';
923 $i = 0;
924 } else {
925 if ( ! $first_row ) {
926 // Now close a wellformed table
927 for ( $i; $i < $checks_per_row; $i++ ){
928 echo '<td>&nbsp;</td>';
929 }
930 echo '</tr>';
931 }
932 }
933 ?>
934
935 <tr class="cme-bulk-select">
936 <td colspan="<?php echo $checks_per_row;?>">
937 <span style="float:right">
938 <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
939 </span>
940 </td></tr>
941
942 </table>
943
944 <?php
945 if (array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities)) {
946
947 $_title = esc_attr(__('Meta capabilities are used in code as placeholders for other capabilities. Assiging to a role has no effect.'));
948 echo '<p>&nbsp;</p><h3 class="cme-cap-section" title="' . $_title . '">' . __( 'Invalid Capabilities', 'capsman-enhanced' ) . '</h3>';
949 ?>
950 <table class="form-table cme-checklist">
951 <tr>
952 <?php
953 $i = 0; $first_row = true;
954
955 foreach( $all_capabilities as $cap_name ) {
956 if ( ! isset($this->capabilities[$cap_name]) )
957 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
958 }
959
960 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
961
962 foreach ( $this->capabilities as $cap_name => $cap ) :
963 if ( ! isset( $type_metacaps[$cap_name] ) )
964 continue;
965
966 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
967 continue;
968 }
969
970 if ( $i == $checks_per_row ) {
971 echo '</tr><tr>';
972 $i = 0; $first_row = false;
973 }
974
975 if ( ! isset( $rcaps[$cap_name] ) )
976 $class = 'cap-no';
977 else
978 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
979
980 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
981 $class .= ' cap-metagroup';
982 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
983 } else {
984 $title_text = $cap_name;
985 }
986
987 $disabled = '';
988 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
989 ?>
990 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
991 <span>
992 <?php
993 echo str_replace( '_', ' ', $cap );
994 ?>
995 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
996 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
997 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
998 <?php endif; ?>
999 </td>
1000 <?php
1001 $i++;
1002 endforeach;
1003
1004 if ( ! empty($lock_manage_caps_capability) ) {
1005 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1006 }
1007
1008 if ( $i == $checks_per_row ) {
1009 echo '</tr><tr>';
1010 $i = 0;
1011 } else {
1012 if ( ! $first_row ) {
1013 // Now close a wellformed table
1014 for ( $i; $i < $checks_per_row; $i++ ){
1015 echo '<td>&nbsp;</td>';
1016 }
1017 echo '</tr>';
1018 }
1019 }
1020 ?>
1021
1022 <tr class="cme-bulk-select">
1023 <td colspan="<?php echo $checks_per_row;?>">
1024 <span style="float:right">
1025 <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
1026 </span>
1027 </td></tr>
1028
1029 </table>
1030 <?php
1031 } // endif any invalid caps
1032 ?>
1033
1034 <div>
1035 <?php
1036 $level = ak_caps2level($rcaps);
1037 ?>
1038 <span title="<?php _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');?>">
1039 <?php _e('Role Level:', 'capsman-enhanced');?> <select name="level">
1040 <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
1041 <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo $l; ?>&nbsp;</option>
1042 <?php }
1043 ?>
1044 </select>
1045 </span>
1046
1047 </div>
1048 </dd>
1049 </dl>
1050
1051 <?php
1052 $support_pp_only_roles = ( defined('PRESSPERMIT_ACTIVE') ) ? $pp_ui->pp_only_roles_ui( $default ) : false;
1053 cme_network_role_ui( $default );
1054 ?>
1055
1056 <p class="submit">
1057 <input type="hidden" name="action" value="update" />
1058 <input type="hidden" name="current" value="<?php echo $default; ?>" />
1059 <input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
1060
1061 <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
1062 <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&amp;action=delete&amp;role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
1063 <?php endif; ?>
1064 </p>
1065
1066 </td>
1067 <td class="sidebar">
1068 <dl>
1069 <dt><?php if ( defined('WPLANG') && WPLANG ) _e('Select New Role', 'capsman-enhanced'); else echo('Select Role to View / Edit'); ?></dt>
1070 <dd style="text-align:center;">
1071 <p><select name="role">
1072 <?php
1073 foreach ( $roles as $role => $name ) {
1074 $name = translate_user_role($name);
1075 echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' &nbsp;</option>';
1076 }
1077 ?>
1078 </select><span style="margin-left:20px"><input type="submit" name="LoadRole" value="<?php if ( defined('WPLANG') && WPLANG ) _e('Change', 'capsman-enhanced'); else echo('Load'); ?>" class="button" /></span></p>
1079 </dd>
1080 </dl>
1081
1082 <script type="text/javascript">
1083 /* <![CDATA[ */
1084 jQuery(document).ready( function($) {
1085 $('select[name="role"]').val('<?php echo $default;?>');
1086
1087 $('input.button[name="LoadRole"]').click(function(){
1088 $('#publishpress_caps_form').attr('action', 'admin.php?page=capsman&role=' + $('select[name="role"]').val());
1089 });
1090 });
1091 /* ]]> */
1092 </script>
1093
1094 <?php do_action('publishpress-caps_sidebar_top');?>
1095
1096 <dl>
1097 <dt><?php _e('Create New Role', 'capsman-enhanced'); ?></dt>
1098 <dd style="text-align:center;">
1099 <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
1100 <p><input type="text" name="create-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
1101
1102 <?php if( $support_pp_only_roles ) : ?>
1103 <label for="new_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="new_role_pp_only" id="new_role_pp_only" autocomplete="off" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
1104 <?php endif; ?>
1105
1106 <br />
1107 <input type="submit" name="CreateRole" value="<?php _e('Create', 'capsman-enhanced') ?>" class="button" />
1108 </p>
1109 </dd>
1110 </dl>
1111
1112 <dl>
1113 <dt><?php defined('WPLANG') && WPLANG ? _e('Copy this role to', 'capsman-enhanced') : printf('Copy %s Role', translate_user_role($roles[$default])); ?></dt>
1114 <dd style="text-align:center;">
1115 <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
1116 <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
1117
1118 <?php if( $support_pp_only_roles ) : ?>
1119 <label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" autocomplete="off" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
1120 <?php endif; ?>
1121
1122 <br />
1123 <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" />
1124 </p>
1125 </dd>
1126 </dl>
1127
1128 <dl>
1129 <dt><?php _e('Rename Role', 'capsman-enhanced'); ?></dt>
1130 <dd style="text-align:center;">
1131 <p><input type="text" name="rename-name" class="regular-text" placeholder="<?php _e('New Role Name', 'capsman-enhanced') ?>" />
1132
1133 <br />
1134 <input type="submit" name="RenameRole" value="<?php _e('Rename', 'capsman-enhanced') ?>" class="button" />
1135 </p>
1136 </dd>
1137 </dl>
1138
1139 <dl>
1140 <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
1141 <dd style="text-align:center;">
1142 <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
1143 <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
1144 </dd>
1145 </dl>
1146
1147 <!-- <dl class="cme-backup-tool">
1148 <dt><?php _e('Backup Tool', 'capsman-enhanced'); ?></dt>
1149 <dd style="text-align:center;">
1150 <p><a href="admin.php?page=capsman-tool"><?php _e('Backup / Restore Roles', 'capsman-enhanced');?></a></p>
1151 </dd>
1152 </dl> -->
1153
1154 <dl>
1155 <dt><?php _e('Related Permissions Plugins', 'capsman-enhanced'); ?></dt>
1156 <dd>
1157 <ul>
1158 <li><a href="https://publishpress.com/ma/" target="_blank"><?php _e('Multiple Authors', 'capsman-enhanced');?></a></li>
1159 </li>
1160
1161 <li><a href="#pp-more"><?php _e('PublishPress Permissions', 'capsman-enhanced');?></a>
1162 </li>
1163
1164 <?php $_url = "plugin-install.php?tab=plugin-information&plugin=publishpress&TB_iframe=true&width=640&height=678";
1165 $url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1166 ?>
1167 <li><a class="thickbox" href="<?php echo $url;?>"><?php _e('PublishPress', 'capsman-enhanced');?></a></li>
1168
1169 <?php $_url = "plugin-install.php?tab=plugin-information&plugin=revisionary&TB_iframe=true&width=640&height=678";
1170 $url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1171 ?>
1172 <li><a class="thickbox" href="<?php echo $url;?>"><?php _e('PublishPress Revisions', 'capsman-enhanced');?></a></li>
1173
1174 <li class="publishpress-contact"><a href="https://publishpress.com/contact" target="_blank"><?php _e('Help / Contact Form', 'capsman-enhanced');?></a></li>
1175
1176 </ul>
1177 </dd>
1178 </dl>
1179
1180 <?php
1181 $pp_ui->pp_types_ui( $defined['type'] );
1182 $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
1183
1184 do_action('publishpress-caps_sidebar_bottom');
1185 ?>
1186 </td>
1187 </tr>
1188 </table>
1189 </fieldset>
1190 </form>
1191
1192 <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
1193 cme_publishpressFooter();
1194 }
1195 ?>
1196 </div>
1197
1198 <?php
1199 function cme_network_role_ui( $default ) {
1200 if (!is_multisite() || !is_super_admin() || !is_main_site()) {
1201 return false;
1202 }
1203 ?>
1204
1205 <div style="float:right;margin-left:10px;margin-right:10px">
1206 <?php
1207 if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
1208 $autocreate_roles = array();
1209
1210 $checked = ( in_array( $default, $autocreate_roles ) ) ? 'checked="checked"': '';
1211 ?>
1212 <div style="margin-bottom: 5px">
1213 <label for="cme_autocreate_role" title="<?php _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;?>> <?php _e('include in new sites', 'capsman-enhanced'); ?> </label>
1214 </div>
1215 <div>
1216 <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 _e('sync role to all sites now', 'capsman-enhanced'); ?> </label>
1217 </div>
1218 </div>
1219 <?php
1220 return true;
1221 }
1222
1223 function cme_plugin_info_url( $plugin_slug ) {
1224 $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
1225 return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1226 }
1227