admin-notices
2 months ago
features
2 weeks ago
plugin-capabilities
2 months ago
redirects
2 months ago
roles
1 month ago
admin-load.php
1 month ago
admin.php
2 weeks ago
application-passwords.php
2 weeks ago
backup-handler.php
2 weeks ago
backup.php
1 month ago
cap-helper.php
6 months ago
dashboard.php
2 months ago
extractor-capabilities.php
6 months ago
filters-admin.php
6 months ago
filters-woocommerce.php
6 months ago
filters-wp_rest_workarounds.php
6 months ago
filters.php
5 months ago
functions-admin.php
2 weeks ago
functions.php
2 weeks ago
handler.php
2 weeks ago
inflect-cme.php
6 months ago
manager.php
2 weeks ago
network.php
6 months ago
plugin-capabilities.php
2 months ago
pp-handler.php
6 months ago
pp-ui.php
3 months ago
publishpress-roles.php
6 months ago
settings-handler.php
6 months ago
settings-ui.php
2 weeks ago
settings.php
6 months ago
test-user-ui.php
1 month ago
test-user.php
5 months ago
admin.php
2244 lines
| 1 | <?php |
| 2 | /** |
| 3 | * PublishPress Capabilities [Free] |
| 4 | * |
| 5 | * UI output for Capabilities screen. |
| 6 | * |
| 7 | * Provides admin pages to create and manage roles and capabilities. |
| 8 | * |
| 9 | * @author Jordi Canals, Kevin Behrens |
| 10 | * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2020 PublishPress |
| 11 | * @license GNU General Public License version 2 |
| 12 | * @link https://publishpress.com |
| 13 | * |
| 14 | * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat> |
| 15 | * Modifications Copyright 2020, PublishPress <help@publishpress.com> |
| 16 | * |
| 17 | * This program is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU General Public License |
| 19 | * version 2 as published by the Free Software Foundation. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 | **/ |
| 29 | |
| 30 | global $capsman, $cme_cap_helper, $current_user, $sidebar_metabox_state; |
| 31 | |
| 32 | do_action('publishpress-caps_manager-load'); |
| 33 | |
| 34 | $sidebar_metabox_state = get_user_meta($current_user->ID, 'ppc_sidebar_metabox_state', true); |
| 35 | if ($sidebar_metabox_state == '' || !is_array($sidebar_metabox_state)) { |
| 36 | $sidebar_metabox_state = []; |
| 37 | $sidebar_metabox_state['how_to_user_capabilities'] = 'opened'; |
| 38 | } |
| 39 | |
| 40 | if (!isset($sidebar_metabox_state['multi_site'])) { |
| 41 | $sidebar_metabox_state['multi_site'] = 'opened'; |
| 42 | } |
| 43 | $roles = $this->roles; |
| 44 | $default = $this->current; |
| 45 | $application_password_subjects = function_exists('pp_capabilities_get_application_password_subjects') |
| 46 | ? pp_capabilities_get_application_password_subjects() |
| 47 | : []; |
| 48 | $is_application_password = function_exists('pp_capabilities_is_application_password_subject') |
| 49 | && pp_capabilities_is_application_password_subject($default) |
| 50 | && isset($application_password_subjects[$default]); |
| 51 | $application_password_denied_caps = $is_application_password && function_exists('pp_capabilities_get_application_password_denied_capabilities') |
| 52 | ? pp_capabilities_get_application_password_denied_capabilities($default) |
| 53 | : []; |
| 54 | $rcaps = []; |
| 55 | $set_application_password_cap = function ($cap_name) use ($is_application_password, $application_password_denied_caps, &$rcaps) { |
| 56 | if (!$is_application_password || !is_scalar($cap_name)) { |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | $cap_name = sanitize_text_field((string) $cap_name); |
| 61 | |
| 62 | if ('' === $cap_name) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | $rcaps[$cap_name] = empty($application_password_denied_caps[$cap_name]); |
| 67 | }; |
| 68 | |
| 69 | if ( !$is_application_password && ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) ) { |
| 70 | if ( $current = get_role($default) ) { |
| 71 | if ( empty( $current->capabilities['read'] ) ) { |
| 72 | ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capability-manager-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) ); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // include extractor plugin capabilites |
| 78 | require_once (dirname(CME_FILE) . '/includes/extractor-capabilities.php'); |
| 79 | |
| 80 | require_once (dirname(CME_FILE) . '/includes/roles/roles-functions.php'); |
| 81 | |
| 82 | require_once( dirname(__FILE__).'/pp-ui.php' ); |
| 83 | $pp_ui = new Capsman_PP_UI(); |
| 84 | |
| 85 | if( defined('PRESSPERMIT_ACTIVE') && !$is_application_password ) { |
| 86 | $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default ); |
| 87 | } else { |
| 88 | $pp_metagroup_caps = array(); |
| 89 | } |
| 90 | |
| 91 | if (defined('PUBLISHPRESS_REVISIONS_VERSION') && function_exists('rvy_get_option')) { |
| 92 | $pp_revisions_copy = rvy_get_option("copy_posts_capability"); |
| 93 | $pp_revisions_revise = rvy_get_option("revise_posts_capability"); |
| 94 | |
| 95 | if (version_compare(PUBLISHPRESS_REVISIONS_VERSION, '3.7.15-beta3', '>=')) { |
| 96 | $pp_revisions_approve = true; |
| 97 | } else { |
| 98 | $pp_revisions_approve = false; |
| 99 | } |
| 100 | } else { |
| 101 | $pp_revisions_copy = false; |
| 102 | $pp_revisions_revise = false; |
| 103 | $pp_revisions_approve = false; |
| 104 | } |
| 105 | |
| 106 | ?> |
| 107 | <div class="wrap publishpress-caps-manage pressshack-admin-wrapper"> |
| 108 | <div id="icon-capsman-admin" class="icon32"></div> |
| 109 | |
| 110 | <h1><?php esc_html_e('Role Capabilities', 'capability-manager-enhanced') ?></h1> |
| 111 | |
| 112 | <?php |
| 113 | pp_capabilities_roles()->notify->display(); |
| 114 | ?> |
| 115 | |
| 116 | <script type="text/javascript"> |
| 117 | /* <![CDATA[ */ |
| 118 | jQuery(document).ready( function($) { |
| 119 | $('#publishpress_caps_form').attr('action', 'admin.php?page=pp-capabilities&role=' + $('select[name="role"]').val()); |
| 120 | |
| 121 | $('select[name="role"]').change(function(){ |
| 122 | window.location = '<?php echo esc_url_raw(admin_url('admin.php?page=pp-capabilities&role=')); ?>' + $(this).val() + ''; |
| 123 | }); |
| 124 | }); |
| 125 | /* ]]> */ |
| 126 | </script> |
| 127 | |
| 128 | <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo esc_attr($this->ID);?>"> |
| 129 | <?php wp_nonce_field('capsman-general-manager'); ?> |
| 130 | |
| 131 | <?php |
| 132 | if (empty($_REQUEST['pp_caps_tab']) && !empty($_REQUEST['added'])) { |
| 133 | $pp_tab = 'additional'; |
| 134 | } else { |
| 135 | $pp_tab = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit'; |
| 136 | } |
| 137 | ?> |
| 138 | |
| 139 | <input type="hidden" name="pp_caps_tab" value="<?php echo esc_attr($pp_tab);?>" /> |
| 140 | |
| 141 | <fieldset> |
| 142 | <table id="akmin" class="clear"><tr><td> |
| 143 | <div class="pp-columns-wrapper pp-enable-sidebar"> |
| 144 | <div class="pp-column-left"> |
| 145 | <div style="margin-bottom: 20px;"> |
| 146 | <div class="pp-capabilities-submit-top" style="float:right"> |
| 147 | <div class="capabilities-top-action"> |
| 148 | <div class="pp-capabilities-global-search"> |
| 149 | <input type="text" id="pp-global-capability-search" |
| 150 | class="regular-text" |
| 151 | placeholder="<?php esc_attr_e('Search capabilities...', 'capability-manager-enhanced'); ?>" /> |
| 152 | <div id="pp-search-results-summary" style="font-size: 12px; color: #666;"></div> |
| 153 | </div> |
| 154 | <div> |
| 155 | <?php |
| 156 | $caption = (in_array(sanitize_key(get_locale()), ['en_EN', 'en_US'])) ? 'Save Capabilities' : __('Save Changes'); |
| 157 | ?> |
| 158 | <input type="submit" name="SaveRole" value="<?php echo esc_attr($caption);?>" class="button-primary" /> |
| 159 | </div> |
| 160 | </div> |
| 161 | </div> |
| 162 | <div class="clear"></div> |
| 163 | |
| 164 | <select name="role"> |
| 165 | <?php if (!empty($application_password_subjects)) : ?> |
| 166 | <optgroup label="<?php esc_attr_e('Application Passwords', 'capability-manager-enhanced'); ?>"> |
| 167 | <?php foreach ($application_password_subjects as $subject => $application_password) : ?> |
| 168 | <option value="<?php echo esc_attr($subject); ?>" <?php selected($default, $subject); ?>> |
| 169 | <?php echo esc_html($application_password['label']); ?> |
| 170 | </option> |
| 171 | <?php endforeach; ?> |
| 172 | </optgroup> |
| 173 | <?php endif; ?> |
| 174 | <?php if (function_exists('pp_capabilities_application_password_capabilities_enabled') && pp_capabilities_application_password_capabilities_enabled()) : ?> |
| 175 | <optgroup label="<?php esc_attr_e('Roles', 'capability-manager-enhanced'); ?>"> |
| 176 | <?php endif; ?> |
| 177 | <?php |
| 178 | foreach ( $roles as $role_name => $name ) { |
| 179 | $role_name = sanitize_key($role_name); |
| 180 | |
| 181 | if (pp_capabilities_is_editable_role($role_name)) { |
| 182 | $name = translate_user_role($name); |
| 183 | echo '<option value="' . esc_attr($role_name) .'"'; selected($default, $role_name); echo '> ' . esc_html($name) . ' </option>'; |
| 184 | } |
| 185 | } |
| 186 | ?> |
| 187 | <?php if (function_exists('pp_capabilities_application_password_capabilities_enabled') && pp_capabilities_application_password_capabilities_enabled()) : ?> |
| 188 | </optgroup> |
| 189 | <?php endif; ?> |
| 190 | </select> |
| 191 | </div> |
| 192 | <?php |
| 193 | $img_url = $capsman->mod_url . '/images/'; |
| 194 | ?> |
| 195 | |
| 196 | <?php |
| 197 | if ( defined( 'PRESSPERMIT_ACTIVE' ) && !$is_application_password ) { |
| 198 | $pp_ui->show_capability_hints( $default ); |
| 199 | } |
| 200 | |
| 201 | if ( defined( 'MULTISITE' ) && MULTISITE ) { |
| 202 | global $wp_roles; |
| 203 | global $wpdb; |
| 204 | |
| 205 | if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) { |
| 206 | $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1; |
| 207 | switch_to_blog($main_site_id); |
| 208 | wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' ); |
| 209 | restore_current_blog(); |
| 210 | } |
| 211 | |
| 212 | ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit(); |
| 213 | } |
| 214 | $capsman->reinstate_db_roles(); |
| 215 | |
| 216 | if ($is_application_password) { |
| 217 | $rcaps = function_exists('pp_capabilities_get_application_password_ui_capabilities') |
| 218 | ? pp_capabilities_get_application_password_ui_capabilities($default, array_keys($this->capabilities)) |
| 219 | : []; |
| 220 | $current = (object) [ |
| 221 | 'name' => isset($application_password_subjects[$default]['label']) ? $application_password_subjects[$default]['label'] : $default, |
| 222 | 'capabilities' => $rcaps, |
| 223 | ]; |
| 224 | } else { |
| 225 | $current = get_role($default); |
| 226 | $rcaps = $current->capabilities; |
| 227 | } |
| 228 | |
| 229 | $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin()); |
| 230 | |
| 231 | $custom_types = get_post_types( array( '_builtin' => false ), 'names' ); |
| 232 | $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' ); |
| 233 | |
| 234 | $defined = []; |
| 235 | |
| 236 | // Get public post types |
| 237 | $post_types = get_post_types(['public' => true, 'show_ui' => true], 'object', 'or'); |
| 238 | |
| 239 | // Include private post types if setting is enabled |
| 240 | if (get_option('cme_capabilities_show_private_post_types', 0)) { |
| 241 | $private_types = get_post_types(['public' => false, 'show_ui' => true], 'object', 'or'); |
| 242 | $post_types = array_merge($post_types, $private_types); |
| 243 | } |
| 244 | |
| 245 | $defined['type'] = apply_filters('cme_filterable_post_types', $post_types); |
| 246 | |
| 247 | if (in_array(get_locale(), ['en_EN', 'en_US'])) { |
| 248 | $defined['type']['wp_navigation']->label = __('Nav Menus (Block)', 'capability-manager-enhanced'); |
| 249 | } else { |
| 250 | $defined['type']['wp_navigation']->label .= ' (' . __('Block', 'capability-manager-enhanced') . ')'; |
| 251 | } |
| 252 | |
| 253 | $defined['taxonomy'] = apply_filters('cme_filterable_taxonomies', get_taxonomies(['public' => true, 'show_ui' => true], 'object', 'or')); |
| 254 | $defined['taxonomy']['nav_menu'] = get_taxonomy('nav_menu'); |
| 255 | |
| 256 | if (in_array(get_locale(), ['en_EN', 'en_US'])) { |
| 257 | $defined['taxonomy']['nav_menu']->label = __('Nav Menus (Legacy)', 'capability-manager-enhanced'); |
| 258 | } else { |
| 259 | $defined['taxonomy']['nav_menu']->label .= ' (' . __('Legacy', 'capability-manager-enhanced') . ')'; |
| 260 | } |
| 261 | |
| 262 | // bbPress' dynamic role def requires additional code to enforce stored caps |
| 263 | $unfiltered['type'] = apply_filters('presspermit_unfiltered_post_types', ['forum','topic','reply', 'customize_changeset']); |
| 264 | $unfiltered['type'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['type'] : apply_filters('pp_unfiltered_post_types', $unfiltered['type']); |
| 265 | |
| 266 | $unfiltered['taxonomy'] = apply_filters('presspermit_unfiltered_post_types', ['post_status', 'topic-tag']); // avoid confusion with Edit Flow administrative taxonomy |
| 267 | $unfiltered['taxonomy'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['taxonomy'] : apply_filters('pp_unfiltered_taxonomies', $unfiltered['taxonomy']); |
| 268 | |
| 269 | $enabled_taxonomies = cme_get_assisted_taxonomies(); |
| 270 | |
| 271 | $cap_properties['edit']['type'] = array( 'edit_posts' ); |
| 272 | |
| 273 | foreach( $defined['type'] as $type_obj ) { |
| 274 | if ( 'attachment' != $type_obj->name ) { |
| 275 | if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) { |
| 276 | $cap_properties['edit']['type'][]= 'create_posts'; |
| 277 | break; |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | $cap_properties['edit']['type'][]= 'edit_others_posts'; |
| 283 | $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) ); |
| 284 | |
| 285 | $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' ); |
| 286 | $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) ); |
| 287 | |
| 288 | if (defined('PRESSPERMIT_VERSION') && defined('PRESSPERMIT_COLLAB_VERSION')) { |
| 289 | $cap_properties['list']['type'] = ['list_posts', 'list_others_posts', 'list_published_posts', 'list_private_posts']; |
| 290 | } |
| 291 | |
| 292 | if ($pp_revisions_copy) { |
| 293 | $cap_properties['copy']['type'] = ['copy_posts', 'copy_others_posts', 'copy_published_posts', 'copy_private_posts']; |
| 294 | } |
| 295 | |
| 296 | if ($pp_revisions_revise) { |
| 297 | $cap_properties['revise']['type'] = ['revise_posts', 'revise_others_posts', 'revise_published_posts', 'revise_private_posts']; |
| 298 | } |
| 299 | |
| 300 | if ($pp_revisions_approve) { |
| 301 | $cap_properties['approve']['type'] = ['approve_posts', 'approve_others_posts']; |
| 302 | } |
| 303 | |
| 304 | $cap_properties['read']['type'] = array( 'read_private_posts' ); |
| 305 | |
| 306 | $cap_properties['taxonomies']['taxonomy'] = array( 'manage_terms', 'edit_terms', 'assign_terms', 'delete_terms' ); |
| 307 | |
| 308 | $stati = get_post_stati( array( 'internal' => false ) ); |
| 309 | |
| 310 | $cap_type_names = array( |
| 311 | '' => __( ' ', 'capability-manager-enhanced' ), |
| 312 | 'read' => __( 'Visibility', 'capability-manager-enhanced' ), |
| 313 | 'edit' => __( 'Editing', 'capability-manager-enhanced' ), |
| 314 | 'delete' => __( 'Deletion', 'capability-manager-enhanced' ), |
| 315 | 'taxonomies' => __( 'Taxonomies', 'capability-manager-enhanced' ), |
| 316 | ); |
| 317 | |
| 318 | if (defined('PRESSPERMIT_VERSION') && defined('PRESSPERMIT_COLLAB_VERSION')) { |
| 319 | $cap_type_names['list'] = __('Listing', 'capability-manager-enhanced'); |
| 320 | } |
| 321 | |
| 322 | if ($pp_revisions_copy) { |
| 323 | $cap_type_names['copy'] = __('Create Revision', 'capability-manager-enhanced'); |
| 324 | } |
| 325 | |
| 326 | if ($pp_revisions_revise) { |
| 327 | $cap_type_names['revise'] = __('Submit Revision', 'capability-manager-enhanced'); |
| 328 | } |
| 329 | |
| 330 | if ($pp_revisions_approve) { |
| 331 | $cap_type_names['approve'] = __('Approve Revision', 'capability-manager-enhanced'); |
| 332 | } |
| 333 | |
| 334 | $cap_tips = array( |
| 335 | 'read_private' => esc_attr__( 'Can read posts which are currently published with private visibility.', 'capability-manager-enhanced' ), |
| 336 | 'edit' => esc_attr__( 'Has basic editing capability (but may need other capabilities based on post status and ownership).', 'capability-manager-enhanced' ), |
| 337 | 'edit_others' => esc_attr__( 'Can edit posts which were created by other users.', 'capability-manager-enhanced' ), |
| 338 | 'edit_published' => esc_attr__( 'Can edit posts which are currently published.', 'capability-manager-enhanced' ), |
| 339 | 'edit_private' => esc_attr__( 'Can edit posts which are currently published with private visibility.', 'capability-manager-enhanced' ), |
| 340 | 'publish' => esc_attr__( 'Can make a post publicly visible.', 'capability-manager-enhanced' ), |
| 341 | 'delete' => esc_attr__( 'Has basic deletion capability (but may need other capabilities based on post status and ownership).', 'capability-manager-enhanced' ), |
| 342 | 'delete_others' => esc_attr__( 'Can delete posts which were created by other users.', 'capability-manager-enhanced' ), |
| 343 | 'delete_published' => esc_attr__( 'Can delete posts which are currently published.', 'capability-manager-enhanced' ), |
| 344 | 'delete_private' => esc_attr__( 'Can delete posts which are currently published with private visibility.', 'capability-manager-enhanced' ), |
| 345 | ); |
| 346 | |
| 347 | $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', |
| 348 | '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', |
| 349 | 'manage_categories' |
| 350 | ); |
| 351 | |
| 352 | if (defined('PRESSPERMIT_PRO_FILE') && defined('PRESSPERMIT_COLLAB_VERSION')) { |
| 353 | $default_caps = array_merge($default_caps, ['list_posts', 'list_others_posts', 'list_published_posts', 'list_private_posts', 'list_pages', 'list_others_pages', 'list_published_pages', 'list_private_pages']); |
| 354 | } |
| 355 | |
| 356 | if ($pp_revisions_copy) { |
| 357 | $default_caps = array_merge($default_caps, ['copy_posts', 'copy_others_posts', 'copy_pages', 'copy_others_pages']); |
| 358 | } |
| 359 | |
| 360 | if ($pp_revisions_revise) { |
| 361 | $default_caps = array_merge($default_caps, ['revise_posts', 'revise_others_posts', 'revise_pages', 'revise_others_pages']); |
| 362 | } |
| 363 | |
| 364 | $type_caps = array(); |
| 365 | $type_metacaps = array(); |
| 366 | |
| 367 | // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post |
| 368 | if ( defined('OLD_PRESSPERMIT_ACTIVE') ) { |
| 369 | unset( $defined['type']['attachment'] ); |
| 370 | } |
| 371 | ?> |
| 372 | |
| 373 | <script type="text/javascript"> |
| 374 | /* <![CDATA[ */ |
| 375 | jQuery(document).ready( function($) { |
| 376 | if ($('.ppc-capabilities-tabs li.ppc-capabilities-tab-active').hasClass('ppc-full-width')) { |
| 377 | $('.capabilities-sidebar').hide(); |
| 378 | $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr'); |
| 379 | } |
| 380 | |
| 381 | // Tabs and Content display |
| 382 | $(document).on('click', '.ppc-capabilities-tabs > ul > li', function() { |
| 383 | var $pp_tab = $(this).attr('data-content'); |
| 384 | var data_slug = $(this).attr('data-slug'); |
| 385 | |
| 386 | $("[name='pp_caps_tab']").val(data_slug); |
| 387 | |
| 388 | // Show current Content |
| 389 | $('.ppc-capabilities-content > div').not('.capabilities-sidebar').hide(); |
| 390 | $('#' + $pp_tab).show(); |
| 391 | |
| 392 | var post_ops = ['read', 'edit', 'delete', 'list']; |
| 393 | $('.capabilities-sidebar .ppc-post-types').toggle(post_ops.indexOf(data_slug,) != -1); |
| 394 | |
| 395 | $('.capabilities-sidebar .ppc-taxonomies').toggle(data_slug == 'taxonomies'); |
| 396 | $('.capabilities-sidebar .ppc-detailed-taxonomies').toggle(data_slug == 'taxonomies'); |
| 397 | |
| 398 | if ($(this).hasClass('ppc-full-width')) { |
| 399 | $('.capabilities-sidebar').hide(); |
| 400 | $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr'); |
| 401 | } else { |
| 402 | $('.capabilities-sidebar').show(); |
| 403 | |
| 404 | if ($(window).width() > 1199) { |
| 405 | $('#ppc-capabilities-wrapper .ppc-capabilities-content').css('grid-template-columns', '1fr 200px 70px'); |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | $('#' + $pp_tab + '-taxonomy').show(); |
| 410 | |
| 411 | // Active current Tab |
| 412 | $('.ppc-capabilities-tabs > ul > li').removeClass('ppc-capabilities-tab-active'); |
| 413 | $(this).addClass('ppc-capabilities-tab-active'); |
| 414 | |
| 415 | // Add search functionality |
| 416 | var searchTerm = $('#pp-global-capability-search').val().trim(); |
| 417 | if (searchTerm.length >= 2) { |
| 418 | // Handle special case for taxonomies tab |
| 419 | var filterInputId = (data_slug === 'taxonomies') ? |
| 420 | 'cme-cap-type-tables-' + data_slug + '-taxonomy .ppc-filter-text' : |
| 421 | 'cme-cap-type-tables-' + data_slug + ' .ppc-filter-text'; |
| 422 | var $filterInput = $(filterInputId); |
| 423 | if ($filterInput.length > 0) { |
| 424 | $filterInput.val(searchTerm).trigger('input'); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | // Scroll to content area (for responsive display) |
| 429 | if ($(window).width() <= 1199) { |
| 430 | $([document.documentElement, document.body]).animate({ |
| 431 | scrollTop: $("#capabilities_content").offset().top - 20 |
| 432 | }, 500); |
| 433 | } |
| 434 | }); |
| 435 | |
| 436 | // Tab capabilities counting |
| 437 | function updateTabCounts() { |
| 438 | $('.ppc-capabilities-tabs > ul > li').each(function() { |
| 439 | var $tab = $(this); |
| 440 | var tabSlug = $tab.data('slug'); |
| 441 | var $content = $('#' + $tab.data('content')); |
| 442 | |
| 443 | // Count checked checkboxes in this tab's content |
| 444 | var checkedCount = $content.find('input[type="checkbox"]:checked').length; |
| 445 | |
| 446 | // Remove existing count and title wrapper if present |
| 447 | $tab.find('.pp-capabilities-count-indicator').remove(); |
| 448 | $tab.find('.tab-title').contents().unwrap(); |
| 449 | |
| 450 | // Wrap existing text in title span |
| 451 | $tab.contents().filter(function() { |
| 452 | return this.nodeType === 3 && this.textContent.trim() !== ''; |
| 453 | }).wrap('<span class="tab-title"></span>'); |
| 454 | |
| 455 | // Add count if > 0 |
| 456 | if (checkedCount > 0) { |
| 457 | $tab.append(' <span class="pp-capabilities-count-container"><span class="pp-capabilities-count-indicator">' + checkedCount + '</span></span>'); |
| 458 | } else { |
| 459 | $tab.append(' <span class="pp-capabilities-count-container"></span>'); |
| 460 | } |
| 461 | }); |
| 462 | } |
| 463 | |
| 464 | // Initialize tab capabilities counting |
| 465 | updateTabCounts(); |
| 466 | }); |
| 467 | /* ]]> */ |
| 468 | </script> |
| 469 | |
| 470 | <div id="ppc-capabilities-wrapper" class="postbox"> |
| 471 | <div class="ppc-capabilities-tabs"> |
| 472 | <ul style="min-width: 220px;"> |
| 473 | <?php |
| 474 | $full_width_tabs = apply_filters('pp_capabilities_full_width_tabs', []); |
| 475 | |
| 476 | if (empty($_REQUEST['pp_caps_tab']) && !empty($_REQUEST['added'])) { |
| 477 | $active_tab_slug = 'additional'; |
| 478 | } else { |
| 479 | $active_tab_slug = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit'; |
| 480 | } |
| 481 | |
| 482 | $active_tab_id = "cme-cap-type-tables-{$active_tab_slug}"; |
| 483 | |
| 484 | $ppc_tab_active = 'ppc-capabilities-tab-active'; |
| 485 | |
| 486 | // caps: edit, delete, read |
| 487 | foreach( array_keys($cap_properties) as $cap_type ) { |
| 488 | $tab_id = "cme-cap-type-tables-$cap_type"; |
| 489 | $classes = []; |
| 490 | |
| 491 | if ($tab_id == $active_tab_id) { |
| 492 | $classes []= $ppc_tab_active; |
| 493 | } |
| 494 | |
| 495 | if (!empty($full_width_tabs[$cap_type])) { |
| 496 | $classes []= 'ppc-full-width'; |
| 497 | } |
| 498 | |
| 499 | $class = implode(' ', $classes); |
| 500 | |
| 501 | echo '<li data-slug="'. esc_attr($cap_type) . '"' . ' data-content="cme-cap-type-tables-' . esc_attr($cap_type) . '" class="' . esc_attr($class) . '">' |
| 502 | . esc_html($cap_type_names[$cap_type]) . |
| 503 | '</li>'; |
| 504 | } |
| 505 | |
| 506 | if ($extra_tabs = apply_filters('pp_capabilities_extra_post_capability_tabs', [])) { |
| 507 | foreach($extra_tabs as $tab_slug => $tab_caption) { |
| 508 | $tab_slug = esc_attr($tab_slug); |
| 509 | |
| 510 | $tab_id = "cme-cap-type-tables-{$tab_slug}"; |
| 511 | |
| 512 | $classes = []; |
| 513 | |
| 514 | if ($tab_id == $active_tab_id) { |
| 515 | $classes []= $ppc_tab_active; |
| 516 | } |
| 517 | |
| 518 | if (!empty($full_width_tabs[$tab_slug])) { |
| 519 | $classes []= 'ppc-full-width'; |
| 520 | } |
| 521 | |
| 522 | $class = implode(' ', $classes); |
| 523 | |
| 524 | echo '<li data-slug="' . esc_attr($tab_slug) . '"' . ' data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($class) . '">' |
| 525 | . esc_html($tab_caption) . |
| 526 | '</li>'; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | //grouped capabilities |
| 531 | $grouped_caps = []; |
| 532 | $grouped_caps_lists = []; |
| 533 | |
| 534 | //add media related caps |
| 535 | $grouped_caps['Media'] = [ |
| 536 | 'edit_files', |
| 537 | 'upload_files', |
| 538 | 'unfiltered_upload', |
| 539 | ]; |
| 540 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Media']); |
| 541 | |
| 542 | //add comments related caps |
| 543 | $grouped_caps['Comments'] = [ |
| 544 | 'moderate_comments' |
| 545 | ]; |
| 546 | if (isset($rcaps['edit_comment'])) { |
| 547 | $type_metacaps['edit_comment'] = 1; |
| 548 | } |
| 549 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Comments']); |
| 550 | |
| 551 | //add users related caps |
| 552 | $grouped_caps['Users'] = [ |
| 553 | 'create_users', |
| 554 | 'delete_users', |
| 555 | 'edit_users', |
| 556 | 'list_users', |
| 557 | 'promote_users', |
| 558 | 'remove_users', |
| 559 | ]; |
| 560 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Users']); |
| 561 | |
| 562 | //add admin options related caps |
| 563 | $grouped_caps['Admin'] = [ |
| 564 | 'manage_options', |
| 565 | 'edit_dashboard', |
| 566 | 'export', |
| 567 | 'import', |
| 568 | 'read', |
| 569 | 'update_core', |
| 570 | 'unfiltered_html', |
| 571 | ]; |
| 572 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Admin']); |
| 573 | |
| 574 | //add themes related caps |
| 575 | $grouped_caps['Themes'] = [ |
| 576 | 'delete_themes', |
| 577 | 'edit_themes', |
| 578 | 'install_themes', |
| 579 | 'switch_themes', |
| 580 | 'update_themes', |
| 581 | 'edit_theme_options', |
| 582 | 'manage_links', |
| 583 | ]; |
| 584 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Themes']); |
| 585 | |
| 586 | //add plugin related caps |
| 587 | $grouped_caps['Plugins'] = [ |
| 588 | 'activate_plugins', |
| 589 | 'delete_plugins', |
| 590 | 'edit_plugins', |
| 591 | 'install_plugins', |
| 592 | 'update_plugins', |
| 593 | ]; |
| 594 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Plugins']); |
| 595 | |
| 596 | if (is_multisite()) { |
| 597 | //add multisite caps |
| 598 | $grouped_caps['Multisite'] = [ |
| 599 | 'create_sites', |
| 600 | 'delete_sites', |
| 601 | 'manage_network', |
| 602 | 'manage_sites', |
| 603 | 'manage_network_users', |
| 604 | 'manage_network_plugins', |
| 605 | 'manage_network_themes', |
| 606 | 'manage_network_options', |
| 607 | 'upgrade_network', |
| 608 | 'setup_network', |
| 609 | ]; |
| 610 | $grouped_caps_lists = array_merge($grouped_caps_lists, $grouped_caps['Multisite']); |
| 611 | } |
| 612 | |
| 613 | $grouped_caps = apply_filters('cme_grouped_capabilities', $grouped_caps); |
| 614 | |
| 615 | foreach($grouped_caps as $grouped_title => $__grouped_caps) { |
| 616 | $tab_slug = pp_capabilities_convert_to_slug(sanitize_title($grouped_title)); |
| 617 | switch ($grouped_title) { |
| 618 | case 'Comments' : |
| 619 | $grouped_title = __('Comments'); |
| 620 | break; |
| 621 | |
| 622 | case 'Media' : |
| 623 | $grouped_title = __('Media'); |
| 624 | break; |
| 625 | |
| 626 | case 'Users' : |
| 627 | $grouped_title = __('Users'); |
| 628 | break; |
| 629 | |
| 630 | case 'Themes' : |
| 631 | $grouped_title = __('Themes'); |
| 632 | break; |
| 633 | |
| 634 | case 'Plugins' : |
| 635 | $grouped_title = __('Plugins'); |
| 636 | break; |
| 637 | |
| 638 | case 'Multisite' : |
| 639 | $grouped_title = esc_html__('Multisite', 'capability-manager-enhanced'); |
| 640 | break; |
| 641 | |
| 642 | case 'Admin' : |
| 643 | $grouped_title = esc_html__('Admin', 'capability-manager-enhanced'); |
| 644 | break; |
| 645 | |
| 646 | default: |
| 647 | $grouped_title = esc_html($grouped_title); |
| 648 | } |
| 649 | |
| 650 | $tab_id = 'cme-cap-type-tables-' . $tab_slug; |
| 651 | $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : ''; |
| 652 | |
| 653 | echo '<li data-slug="' . esc_attr($tab_slug) . '" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">' |
| 654 | . esc_html(str_replace('_', ' ', $grouped_title)) . |
| 655 | '</li>'; |
| 656 | } |
| 657 | |
| 658 | $sort_publishpress_plugin_caps = static function ($plugin_caps) { |
| 659 | if (!is_array($plugin_caps) || empty($plugin_caps)) { |
| 660 | return $plugin_caps; |
| 661 | } |
| 662 | |
| 663 | $publishpress_capabilities_key = null; |
| 664 | |
| 665 | foreach (array_keys($plugin_caps) as $plugin_title_key) { |
| 666 | if (0 === strcasecmp(trim((string) $plugin_title_key), 'PublishPress Capabilities')) { |
| 667 | $publishpress_capabilities_key = $plugin_title_key; |
| 668 | break; |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | if (null === $publishpress_capabilities_key) { |
| 673 | return $plugin_caps; |
| 674 | } |
| 675 | |
| 676 | $sorted_plugin_caps = [ |
| 677 | $publishpress_capabilities_key => $plugin_caps[$publishpress_capabilities_key], |
| 678 | ]; |
| 679 | |
| 680 | foreach ($plugin_caps as $plugin_title_key => $plugin_cap_values) { |
| 681 | if ($plugin_title_key === $publishpress_capabilities_key) { |
| 682 | continue; |
| 683 | } |
| 684 | |
| 685 | if (0 === stripos((string) $plugin_title_key, 'PublishPress')) { |
| 686 | $sorted_plugin_caps[$plugin_title_key] = $plugin_cap_values; |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | foreach ($plugin_caps as $plugin_title_key => $plugin_cap_values) { |
| 691 | if (array_key_exists($plugin_title_key, $sorted_plugin_caps)) { |
| 692 | continue; |
| 693 | } |
| 694 | |
| 695 | $sorted_plugin_caps[$plugin_title_key] = $plugin_cap_values; |
| 696 | } |
| 697 | |
| 698 | return $sorted_plugin_caps; |
| 699 | }; |
| 700 | |
| 701 | // caps: plugins |
| 702 | $plugin_caps = apply_filters('cme_plugin_capabilities', []); |
| 703 | $plugin_caps = $sort_publishpress_plugin_caps($plugin_caps); |
| 704 | |
| 705 | foreach($plugin_caps as $plugin_title => $__plugin_caps) { |
| 706 | $plugin_title = esc_html($plugin_title); |
| 707 | |
| 708 | $tab_slug = pp_capabilities_convert_to_slug(sanitize_title($plugin_title)); |
| 709 | $tab_id = 'cme-cap-type-tables-' . $tab_slug; |
| 710 | $tab_name = esc_html(str_replace('_', ' ', $plugin_title)); |
| 711 | // support extractor staging label |
| 712 | $tab_name = str_replace('(CAPABILITYEXTRACTOR)', '<span class="capability-extractor-label">CE</span>', $tab_name); |
| 713 | $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : ''; |
| 714 | |
| 715 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 716 | echo '<li data-slug="' . esc_attr($tab_slug) . '" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">' |
| 717 | . $tab_name . |
| 718 | '</li>'; |
| 719 | } |
| 720 | |
| 721 | $tab_id = "cme-cap-type-tables-invalid"; |
| 722 | $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : ''; |
| 723 | $tab_caption = esc_html__( 'Invalid Capabilities', 'capability-manager-enhanced' ); |
| 724 | echo '<li id="cme_tab_invalid_caps" data-slug="invalid" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '" style="display:none;">' . esc_html($tab_caption) . '</li>'; |
| 725 | |
| 726 | $tab_id = "cme-cap-type-tables-additional"; |
| 727 | $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : ''; |
| 728 | $tab_caption = esc_html__( 'Additional', 'capability-manager-enhanced' ); |
| 729 | echo '<li data-slug="additional" data-content="' . esc_attr($tab_id) . '" class="' . esc_attr($tab_active) . '">' . esc_html($tab_caption) . '</li>'; |
| 730 | ?> |
| 731 | </ul> |
| 732 | </div> |
| 733 | |
| 734 | <div id="capabilities_content" class="ppc-capabilities-content"> |
| 735 | <?php |
| 736 | // caps: read, edit, deletion |
| 737 | foreach( array_keys($cap_properties) as $cap_type ) { |
| 738 | |
| 739 | foreach( array_keys($defined) as $item_type ) { |
| 740 | |
| 741 | |
| 742 | if (!isset($cap_properties[$cap_type][$item_type])) { |
| 743 | continue; |
| 744 | } |
| 745 | if ( ! count( $cap_properties[$cap_type][$item_type] ) ) |
| 746 | continue; |
| 747 | |
| 748 | $tab_id = "cme-cap-type-tables-" . pp_capabilities_convert_to_slug($cap_type); |
| 749 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 750 | |
| 751 | $any_caps = false; |
| 752 | |
| 753 | if ($item_type == 'taxonomy') { |
| 754 | $tab_id .= '-taxonomy'; |
| 755 | |
| 756 | ob_start(); |
| 757 | } |
| 758 | |
| 759 | echo "<div id='" . esc_attr($tab_id) . "' style='display:" . esc_attr($div_display) . ";'>"; |
| 760 | |
| 761 | if ('taxonomy' == $item_type) { |
| 762 | $caption_pattern = esc_html__('Term %s Capabilities', 'capability-manager-enhanced'); |
| 763 | } else { |
| 764 | $caption_pattern = (in_array($cap_type, ['copy', 'revise'])) |
| 765 | ? esc_html__('%s Capabilities', 'capability-manager-enhanced') |
| 766 | : esc_html__('Post %s Capabilities', 'capability-manager-enhanced'); |
| 767 | } |
| 768 | |
| 769 | $cap_type_name = ('taxonomies' == $cap_type) ? esc_html__('Taxonomy', 'capability-manager-enhanced') : $cap_type_names[$cap_type]; |
| 770 | |
| 771 | echo '<h3>' . sprintf($caption_pattern, esc_html($cap_type_name)) . '</h3>'; |
| 772 | |
| 773 | echo '<div class="ppc-filter-wrapper">'; |
| 774 | echo '<select class="ppc-filter-select">'; |
| 775 | $filter_caption = ('taxonomy' == $item_type) ? __('Filter by taxonomy', 'capability-manager-enhanced') : __('Filter by post type', 'capability-manager-enhanced'); |
| 776 | echo '<option value="">' . esc_html($filter_caption) . '</option>'; |
| 777 | echo '</select>'; |
| 778 | echo ' <button class="button secondary-button ppc-filter-select-reset" type="button">' . esc_html__('Clear') . '</button>'; |
| 779 | echo '</div>'; |
| 780 | |
| 781 | echo "<table class='widefat striped cme-typecaps cme-typecaps-basic cme-typecaps-" . esc_attr($cap_type) . "'>"; |
| 782 | |
| 783 | echo '<thead><tr><th class="pp-header-checkall">'; |
| 784 | echo '<input type="checkbox" name="pp_toggle_all" class="excluded-input" autocomplete="off"> '; |
| 785 | echo '</th>'; |
| 786 | |
| 787 | // label cap properties |
| 788 | foreach( $cap_properties[$cap_type][$item_type] as $prop ) { |
| 789 | $prop = str_replace( '_posts', '', $prop ); |
| 790 | $prop = str_replace( '_pages', '', $prop ); |
| 791 | $prop = str_replace( '_terms', '', $prop ); |
| 792 | |
| 793 | if (in_array($prop, ['copy_published', 'copy_private', 'revise_published', 'revise_private'])) { |
| 794 | echo "<th></th>"; |
| 795 | continue; |
| 796 | } |
| 797 | |
| 798 | $th_class = ( 'taxonomy' == $item_type ) ? 'term-cap' : 'post-cap'; |
| 799 | |
| 800 | $tip_text = ''; |
| 801 | if ( isset( $cap_tips[$prop] ) ) { |
| 802 | $th_class .= ' ppc-tool-tip'; |
| 803 | $tip_text = '<div class="tool-tip-text"> |
| 804 | <p>'. $cap_tips[$prop] .'</p> |
| 805 | <i></i> |
| 806 | </div>'; |
| 807 | } |
| 808 | |
| 809 | echo "<th style='text-align:center;' class='" . esc_attr($th_class) . "'>" . $tip_text; |
| 810 | |
| 811 | if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) { |
| 812 | echo str_replace('_', '<br />', esc_html(ucwords($prop))); |
| 813 | } |
| 814 | |
| 815 | echo '</th>'; |
| 816 | } |
| 817 | |
| 818 | echo '</tr></thead>'; |
| 819 | $attachement_cap_position = 0; |
| 820 | foreach( $defined[$item_type] as $key => $type_obj ) { |
| 821 | if ( in_array( $key, $unfiltered[$item_type] ) ) |
| 822 | continue; |
| 823 | |
| 824 | if (in_array($cap_type, ['copy', 'revise'])) { |
| 825 | global $revisionary; |
| 826 | |
| 827 | if (!empty($revisionary) && !empty($revisionary->enabled_post_types) && empty($revisionary->enabled_post_types[$key])) { |
| 828 | continue; |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | $row = "<tr class='cme_type_" . esc_attr($key) . "'>"; |
| 833 | |
| 834 | if ( $cap_type ) { |
| 835 | |
| 836 | if (empty($force_distinct_ui) && empty($cap_properties[$cap_type][$item_type])) { |
| 837 | continue; |
| 838 | } |
| 839 | |
| 840 | if (defined('PRESSPERMIT_VERSION') || defined('PRESSPERMIT_PRO_VERSION')) { |
| 841 | //add list capabilities |
| 842 | if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->list_posts)) { |
| 843 | $type_obj->cap->list_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_posts); |
| 844 | } |
| 845 | if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->list_others_posts)) { |
| 846 | $type_obj->cap->list_others_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_others_posts); |
| 847 | } |
| 848 | if (isset($type_obj->cap->edit_published_posts) && !isset($type_obj->cap->list_published_posts)) { |
| 849 | $type_obj->cap->list_published_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_published_posts); |
| 850 | } |
| 851 | if (isset($type_obj->cap->edit_private_posts) && !isset($type_obj->cap->list_private_posts)) { |
| 852 | $type_obj->cap->list_private_posts = str_replace('edit_', 'list_', $type_obj->cap->edit_private_posts); |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | if ($pp_revisions_copy) { |
| 857 | //add copy capabilities |
| 858 | if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->copy_posts)) { |
| 859 | $type_obj->cap->copy_posts = str_replace('edit_', 'copy_', $type_obj->cap->edit_posts); |
| 860 | } |
| 861 | if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->copy_others_posts)) { |
| 862 | $type_obj->cap->copy_others_posts = str_replace('edit_', 'copy_', $type_obj->cap->edit_others_posts); |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | if ($pp_revisions_revise) { |
| 867 | //add revise capabilities |
| 868 | if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->revise_posts)) { |
| 869 | $type_obj->cap->revise_posts = str_replace('edit_', 'revise_', $type_obj->cap->edit_posts); |
| 870 | } |
| 871 | if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->revise_others_posts)) { |
| 872 | $type_obj->cap->revise_others_posts = str_replace('edit_', 'revise_', $type_obj->cap->edit_others_posts); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | if ($pp_revisions_approve) { |
| 877 | //add approve capabilities |
| 878 | if (isset($type_obj->cap->edit_posts) && !isset($type_obj->cap->approve_posts)) { |
| 879 | $type_obj->cap->approve_posts = str_replace('edit_', 'approve_', $type_obj->cap->edit_posts); |
| 880 | } |
| 881 | if (isset($type_obj->cap->edit_others_posts) && !isset($type_obj->cap->approve_others_posts)) { |
| 882 | $type_obj->cap->approve_others_posts = str_replace('edit_', 'approve_', $type_obj->cap->edit_others_posts); |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | if ('wp_navigation' == $type_obj->name) { |
| 887 | $type_label = __('Nav Menus (Block)', 'capability-manager-enhanced'); |
| 888 | } elseif ('nav_menu' == $type_obj->name) { |
| 889 | $type_label = __('Nav Menus (Legacy)', 'capability-manager-enhanced'); |
| 890 | } else { |
| 891 | $type_label = (defined('CME_LEGACY_MENU_NAME_LABEL') && !empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name; |
| 892 | } |
| 893 | |
| 894 | if (!empty($type_obj->name)) { |
| 895 | if ('taxonomy' == $item_type) { |
| 896 | $type_tooltip = sprintf(__( 'The slug for this taxonomy is %s', 'capability-manager-enhanced' ), '<strong>' . esc_html($type_obj->name) . '</strong>' ); |
| 897 | } else { |
| 898 | $type_tooltip = sprintf(__( 'The slug for this post type is %s', 'capability-manager-enhanced' ), '<strong>' . esc_html($type_obj->name) . '</strong>' ); |
| 899 | } |
| 900 | $type_tooltip_class = 'ppc-tool-tip disabled'; |
| 901 | $type_tooltip_msg = '<span class="tool-tip-text"> |
| 902 | <p>'. $type_tooltip .'</p> |
| 903 | <i></i> |
| 904 | </span>'; |
| 905 | } else { |
| 906 | $type_tooltip_class = ''; |
| 907 | $type_tooltip_msg = ''; |
| 908 | } |
| 909 | |
| 910 | $row .= "<td>"; |
| 911 | $row .= '<input type="checkbox" class="pp-row-action-rotate excluded-input"> '; |
| 912 | $row .= "<span class='{$type_tooltip_class}'><a class='cap_type' href='#toggle_type_caps'>" . esc_html($type_label) . '</a> '. $type_tooltip_msg .'</span>'; |
| 913 | $row .= '<a style="display: none;" href="#" class="neg-type-caps"> x </a>'; |
| 914 | $row .= '</td>'; |
| 915 | |
| 916 | $display_row = ! empty($force_distinct_ui); |
| 917 | $col_count = 0; |
| 918 | |
| 919 | foreach( $cap_properties[$cap_type][$item_type] as $prop ) { |
| 920 | $td_classes = array(); |
| 921 | $checkbox = ''; |
| 922 | $cap_title = ''; |
| 923 | $disabled_cap = false; |
| 924 | |
| 925 | if ($type_obj->name === 'attachment') { |
| 926 | $attachement_cap_position++; |
| 927 | } |
| 928 | |
| 929 | if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) ) |
| 930 | || ! in_array( $type_obj->cap->$prop, $default_caps ) |
| 931 | || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) { |
| 932 | |
| 933 | // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it |
| 934 | if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) ) |
| 935 | && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) ) |
| 936 | && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) ) |
| 937 | |
| 938 | && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) |
| 939 | || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop]) |
| 940 | || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 ) |
| 941 | || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop ) |
| 942 | || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) |
| 943 | ) |
| 944 | |
| 945 | && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) |
| 946 | || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop]) |
| 947 | || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 ) |
| 948 | || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name |
| 949 | || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop ) |
| 950 | || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop ) |
| 951 | || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) |
| 952 | || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) |
| 953 | ) |
| 954 | && (!in_array($type_obj->cap->$prop, $grouped_caps_lists)) //capability not enforced in $grouped_caps_lists |
| 955 | && (('manage_post_tags' != $type_obj->cap->$prop) || ('post_tag' == $type_obj->name)) |
| 956 | ) { |
| 957 | // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms |
| 958 | if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) { |
| 959 | continue; |
| 960 | } |
| 961 | |
| 962 | $cap_name = sanitize_text_field($type_obj->cap->$prop); |
| 963 | $set_application_password_cap($cap_name); |
| 964 | |
| 965 | if ( 'taxonomy' == $item_type ) |
| 966 | $td_classes []= "term-cap"; |
| 967 | else |
| 968 | $td_classes []= "post-cap"; |
| 969 | |
| 970 | if ( $is_administrator || current_user_can($cap_name) ) { |
| 971 | $chk_classes = []; |
| 972 | |
| 973 | $cap_title = ''; |
| 974 | if (! empty($pp_metagroup_caps[$cap_name]) ) { |
| 975 | $tool_tip = sprintf(__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 976 | $chk_classes []= 'cm-has-via-pp'; |
| 977 | } else { |
| 978 | $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 979 | } |
| 980 | |
| 981 | $chk_class = ( $chk_classes ) ? ' class="' . implode(' ', $chk_classes) . '"' : ''; |
| 982 | |
| 983 | $checkbox = '<div class="ppc-tool-tip disabled"><input type="checkbox"' . $chk_class . ' name="caps[' . esc_attr($cap_name) . ']" autocomplete="off" value="1" ' . checked(1, ! empty($rcaps[$cap_name]), false ) . ' /> |
| 984 | <div class="tool-tip-text"> |
| 985 | <p>'. $tool_tip .'</p> |
| 986 | <i></i> |
| 987 | </div> |
| 988 | </div>'; |
| 989 | |
| 990 | $type_caps [$cap_name] = true; |
| 991 | $display_row = true; |
| 992 | $any_caps = true; |
| 993 | $disabled_cap = false; |
| 994 | } |
| 995 | } else { |
| 996 | |
| 997 | // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms |
| 998 | if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) { |
| 999 | continue; |
| 1000 | } |
| 1001 | |
| 1002 | $disabled_cap = true; |
| 1003 | $display_row = true; |
| 1004 | $cap_name = sanitize_text_field($type_obj->cap->$prop); |
| 1005 | $set_application_password_cap($cap_name); |
| 1006 | $cap_title = ''; |
| 1007 | |
| 1008 | if (($cap_name === 'manage_categories') && !defined('PRESSPERMIT_ACTIVE')) { |
| 1009 | $tool_tip = sprintf(__( 'This capability is controlled by %s', 'capability-manager-enhanced' ), '<strong>manage_categories</strong>' ); |
| 1010 | |
| 1011 | } else { |
| 1012 | $tool_tip = sprintf(__('This capability is controlled by %s Use the sidebar settings to allow this to be controlled independently.', 'capability-manager-enhanced'), '<strong>' . $cap_name . '</strong>.<br /><br />'); |
| 1013 | } |
| 1014 | |
| 1015 | $checkbox = '<div class="ppc-tool-tip disabled"><input disabled class="disabled" type="checkbox" ' . checked(1, ! empty($rcaps[$cap_name]), false ) . ' /> |
| 1016 | <div class="tool-tip-text"> |
| 1017 | <p>'. $tool_tip .'</p> |
| 1018 | <i></i> |
| 1019 | </div> |
| 1020 | </div>'; |
| 1021 | } |
| 1022 | |
| 1023 | if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) { |
| 1024 | $td_classes []= "cap-neg"; |
| 1025 | } |
| 1026 | } else { |
| 1027 | if ($type_obj->name === 'attachment') { |
| 1028 | if ($attachement_cap_position === 1 || $attachement_cap_position === 3) { |
| 1029 | $tool_tip =__('Use the sidebar settings to allow this to be controlled independently.', 'capability-manager-enhanced'); |
| 1030 | } else { |
| 1031 | $tool_tip =__('This capability is not available for this post type.', 'capability-manager-enhanced'); |
| 1032 | } |
| 1033 | |
| 1034 | } else { |
| 1035 | $tool_tip =__('This capability is not available for this post type.', 'capability-manager-enhanced'); |
| 1036 | } |
| 1037 | $checkbox = '<div class="ppc-tool-tip disabled"> |
| 1038 | <div class="tool-tip-text"> |
| 1039 | <p>'. $tool_tip .'</p> |
| 1040 | <i></i> |
| 1041 | </div> |
| 1042 | </div>'; |
| 1043 | $td_classes []= "cap-unreg"; |
| 1044 | } |
| 1045 | |
| 1046 | $td_classes[] = 'capability-checkbox-rotate'; |
| 1047 | $td_classes[] = $cap_name; |
| 1048 | |
| 1049 | $td_class = ( $td_classes ) ? implode(' ', $td_classes) : ''; |
| 1050 | |
| 1051 | $row .= '<td class="' . esc_attr($td_class) . '" title="' . esc_attr($cap_title) . '"' . "><span class='ppc-tool-tip disabled cap-x'>X</span>$checkbox"; |
| 1052 | |
| 1053 | if ( !$disabled_cap && false !== strpos( $td_class, 'cap-neg' ) ) |
| 1054 | $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . esc_attr($cap_name) . ']" value="" />'; |
| 1055 | |
| 1056 | $row .= "</td>"; |
| 1057 | |
| 1058 | $col_count++; |
| 1059 | } |
| 1060 | |
| 1061 | if ('taxonomy' == $item_type) { |
| 1062 | for ($i = $col_count; $i < 4; $i++) { |
| 1063 | $row .= "<td></td>"; |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | if (!empty($type_obj->map_meta_cap) && !defined('PP_CAPABILITIES_NO_INVALID_SECTION')) { |
| 1068 | if ('type' == $item_type) { |
| 1069 | if (!in_array($type_obj->cap->read_post, $grouped_caps_lists) |
| 1070 | && !in_array($type_obj->cap->edit_post, $grouped_caps_lists) |
| 1071 | && !in_array($type_obj->cap->delete_post, $grouped_caps_lists) |
| 1072 | ) { |
| 1073 | $type_metacaps[$type_obj->cap->read_post] = true; |
| 1074 | $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts); |
| 1075 | $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts); |
| 1076 | } |
| 1077 | } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) { |
| 1078 | if (!in_array($type_obj->cap->edit_term, $grouped_caps_lists) |
| 1079 | && !in_array($type_obj->cap->delete_term, $grouped_caps_lists) |
| 1080 | ) { |
| 1081 | $type_metacaps[$type_obj->cap->edit_term] = true; |
| 1082 | $type_metacaps[$type_obj->cap->delete_term] = true; |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | if ( $display_row ) { |
| 1089 | $row .= '</tr>'; |
| 1090 | |
| 1091 | // Escaped piecemeal upstream; cannot be late-escaped until upstream UI output logic is reworked |
| 1092 | echo $row; |
| 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | echo '</table>'; |
| 1097 | |
| 1098 | if ($cap_type === 'list' && defined('PRESSPERMIT_VERSION') && defined('PRESSPERMIT_COLLAB_VERSION')) { |
| 1099 | echo '<p class="pp-subtext"> '. esc_html__('Admin listing access is normally provided by the "Edit" capabilities. These "List" capabilities only apply if the corresponding "Edit" capability is missing. Also, these "List" capabilities can grant access, but not deny access.', 'capability-manager-enhanced') .' </p>'; |
| 1100 | } |
| 1101 | |
| 1102 | do_action('publishpress-caps_manager_postcaps_table', $cap_type, $item_type, compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps', 'active_tab_id')); |
| 1103 | |
| 1104 | echo '</div>'; |
| 1105 | |
| 1106 | if ($item_type == 'taxonomy') { |
| 1107 | if ($any_caps) { |
| 1108 | ob_flush(); |
| 1109 | } else { |
| 1110 | ob_clean(); |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | } // end foreach item type |
| 1115 | } |
| 1116 | |
| 1117 | if (empty($caps_manager_postcaps_section)) { |
| 1118 | $caps_manager_postcaps_section = ''; |
| 1119 | } |
| 1120 | |
| 1121 | 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')); |
| 1122 | |
| 1123 | $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps); |
| 1124 | |
| 1125 | // clicking on post type name toggles corresponding checkbox selections |
| 1126 | |
| 1127 | // caps: grouped |
| 1128 | $grouped_caps = apply_filters('cme_grouped_capabilities', $grouped_caps); |
| 1129 | |
| 1130 | foreach($grouped_caps as $grouped_title => $__grouped_caps) { |
| 1131 | |
| 1132 | $tab_id = 'cme-cap-type-tables-' . esc_attr(pp_capabilities_convert_to_slug($grouped_title)); |
| 1133 | |
| 1134 | switch ($grouped_title) { |
| 1135 | case 'Comments' : |
| 1136 | $grouped_title = __('Comments'); |
| 1137 | break; |
| 1138 | |
| 1139 | case 'Media' : |
| 1140 | $grouped_title = __('Media'); |
| 1141 | break; |
| 1142 | |
| 1143 | case 'Users' : |
| 1144 | $grouped_title = __('Users'); |
| 1145 | break; |
| 1146 | |
| 1147 | case 'Themes' : |
| 1148 | $grouped_title = __('Themes'); |
| 1149 | break; |
| 1150 | |
| 1151 | case 'Plugins' : |
| 1152 | $grouped_title = __('Plugins'); |
| 1153 | break; |
| 1154 | |
| 1155 | case 'Multisite' : |
| 1156 | $grouped_title = esc_html__('Multisite', 'capability-manager-enhanced'); |
| 1157 | break; |
| 1158 | |
| 1159 | case 'Admin' : |
| 1160 | $grouped_title = esc_html__('Admin', 'capability-manager-enhanced'); |
| 1161 | break; |
| 1162 | |
| 1163 | default: |
| 1164 | $grouped_title = esc_html($grouped_title); |
| 1165 | } |
| 1166 | |
| 1167 | $_grouped_caps = array_fill_keys($__grouped_caps, true); |
| 1168 | |
| 1169 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 1170 | |
| 1171 | echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '">'; |
| 1172 | |
| 1173 | echo '<h3 class="cme-cap-section">' . esc_html(str_replace('_', ' ', $grouped_title)) . '</h3>'; |
| 1174 | |
| 1175 | echo '<div class="ppc-filter-wrapper">'; |
| 1176 | echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">'; |
| 1177 | echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>'; |
| 1178 | echo '</div>'; |
| 1179 | echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>'; |
| 1180 | |
| 1181 | echo '<table class="widefat fixed striped form-table cme-checklist single-checkbox-table">'; |
| 1182 | |
| 1183 | $centinel_ = true; |
| 1184 | $checks_per_row = get_option( 'cme_form-rows', 1 ); |
| 1185 | $i = 0; $first_row = true; |
| 1186 | |
| 1187 | ?> |
| 1188 | <tr class="cme-bulk-select"> |
| 1189 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1190 | <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1191 | </td> |
| 1192 | </tr> |
| 1193 | <?php |
| 1194 | foreach( array_keys($_grouped_caps) as $cap_name ) { |
| 1195 | $cap_name = sanitize_text_field($cap_name); |
| 1196 | $set_application_password_cap($cap_name); |
| 1197 | |
| 1198 | if ( isset( $type_caps[$cap_name] ) || isset($type_metacaps[$cap_name]) ) { |
| 1199 | continue; |
| 1200 | } |
| 1201 | |
| 1202 | if ( ! $is_administrator && ! current_user_can($cap_name) ) |
| 1203 | continue; |
| 1204 | |
| 1205 | // Output first <tr> |
| 1206 | if ( $centinel_ == true ) { |
| 1207 | echo '<tr class="' . esc_attr($cap_name) . '">'; |
| 1208 | $centinel_ = false; |
| 1209 | } |
| 1210 | |
| 1211 | if ( $i == $checks_per_row ) { |
| 1212 | echo '</tr><tr class="' . esc_attr($cap_name) . '">'; |
| 1213 | $i = 0; |
| 1214 | } |
| 1215 | |
| 1216 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 1217 | $class = 'cap-no'; |
| 1218 | else |
| 1219 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 1220 | |
| 1221 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 1222 | $class .= ' cap-metagroup'; |
| 1223 | $tool_tip = sprintf(__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1224 | } else { |
| 1225 | $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1226 | } |
| 1227 | |
| 1228 | $disabled = ''; |
| 1229 | $checked = !empty($rcaps[$cap_name]) ? 'checked' : ''; |
| 1230 | $cap_title = ''; |
| 1231 | |
| 1232 | $tooltip_html = ' |
| 1233 | <div class="tool-tip-text"> |
| 1234 | <p>'. $tool_tip .'</p> |
| 1235 | <i></i> |
| 1236 | </div> |
| 1237 | '; |
| 1238 | ?> |
| 1239 | <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> /> |
| 1240 | <span> |
| 1241 | <?php |
| 1242 | echo esc_html(str_replace( '_', ' ', $cap_name)); |
| 1243 | ?> |
| 1244 | </span></label> |
| 1245 | <?php echo $tooltip_html; ?> |
| 1246 | </span><a href="#" class="neg-cap" style="visibility: hidden;"> x </a> |
| 1247 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 1248 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" /> |
| 1249 | <?php endif; ?> |
| 1250 | </td> |
| 1251 | |
| 1252 | <?php |
| 1253 | ++$i; |
| 1254 | } |
| 1255 | |
| 1256 | if ( $i == $checks_per_row ) { |
| 1257 | echo '</tr>'; |
| 1258 | $i = 0; |
| 1259 | } elseif ( ! $first_row ) { |
| 1260 | // Now close a wellformed table |
| 1261 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 1262 | echo '<td> </td>'; |
| 1263 | } |
| 1264 | echo '</tr>'; |
| 1265 | } |
| 1266 | ?> |
| 1267 | |
| 1268 | <tr class="cme-bulk-select"> |
| 1269 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1270 | <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1271 | </td> |
| 1272 | </tr> |
| 1273 | |
| 1274 | </table> |
| 1275 | </div> |
| 1276 | <?php |
| 1277 | } |
| 1278 | |
| 1279 | // caps: other |
| 1280 | |
| 1281 | $tab_id = "cme-cap-type-tables-other"; |
| 1282 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 1283 | ?> |
| 1284 | <div id="<?php echo esc_attr($tab_id);?>" style="display:<?php echo esc_attr($div_display);?>"> |
| 1285 | <?php |
| 1286 | |
| 1287 | echo '<h3>' . esc_html__( 'WordPress Core Capabilities', 'capability-manager-enhanced' ) . '</h3>'; |
| 1288 | |
| 1289 | echo '<div class="ppc-filter-wrapper">'; |
| 1290 | echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">'; |
| 1291 | echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>'; |
| 1292 | echo '</div>'; |
| 1293 | echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>'; |
| 1294 | |
| 1295 | echo '<table class="widefat fixed striped form-table cme-checklist">'; |
| 1296 | |
| 1297 | $centinel_ = true; |
| 1298 | $checks_per_row = get_option( 'cme_form-rows', 1 ); |
| 1299 | $i = 0; $first_row = true; |
| 1300 | |
| 1301 | ?> |
| 1302 | <tr class="cme-bulk-select"> |
| 1303 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1304 | <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1305 | </td> |
| 1306 | </tr> |
| 1307 | |
| 1308 | <tr class="cme-bulk-select"> |
| 1309 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1310 | <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1311 | </td> |
| 1312 | </tr> |
| 1313 | |
| 1314 | </table> |
| 1315 | </div> |
| 1316 | |
| 1317 | <?php |
| 1318 | $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID ); |
| 1319 | $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities ); |
| 1320 | |
| 1321 | // caps: plugins |
| 1322 | $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps); |
| 1323 | $plugin_caps = $sort_publishpress_plugin_caps($plugin_caps); |
| 1324 | |
| 1325 | $plugin_cap_descriptions = apply_filters('cme_capability_descriptions', []); |
| 1326 | |
| 1327 | foreach($plugin_caps as $plugin_title => $__plugin_caps) { |
| 1328 | $plugin_title_raw = (string) $plugin_title; |
| 1329 | $plugin_title = esc_html($plugin_title_raw); |
| 1330 | |
| 1331 | // Compact for old permission description format |
| 1332 | //TODO: Remove after permission update their code to new structure |
| 1333 | if ('PublishPress Permissions' === $plugin_title_raw && function_exists('apply_filters')) { |
| 1334 | $plugin_cap_descriptions = apply_filters('presspermit_cap_descriptions', $plugin_cap_descriptions); |
| 1335 | } |
| 1336 | |
| 1337 | $plugin_cap_payload = (array) $__plugin_caps; |
| 1338 | $plugin_cap_groups = []; |
| 1339 | $all_plugin_caps = pp_capabilities_plugin_capability_list($plugin_cap_payload); |
| 1340 | $_plugin_caps = array_fill_keys($all_plugin_caps, true); |
| 1341 | |
| 1342 | // Support grouped or single list payload. |
| 1343 | $is_grouped_payload = false; |
| 1344 | foreach ($plugin_cap_payload as $payload_caps) { |
| 1345 | if (is_array($payload_caps)) { |
| 1346 | $is_grouped_payload = true; |
| 1347 | break; |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | if ($is_grouped_payload) { |
| 1352 | $plugin_cap_groups = function_exists('pp_capabilities_groups_with_descriptions') |
| 1353 | ? pp_capabilities_groups_with_descriptions($plugin_cap_payload, $plugin_cap_descriptions) |
| 1354 | : $plugin_cap_payload; |
| 1355 | } else { |
| 1356 | $plugin_cap_groups = apply_filters( |
| 1357 | 'publishpress_caps_plugin_capability_groups', |
| 1358 | [], |
| 1359 | $plugin_title_raw, |
| 1360 | $all_plugin_caps, |
| 1361 | $default |
| 1362 | ); |
| 1363 | } |
| 1364 | |
| 1365 | $normalized_plugin_cap_groups = []; |
| 1366 | $plugin_group_cap_descriptions = []; |
| 1367 | $grouped_plugin_caps = []; |
| 1368 | |
| 1369 | if (is_array($plugin_cap_groups)) { |
| 1370 | foreach ($plugin_cap_groups as $group_label => $group_caps) { |
| 1371 | if (empty($group_caps) || !is_array($group_caps)) { |
| 1372 | continue; |
| 1373 | } |
| 1374 | |
| 1375 | $group_label = sanitize_text_field((string) $group_label); |
| 1376 | if ('' === $group_label) { |
| 1377 | continue; |
| 1378 | } |
| 1379 | |
| 1380 | $normalized_group_caps = []; |
| 1381 | foreach ($group_caps as $group_cap_key => $group_cap_value) { |
| 1382 | $group_cap_description = ''; |
| 1383 | |
| 1384 | if (is_string($group_cap_key) && ('' !== $group_cap_key) && !is_numeric($group_cap_key)) { |
| 1385 | $group_cap = sanitize_text_field($group_cap_key); |
| 1386 | |
| 1387 | if (is_string($group_cap_value)) { |
| 1388 | $group_cap_description = $group_cap_value; |
| 1389 | } elseif (is_array($group_cap_value) && !empty($group_cap_value['description']) && is_string($group_cap_value['description'])) { |
| 1390 | $group_cap_description = $group_cap_value['description']; |
| 1391 | } |
| 1392 | } else { |
| 1393 | $group_cap = sanitize_text_field((string) $group_cap_value); |
| 1394 | } |
| 1395 | |
| 1396 | if ('' === $group_cap || !isset($_plugin_caps[$group_cap]) || isset($grouped_plugin_caps[$group_cap])) { |
| 1397 | continue; |
| 1398 | } |
| 1399 | |
| 1400 | $normalized_group_caps[] = $group_cap; |
| 1401 | $grouped_plugin_caps[$group_cap] = true; |
| 1402 | |
| 1403 | if ('' !== trim($group_cap_description)) { |
| 1404 | $plugin_group_cap_descriptions[$group_cap] = $group_cap_description; |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | if (!empty($normalized_group_caps)) { |
| 1409 | $normalized_plugin_cap_groups[$group_label] = $normalized_group_caps; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | $plugin_cap_group_for_cap = []; |
| 1415 | $ordered_plugin_caps = []; |
| 1416 | |
| 1417 | foreach ($normalized_plugin_cap_groups as $group_label => $group_caps) { |
| 1418 | foreach ($group_caps as $group_cap) { |
| 1419 | $ordered_plugin_caps[] = $group_cap; |
| 1420 | $plugin_cap_group_for_cap[$group_cap] = $group_label; |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | $ungrouped_plugin_caps = array_values(array_diff($all_plugin_caps, array_keys($grouped_plugin_caps))); |
| 1425 | if (!empty($ungrouped_plugin_caps)) { |
| 1426 | $general_group_label = __('General', 'capability-manager-enhanced'); |
| 1427 | |
| 1428 | foreach ($ungrouped_plugin_caps as $ungrouped_cap) { |
| 1429 | $ordered_plugin_caps[] = $ungrouped_cap; |
| 1430 | $plugin_cap_group_for_cap[$ungrouped_cap] = $general_group_label; |
| 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | $tab_id = 'cme-cap-type-tables-' . esc_attr(pp_capabilities_convert_to_slug($plugin_title)); |
| 1435 | $tab_name = esc_html(str_replace('_', ' ', $plugin_title_raw)); |
| 1436 | // support extractor staging label |
| 1437 | $tab_name = str_replace('(CAPABILITYEXTRACTOR)', '<span class="capability-extractor-label">CE</span>', $tab_name); |
| 1438 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 1439 | |
| 1440 | echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '" class="cme-plugin-cap-table">'; |
| 1441 | |
| 1442 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1443 | echo '<h3 class="cme-cap-section">' . sprintf(esc_html__( 'Plugin Capabilities – %s', 'capability-manager-enhanced' ), $tab_name) . '</h3>'; |
| 1444 | |
| 1445 | echo '<div class="ppc-filter-wrapper">'; |
| 1446 | echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">'; |
| 1447 | echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . esc_html__('Clear') . '</button>'; |
| 1448 | echo '</div>'; |
| 1449 | echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>'; |
| 1450 | |
| 1451 | echo '<table class="widefat fixed striped form-table cme-checklist single-checkbox-table">'; |
| 1452 | |
| 1453 | $centinel_ = true; |
| 1454 | $checks_per_row = get_option( 'cme_form-rows', 1 ); |
| 1455 | $i = 0; $first_row = true; |
| 1456 | |
| 1457 | ?> |
| 1458 | <tr class="cme-bulk-select"> |
| 1459 | <td colspan="<?php echo (int) $checks_per_row + 1;?>" style="width: 100%"> |
| 1460 | <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1461 | </td> |
| 1462 | </tr> |
| 1463 | <?php |
| 1464 | $last_cap_group = ''; |
| 1465 | $unique_cap_groups = array_unique(array_values($plugin_cap_group_for_cap)); |
| 1466 | $show_group_headings = count($unique_cap_groups) > 1; |
| 1467 | |
| 1468 | foreach( $ordered_plugin_caps as $cap_name ) { |
| 1469 | $cap_name = sanitize_text_field($cap_name); |
| 1470 | $set_application_password_cap($cap_name); |
| 1471 | |
| 1472 | if ( isset( $type_caps[$cap_name] ) || in_array($cap_name, $grouped_caps_lists) || isset($type_metacaps[$cap_name]) ) { |
| 1473 | continue; |
| 1474 | } |
| 1475 | |
| 1476 | if ( ! $is_administrator && ! current_user_can($cap_name) ) |
| 1477 | continue; |
| 1478 | |
| 1479 | $cap_group = isset($plugin_cap_group_for_cap[$cap_name]) |
| 1480 | ? $plugin_cap_group_for_cap[$cap_name] |
| 1481 | : __('General', 'capability-manager-enhanced'); |
| 1482 | |
| 1483 | if ($cap_group !== $last_cap_group) { |
| 1484 | if ($show_group_headings) { |
| 1485 | if (!$centinel_ && $i > 0) { |
| 1486 | for ($i; $i < $checks_per_row; $i++) { |
| 1487 | echo '<td> </td>'; |
| 1488 | } |
| 1489 | echo '</tr>'; |
| 1490 | $i = 0; |
| 1491 | $centinel_ = true; |
| 1492 | } |
| 1493 | |
| 1494 | echo '<tr class="cme-cap-group-subheading"><td colspan="' . (int) ($checks_per_row + 1) . '"><h4 class="cme-cap-group-title">' . esc_html($cap_group) . '</h4></td></tr>'; |
| 1495 | } |
| 1496 | $last_cap_group = $cap_group; |
| 1497 | } |
| 1498 | |
| 1499 | // Output first <tr> |
| 1500 | if ( $centinel_ == true ) { |
| 1501 | echo '<tr class="' . esc_attr($cap_name) . '">'; |
| 1502 | $centinel_ = false; |
| 1503 | } |
| 1504 | |
| 1505 | if ( $i == $checks_per_row ) { |
| 1506 | echo '</tr><tr class="' . esc_attr($cap_name) . '">'; |
| 1507 | $i = 0; |
| 1508 | } |
| 1509 | |
| 1510 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 1511 | $class = 'cap-no'; |
| 1512 | else |
| 1513 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 1514 | |
| 1515 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 1516 | $class .= ' cap-metagroup'; |
| 1517 | $tool_tip = sprintf(__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1518 | } else { |
| 1519 | $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1520 | } |
| 1521 | |
| 1522 | if ($cap_name === 'manage_capabilities_user_testing') { |
| 1523 | $warning_message = ' <span class="ppc-tool-tip"><span class="dashicons dashicons-info-outline"></span><span class="tool-tip-text"><p>'. sprintf(esc_html__('The User Testing feature also requires the %1$s edit_users %2$s capability.', 'capability-manager-enhanced'), '<strong>', '</strong>') .'</p><i></i></span></span>'; |
| 1524 | } else { |
| 1525 | $warning_message = ''; |
| 1526 | } |
| 1527 | |
| 1528 | $disabled = ''; |
| 1529 | $checked = !empty($rcaps[$cap_name]) ? 'checked' : ''; |
| 1530 | |
| 1531 | $cap_title = ''; |
| 1532 | |
| 1533 | $tooltip_html = ' |
| 1534 | <div class="tool-tip-text"> |
| 1535 | <p>'. $tool_tip .'</p> |
| 1536 | <i></i> |
| 1537 | </div> |
| 1538 | '; |
| 1539 | ?> |
| 1540 | <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> /> |
| 1541 | <span> |
| 1542 | <?php |
| 1543 | echo esc_html(str_replace( '_', ' ', $cap_name)); |
| 1544 | ?> |
| 1545 | </span></label> |
| 1546 | <?php echo $tooltip_html; ?> |
| 1547 | </span><?php echo $warning_message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><a href="#" class="neg-cap" style="visibility: hidden;"> x </a> |
| 1548 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 1549 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" /> |
| 1550 | <?php endif; ?> |
| 1551 | </td> |
| 1552 | |
| 1553 | <td class="pp-cap-description"> |
| 1554 | <?php |
| 1555 | if (!empty($plugin_group_cap_descriptions[$cap_name])) { |
| 1556 | echo $plugin_group_cap_descriptions[$cap_name]; |
| 1557 | } elseif (!empty($plugin_cap_descriptions[$cap_name])) { |
| 1558 | echo $plugin_cap_descriptions[$cap_name]; |
| 1559 | } |
| 1560 | ?> |
| 1561 | </td> |
| 1562 | |
| 1563 | <?php |
| 1564 | ++$i; |
| 1565 | } |
| 1566 | |
| 1567 | if ( $i == $checks_per_row ) { |
| 1568 | echo '</tr>'; |
| 1569 | $i = 0; |
| 1570 | } elseif ( ! $first_row ) { |
| 1571 | // Now close a wellformed table |
| 1572 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 1573 | echo '<td> </td>'; |
| 1574 | } |
| 1575 | echo '</tr>'; |
| 1576 | } |
| 1577 | ?> |
| 1578 | |
| 1579 | <tr class="cme-bulk-select"> |
| 1580 | <td colspan="<?php echo (int) $checks_per_row + 1;?>"> |
| 1581 | <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1582 | </td> |
| 1583 | </tr> |
| 1584 | |
| 1585 | </table> |
| 1586 | </div> |
| 1587 | <?php |
| 1588 | } |
| 1589 | |
| 1590 | // caps: invalid |
| 1591 | if (!$is_application_password && array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities) && array_intersect_key($type_metacaps, array_filter($rcaps))) { |
| 1592 | $tab_id = "cme-cap-type-tables-invalid"; |
| 1593 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 1594 | |
| 1595 | echo '<div id="' . esc_attr($tab_id) . '" style="display:' . esc_attr($div_display) . '">'; |
| 1596 | echo '<h3 class="cme-cap-section">' . esc_html__( 'Invalid Capabilities', 'capability-manager-enhanced' ) . '</h3>'; |
| 1597 | ?> |
| 1598 | |
| 1599 | <div> |
| 1600 | <span class="cme-subtext"> |
| 1601 | <?php esc_html_e('The following entries have no effect. Please assign desired capabilities on the Editing / Deletion / Private tabs.', 'capability-manager-enhanced');?> |
| 1602 | </span> |
| 1603 | </div> |
| 1604 | |
| 1605 | <table class="widefat fixed striped form-table cme-checklist single-checkbox-table"> |
| 1606 | <tr> |
| 1607 | <?php |
| 1608 | $i = 0; $first_row = true; |
| 1609 | $invalid_caps_capabilities = []; |
| 1610 | foreach( $all_capabilities as $cap_name ) { |
| 1611 | if ( ! isset($this->capabilities[$cap_name]) ) |
| 1612 | $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name ); |
| 1613 | } |
| 1614 | |
| 1615 | uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys ); |
| 1616 | |
| 1617 | foreach ( $this->capabilities as $cap_name => $cap ) : |
| 1618 | $cap_name = sanitize_text_field($cap_name); |
| 1619 | $set_application_password_cap($cap_name); |
| 1620 | |
| 1621 | if (!isset($type_metacaps[$cap_name]) || empty($rcaps[$cap_name])) { |
| 1622 | continue; |
| 1623 | } |
| 1624 | |
| 1625 | if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) { |
| 1626 | continue; |
| 1627 | } |
| 1628 | |
| 1629 | if ( $i == $checks_per_row ) { |
| 1630 | echo '</tr><tr>'; |
| 1631 | $i = 0; $first_row = false; |
| 1632 | } |
| 1633 | |
| 1634 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 1635 | $class = 'cap-no'; |
| 1636 | else |
| 1637 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 1638 | |
| 1639 | $title_text = $cap_name; |
| 1640 | |
| 1641 | $disabled = ''; |
| 1642 | $checked = !empty($rcaps[$cap_name]) ? 'checked' : ''; |
| 1643 | $invalid_caps_capabilities[] = $cap_name; |
| 1644 | |
| 1645 | $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1646 | |
| 1647 | $tooltip_html = ' |
| 1648 | <div class="tool-tip-text"> |
| 1649 | <p>'. $tool_tip .'</p> |
| 1650 | <i></i> |
| 1651 | </div> |
| 1652 | '; |
| 1653 | ?> |
| 1654 | <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><label title="<?php echo esc_attr($title_text);?>"><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . esc_attr($disabled);?> /> |
| 1655 | <span> |
| 1656 | <?php |
| 1657 | echo esc_html(str_replace( '_', ' ', $cap )); |
| 1658 | ?> |
| 1659 | <?php echo $tooltip_html; ?> |
| 1660 | </span></label><a href="#" class="neg-cap" style="visibility: hidden;"> x </a> |
| 1661 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 1662 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" /> |
| 1663 | <?php endif; ?> |
| 1664 | </td> |
| 1665 | <td> |
| 1666 | </td> |
| 1667 | <?php |
| 1668 | $i++; |
| 1669 | endforeach; |
| 1670 | |
| 1671 | if ( ! empty($lock_manage_caps_capability) ) { |
| 1672 | echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />'; |
| 1673 | } |
| 1674 | |
| 1675 | if ( $i == $checks_per_row ) { |
| 1676 | echo '</tr><tr>'; |
| 1677 | $i = 0; |
| 1678 | } else { |
| 1679 | if ( ! $first_row ) { |
| 1680 | // Now close a wellformed table |
| 1681 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 1682 | echo '<td> </td>'; |
| 1683 | } |
| 1684 | echo '</tr>'; |
| 1685 | } |
| 1686 | } |
| 1687 | ?> |
| 1688 | |
| 1689 | <?php if (!empty($invalid_caps_capabilities)) : ?> |
| 1690 | <script type="text/javascript"> |
| 1691 | /* <![CDATA[ */ |
| 1692 | jQuery(document).ready( function($) { |
| 1693 | $('#cme_tab_invalid_caps').show(); |
| 1694 | }); |
| 1695 | /* ]]> */ |
| 1696 | </script> |
| 1697 | <?php endif; ?> |
| 1698 | |
| 1699 | </table> |
| 1700 | </div> |
| 1701 | <?php |
| 1702 | } // endif any invalid caps |
| 1703 | |
| 1704 | $tab_id = "cme-cap-type-tables-additional"; |
| 1705 | $div_display = ($tab_id == $active_tab_id) ? 'block' : 'none'; |
| 1706 | ?> |
| 1707 | <div id="<?php echo esc_attr($tab_id);?>" style="display:<?php echo esc_attr($div_display);?>"> |
| 1708 | <?php |
| 1709 | // caps: additional |
| 1710 | echo '<h3 class="cme-cap-section">' . esc_html__( 'Additional Capabilities', 'capability-manager-enhanced' ) . '</h3>'; |
| 1711 | |
| 1712 | echo '<div class="ppc-filter-wrapper">'; |
| 1713 | echo '<input type="text" class="regular-text ppc-filter-text" placeholder="' . esc_attr__('Filter by capability', 'capability-manager-enhanced') . '">'; |
| 1714 | echo ' <button class="button secondary-button ppc-filter-text-reset" type="button">' . __('Clear') . '</button>'; |
| 1715 | echo '</div>'; |
| 1716 | echo '<div class="ppc-filter-no-results" style="display:none;">' . esc_html__( 'No results found. Please try again with a different word.', 'capability-manager-enhanced' ) . '</div>'; |
| 1717 | ?> |
| 1718 | <table class="widefat fixed striped form-table cme-checklist single-checkbox-table"> |
| 1719 | |
| 1720 | <tr class="cme-bulk-select"> |
| 1721 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1722 | <input type="checkbox" class="cme-check-all" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1723 | </td> |
| 1724 | </tr> |
| 1725 | |
| 1726 | <?php |
| 1727 | $centinel_ = true; |
| 1728 | $i = 0; $first_row = true; |
| 1729 | |
| 1730 | foreach( $all_capabilities as $cap_name ) { |
| 1731 | if ( ! isset($this->capabilities[$cap_name]) ) |
| 1732 | $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name ); |
| 1733 | } |
| 1734 | |
| 1735 | uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys ); |
| 1736 | |
| 1737 | $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities); |
| 1738 | $plugin_capability_lookup = pp_capabilities_plugin_capability_lookup($plugin_caps); |
| 1739 | $additional_tab_slug = 'additional'; |
| 1740 | $additional_group_config = pp_capabilities_capability_tab_group_config( |
| 1741 | $additional_tab_slug, |
| 1742 | __('Additional', 'capability-manager-enhanced'), |
| 1743 | $default, |
| 1744 | $additional_caps, |
| 1745 | [ |
| 1746 | $additional_tab_slug => 10, |
| 1747 | ] |
| 1748 | ); |
| 1749 | $additional_group_enabled = $additional_group_config['enabled']; |
| 1750 | $additional_group_label = $additional_group_config['label']; |
| 1751 | $additional_group_size = $additional_group_config['size']; |
| 1752 | |
| 1753 | $additional_rendered_count = 0; |
| 1754 | $caps_empty = true; |
| 1755 | foreach ($additional_caps as $cap_name => $cap) : |
| 1756 | $cap_name = sanitize_text_field($cap_name); |
| 1757 | $set_application_password_cap($cap_name); |
| 1758 | |
| 1759 | if ((isset($type_caps[$cap_name]) && !isset($type_metacaps[$cap_name])) |
| 1760 | || in_array($cap_name, $grouped_caps_lists) |
| 1761 | || (isset($type_metacaps[$cap_name]) && !empty($rcaps[$cap_name])) ) { |
| 1762 | continue; |
| 1763 | } |
| 1764 | |
| 1765 | if (!isset($type_metacaps[$cap_name]) || !empty($rcaps[$cap_name])) { |
| 1766 | if (isset($plugin_capability_lookup[$cap_name])) { |
| 1767 | continue; |
| 1768 | } |
| 1769 | } |
| 1770 | |
| 1771 | if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) { |
| 1772 | continue; |
| 1773 | } |
| 1774 | |
| 1775 | // Levels are not shown. |
| 1776 | if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) { |
| 1777 | continue; |
| 1778 | } |
| 1779 | |
| 1780 | if ($additional_group_enabled && (0 === ($additional_rendered_count % $additional_group_size))) { |
| 1781 | if (!$centinel_ && $i > 0) { |
| 1782 | for ($i; $i < $checks_per_row; $i++) { |
| 1783 | echo '<td> </td>'; |
| 1784 | } |
| 1785 | echo '</tr>'; |
| 1786 | $i = 0; |
| 1787 | $centinel_ = true; |
| 1788 | } |
| 1789 | |
| 1790 | $group_start = $additional_rendered_count + 1; |
| 1791 | $group_end = $group_start + $additional_group_size - 1; |
| 1792 | $group_title = pp_capabilities_capability_tab_group_title( |
| 1793 | $additional_tab_slug, |
| 1794 | $additional_group_label, |
| 1795 | $group_start, |
| 1796 | $group_end, |
| 1797 | $default, |
| 1798 | $additional_group_size, |
| 1799 | $additional_caps |
| 1800 | ); |
| 1801 | |
| 1802 | echo '<tr class="cme-cap-group-subheading"><td colspan="' . (int) $checks_per_row . '"><h4 class="cme-cap-group-title">' . esc_html($group_title) . '</h4></td></tr>'; |
| 1803 | } |
| 1804 | |
| 1805 | // Output first <tr> |
| 1806 | if ( $centinel_ == true ) { |
| 1807 | echo '<tr class="' . esc_attr($cap_name) . '">'; |
| 1808 | $centinel_ = false; |
| 1809 | } |
| 1810 | |
| 1811 | if ( $i == $checks_per_row ) { |
| 1812 | echo '</tr><tr class="' . esc_attr($cap_name) . '">'; |
| 1813 | $i = 0; $first_row = false; |
| 1814 | } |
| 1815 | |
| 1816 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 1817 | $class = 'cap-no'; |
| 1818 | else |
| 1819 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 1820 | |
| 1821 | $title_text = ''; |
| 1822 | |
| 1823 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 1824 | $class .= ' cap-metagroup'; |
| 1825 | $title_text = sprintf( esc_html__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1826 | $tool_tip = sprintf(__( '%s: assigned by Permission Group', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1827 | } else { |
| 1828 | $tool_tip = sprintf(__( 'This capability is %s', 'capability-manager-enhanced' ), '<strong>' . $cap_name . '</strong>' ); |
| 1829 | } |
| 1830 | |
| 1831 | $disabled = ''; |
| 1832 | $checked = !empty($rcaps[$cap_name]) ? 'checked' : ''; |
| 1833 | |
| 1834 | if ( 'manage_capabilities' == $cap_name ) { |
| 1835 | if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) { |
| 1836 | continue; |
| 1837 | } elseif ( 'administrator' == $default ) { |
| 1838 | $class .= ' cap-locked'; |
| 1839 | $lock_manage_caps_capability = true; |
| 1840 | $disabled = ' disabled '; |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | $caps_empty = false; |
| 1845 | |
| 1846 | $tooltip_html = ' |
| 1847 | <div class="tool-tip-text"> |
| 1848 | <p>'. $tool_tip .'</p> |
| 1849 | <i></i> |
| 1850 | </div> |
| 1851 | '; |
| 1852 | ?> |
| 1853 | <td class="<?php echo esc_attr($class); ?>"><span class="ppc-tool-tip disabled cap-x">X</span><span class="ppc-tool-tip disabled"><label><input type="checkbox" name="caps[<?php echo esc_attr($cap_name); ?>]" class="pp-single-action-rotate" autocomplete="off" value="1" <?php echo esc_attr($checked) . ' ' . esc_attr($disabled);?> /> |
| 1854 | <span> |
| 1855 | <?php |
| 1856 | echo esc_html(str_replace( '_', ' ', $cap )); |
| 1857 | ?> |
| 1858 | <?php echo $tooltip_html; ?> |
| 1859 | </span></label><?php if ( ! empty($title_text) ) :?><span class="tool-tip-text" style="text-align: center;"> |
| 1860 | <p><?php echo $title_text; ?></p> |
| 1861 | <i></i> |
| 1862 | </span><?php endif;?></span><a href="#" class="neg-cap" style="visibility: hidden;"> x </a> |
| 1863 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 1864 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo esc_attr($cap_name); ?>]" value="" /> |
| 1865 | <?php endif; ?> |
| 1866 | </td> |
| 1867 | <?php |
| 1868 | $i++; |
| 1869 | $additional_rendered_count++; |
| 1870 | endforeach; |
| 1871 | |
| 1872 | if ( ! empty($lock_manage_caps_capability) ) { |
| 1873 | echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />'; |
| 1874 | } |
| 1875 | |
| 1876 | if ( $i == $checks_per_row ) { |
| 1877 | echo '</tr><tr>'; |
| 1878 | $i = 0; |
| 1879 | } else { |
| 1880 | if ( ! $first_row ) { |
| 1881 | // Now close a wellformed table |
| 1882 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 1883 | echo '<td> </td>'; |
| 1884 | } |
| 1885 | echo '</tr>'; |
| 1886 | } |
| 1887 | } |
| 1888 | ?> |
| 1889 | <?php if ($caps_empty) : ?> |
| 1890 | <tr> |
| 1891 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1892 | <div> |
| 1893 | <?php esc_html_e( 'You have no additional capabilities.', 'capability-manager-enhanced' ); ?> |
| 1894 | </div> |
| 1895 | </td> |
| 1896 | </tr> |
| 1897 | <?php endif; ?> |
| 1898 | <tr class="cme-bulk-select"> |
| 1899 | <td colspan="<?php echo (int) $checks_per_row;?>"> |
| 1900 | <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php esc_attr_e('check / uncheck / negate all', 'capability-manager-enhanced');?>"> <span><?php _e('Capability Name', 'capability-manager-enhanced');?></span> |
| 1901 | </td> |
| 1902 | </tr> |
| 1903 | |
| 1904 | </table> |
| 1905 | </div> |
| 1906 | |
| 1907 | <div class="capabilities-sidebar pp-column-right"> |
| 1908 | <?php |
| 1909 | do_action('publishpress-caps_sidebar_top'); |
| 1910 | |
| 1911 | $banners = new PublishPress\WordPressBanners\BannersMain; |
| 1912 | |
| 1913 | $banner_messages = []; |
| 1914 | $banner_messages[] = esc_html__('Capabilities allows you change the permissions for any user role.', 'capability-manager-enhanced'); |
| 1915 | $banner_messages[] = sprintf(esc_html__('%1$s = Capability granted %2$s', 'capability-manager-enhanced'), '<table class="pp-capabilities-cb-key"><tr><td class="pp-cap-icon pp-cap-icon-checked"><input type="checkbox" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'" checked disabled></td><td>', '</td></tr>'); |
| 1916 | $banner_messages[] = sprintf(esc_html__('%1$s = Capability not granted %2$s', 'capability-manager-enhanced'), '<tr><td class="pp-cap-icon"><input type="checkbox" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'" disabled></td><td class="pp-cap-not-checked-definition">', '</td></tr>'); |
| 1917 | $banner_messages[] = sprintf(esc_html__('%1$s = Capability denied, even if granted by another role %2$s', 'capability-manager-enhanced'), '<tr><td class="pp-cap-icon pp-cap-x"><span class="cap-x pp-cap-key" title="'. esc_attr__('usage key', 'capability-manager-enhanced') .'">X</span></td><td class="cap-x-definition">', '</td></tr></table>'); |
| 1918 | if (!$is_application_password && defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) { |
| 1919 | if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) { |
| 1920 | $additional_message = sprintf( |
| 1921 | // back compat with existing language string |
| 1922 | str_replace( |
| 1923 | ['<strong>', '</strong>'], |
| 1924 | ['<strong>', '</strong>'], |
| 1925 | esc_html__('You can also configure this role as a %sPermission Group%s.', 'capability-manager-enhanced') |
| 1926 | ), |
| 1927 | '<a href="' . esc_url_raw(admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}")) . '">', |
| 1928 | '</a>' |
| 1929 | ); |
| 1930 | $banner_messages[] = '<p class="cme-subtext">' . $additional_message . '</p>'; |
| 1931 | } |
| 1932 | } |
| 1933 | |
| 1934 | ?> |
| 1935 | <div class="ppc-sidebar-panel-metabox meta-box-sortables"> |
| 1936 | <?php $meta_box_state = (isset($sidebar_metabox_state['how_to_user_capabilities'])) ? $sidebar_metabox_state['how_to_user_capabilities'] : 'closed'; ?> |
| 1937 | <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>"> |
| 1938 | <input |
| 1939 | name="ppc_metabox_state[how_to_user_capabilities]" |
| 1940 | type="hidden" |
| 1941 | class="metabox-state" |
| 1942 | value="<?php echo esc_attr($meta_box_state); ?>" |
| 1943 | /> |
| 1944 | <div class="postbox-header"> |
| 1945 | <h2 class="hndle ui-sortable-handle"><?php esc_html_e('How to use Capabilities', 'capability-manager-enhanced'); ?></h2> |
| 1946 | <div class="handle-actions"> |
| 1947 | <button type="button" class="handlediv"> |
| 1948 | <span class="toggle-indicator"></span> |
| 1949 | </button> |
| 1950 | </div> |
| 1951 | </div> |
| 1952 | <div class="inside"> |
| 1953 | <?php |
| 1954 | $banners->pp_display_banner( |
| 1955 | '', |
| 1956 | '', |
| 1957 | $banner_messages, |
| 1958 | 'https://publishpress.com/knowledge-base/capabilities-screen/', |
| 1959 | __('View Documentation', 'capability-manager-enhanced'), |
| 1960 | '', |
| 1961 | 'button ppc-checkboxes-documentation-link' |
| 1962 | ); |
| 1963 | ?> |
| 1964 | </div> |
| 1965 | </div> |
| 1966 | </div> |
| 1967 | |
| 1968 | <?php |
| 1969 | $pp_ui->pp_types_ui( $defined['type'] ); |
| 1970 | $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] ); |
| 1971 | ?> |
| 1972 | |
| 1973 | <div class="ppc-sidebar-panel-metabox meta-box-sortables ppc-safe"> |
| 1974 | <?php $meta_box_state = (isset($sidebar_metabox_state['capabilities_safe_to_use'])) ? $sidebar_metabox_state['capabilities_safe_to_use'] : 'closed'; ?> |
| 1975 | <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>"> |
| 1976 | <input |
| 1977 | name="ppc_metabox_state[capabilities_safe_to_use]" |
| 1978 | type="hidden" |
| 1979 | class="metabox-state" |
| 1980 | value="<?php echo esc_attr($meta_box_state); ?>" |
| 1981 | /> |
| 1982 | <div class="postbox-header"> |
| 1983 | <h2 class="hndle ui-sortable-handle"><?php esc_html_e( 'Capabilities is Safe to Use', 'capability-manager-enhanced' ); ?></h2> |
| 1984 | <div class="handle-actions"> |
| 1985 | <button type="button" class="handlediv"> |
| 1986 | <span class="toggle-indicator"></span> |
| 1987 | </button> |
| 1988 | </div> |
| 1989 | </div> |
| 1990 | <div class="inside"> |
| 1991 | <?php |
| 1992 | $banners->pp_display_banner( |
| 1993 | '', |
| 1994 | '', |
| 1995 | array( |
| 1996 | __( 'WordPress stores role capabilities in your database, where they remain even if the plugin is deactivated.', 'capability-manager-enhanced' ), |
| 1997 | __( 'Whenever you use PublishPress Capabilities to save changes, it also creates a backup which you can use to restore a previous configuration.', 'capability-manager-enhanced' ) |
| 1998 | ), |
| 1999 | admin_url( 'admin.php?page=pp-capabilities-backup' ), |
| 2000 | __( 'Go to the Backup feature', 'capability-manager-enhanced' ), |
| 2001 | '', |
| 2002 | 'button' |
| 2003 | ); |
| 2004 | ?> |
| 2005 | </div> |
| 2006 | </div> |
| 2007 | </div> |
| 2008 | |
| 2009 | <?php if (!$is_application_password) : ?> |
| 2010 | <div class="ppc-sidebar-panel-metabox meta-box-sortables ppc-add-cap"> |
| 2011 | <?php $meta_box_state = (isset($sidebar_metabox_state['add_capability'])) ? $sidebar_metabox_state['add_capability'] : 'closed'; ?> |
| 2012 | <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>"> |
| 2013 | <input |
| 2014 | name="ppc_metabox_state[add_capability]" |
| 2015 | type="hidden" |
| 2016 | class="metabox-state" |
| 2017 | value="<?php echo esc_attr($meta_box_state); ?>" |
| 2018 | /> |
| 2019 | <div class="postbox-header"> |
| 2020 | <h2 class="hndle ui-sortable-handle"><?php esc_html_e('Add a New Capability', 'capability-manager-enhanced'); ?></h2> |
| 2021 | <div class="handle-actions"> |
| 2022 | <button type="button" class="handlediv"> |
| 2023 | <span class="toggle-indicator"></span> |
| 2024 | </button> |
| 2025 | </div> |
| 2026 | </div> |
| 2027 | <div class="inside" style="text-align:center;"> |
| 2028 | <p> |
| 2029 | <input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br /> |
| 2030 | <input type="submit" name="AddCap" value="<?php esc_attr_e('Add to role', 'capability-manager-enhanced') ?>" class="button" /> |
| 2031 | </p> |
| 2032 | <br /> |
| 2033 | <div class="cme-subtext"><?php _e('New capabilities are controlled on the Additonal tab.', 'capability-manager-enhanced');?></div> |
| 2034 | </div> |
| 2035 | </div> |
| 2036 | </div> |
| 2037 | <?php endif; ?> |
| 2038 | |
| 2039 | <?php if (!$is_application_password && is_multisite() && is_super_admin() && is_main_site()) : ?> |
| 2040 | <div class="ppc-sidebar-panel-metabox meta-box-sortables ppc-multi-site"> |
| 2041 | <?php $meta_box_state = (isset($sidebar_metabox_state['multi_site'])) ? $sidebar_metabox_state['multi_site'] : 'closed'; ?> |
| 2042 | <div class="postbox ppc-sidebar-panel <?php echo esc_attr($meta_box_state); ?>"> |
| 2043 | <input |
| 2044 | name="ppc_metabox_state[multi_site]" |
| 2045 | type="hidden" |
| 2046 | class="metabox-state" |
| 2047 | value="<?php echo esc_attr($meta_box_state); ?>" |
| 2048 | /> |
| 2049 | <div class="postbox-header"> |
| 2050 | <h2 class="hndle ui-sortable-handle"><?php esc_html_e('Multisite', 'capability-manager-enhanced'); ?></h2> |
| 2051 | <div class="handle-actions"> |
| 2052 | <button type="button" class="handlediv"> |
| 2053 | <span class="toggle-indicator"></span> |
| 2054 | </button> |
| 2055 | </div> |
| 2056 | </div> |
| 2057 | <div class="inside"> |
| 2058 | <?php cme_network_role_ui( $default ); ?> |
| 2059 | </div> |
| 2060 | </div> |
| 2061 | </div> |
| 2062 | <?php endif; ?> |
| 2063 | |
| 2064 | <?php |
| 2065 | do_action('publishpress-caps_sidebar_bottom'); |
| 2066 | ?> |
| 2067 | |
| 2068 | </div><!-- right sidebar within tab panel --> |
| 2069 | </div> |
| 2070 | </div> |
| 2071 | |
| 2072 | |
| 2073 | <script type="text/javascript"> |
| 2074 | /* <![CDATA[ */ |
| 2075 | jQuery(document).ready( function($) { |
| 2076 | $('a[href="#pp-more"]').click( function() { |
| 2077 | $('#pp_features').show(); |
| 2078 | return false; |
| 2079 | }); |
| 2080 | $('a[href="#pp-hide"]').click( function() { |
| 2081 | $('#pp_features').hide(); |
| 2082 | return false; |
| 2083 | }); |
| 2084 | }); |
| 2085 | /* ]]> */ |
| 2086 | </script> |
| 2087 | |
| 2088 | <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?> |
| 2089 | |
| 2090 | <div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo esc_url_raw($img_url);?>pp-logo.png" alt="<?php esc_attr_e('PublishPress Permissions', 'capability-manager-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features"> |
| 2091 | <li> |
| 2092 | <?php esc_html_e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capability-manager-enhanced' );?> |
| 2093 | <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> |
| 2094 | |
| 2095 | <li> |
| 2096 | <?php esc_html_e( "Assign standard WP roles supplementally for a specific post type", 'capability-manager-enhanced' );?> |
| 2097 | <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> |
| 2098 | |
| 2099 | <li> |
| 2100 | <?php esc_html_e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2101 | </li> |
| 2102 | |
| 2103 | <li> |
| 2104 | <?php esc_html_e( "Customize reading permissions per-category or per-post", 'capability-manager-enhanced' );?> |
| 2105 | <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> |
| 2106 | |
| 2107 | <li> |
| 2108 | <?php esc_html_e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2109 | <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> |
| 2110 | |
| 2111 | <li> |
| 2112 | <?php esc_html_e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2113 | <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> |
| 2114 | |
| 2115 | <li> |
| 2116 | <?php esc_html_e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2117 | <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> |
| 2118 | |
| 2119 | <li> |
| 2120 | <?php esc_html_e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2121 | <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> |
| 2122 | |
| 2123 | <li> |
| 2124 | <?php esc_html_e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2125 | <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> |
| 2126 | |
| 2127 | <li> |
| 2128 | <?php esc_html_e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2129 | </li> |
| 2130 | |
| 2131 | <li> |
| 2132 | <?php esc_html_e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2133 | <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> |
| 2134 | |
| 2135 | <li> |
| 2136 | <?php esc_html_e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capability-manager-enhanced' );?> |
| 2137 | </li> |
| 2138 | |
| 2139 | <li> |
| 2140 | <?php esc_html_e( "Member support forum", 'capability-manager-enhanced' );?> |
| 2141 | </li> |
| 2142 | |
| 2143 | </ul></div> |
| 2144 | |
| 2145 | <?php |
| 2146 | echo '<div>'; |
| 2147 | printf( esc_html__('%1$sgrab%2$s %3$s', 'capability-manager-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . esc_url_raw(cme_plugin_info_url('press-permit-core')) . '" class="thickbox" title="' . sprintf( esc_attr__('%s (free install)', 'capability-manager-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' ); |
| 2148 | echo ' • '; |
| 2149 | printf( esc_html__('%1$sbuy%2$s %3$s', 'capability-manager-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( esc_attr__('%s info/purchase', 'capability-manager-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a>' ); |
| 2150 | echo ' • '; |
| 2151 | echo '<a href="#pp-hide">hide</a>'; |
| 2152 | echo '</div></div>'; |
| 2153 | |
| 2154 | /// |
| 2155 | ?> |
| 2156 | <script type="text/javascript"> |
| 2157 | /* <![CDATA[ */ |
| 2158 | jQuery(document).ready( function($) { |
| 2159 | $('a[href="#toggle_type_caps"]').click( function() { |
| 2160 | var chks = $(this).closest('tr').find('input'); |
| 2161 | var set_checked = ! $(chks).first().is(':checked'); |
| 2162 | |
| 2163 | $(chks).each(function(i,e) { |
| 2164 | $('input[name="' + $(this).attr('name') + '"]').prop('checked', set_checked); |
| 2165 | }); |
| 2166 | |
| 2167 | return false; |
| 2168 | }); |
| 2169 | |
| 2170 | $('input[name^="caps["]').click(function() { |
| 2171 | $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked')); |
| 2172 | }); |
| 2173 | }); |
| 2174 | /* ]]> */ |
| 2175 | </script> |
| 2176 | |
| 2177 | <?php if (!$is_application_password) : ?> |
| 2178 | <div style="display:none; float:right;"> |
| 2179 | <?php |
| 2180 | $level = ak_caps2level($rcaps); |
| 2181 | ?> |
| 2182 | <span title="<?php esc_attr_e('Role level is mostly deprecated. However, it still determines eligibility for Post Author assignment and limits the application of user editing capabilities.', 'capability-manager-enhanced');?>"> |
| 2183 | |
| 2184 | <?php (in_array(get_locale(), ['en_EN', 'en_US'])) ? printf('Role Level:') : esc_html_e('Level:', 'capability-manager-enhanced');?> <select name="level"> |
| 2185 | <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?> |
| 2186 | <option value="<?php echo (int) $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>> <?php echo (int) $l; ?> </option> |
| 2187 | <?php } |
| 2188 | ?> |
| 2189 | </select> |
| 2190 | </span> |
| 2191 | |
| 2192 | </div> |
| 2193 | <?php endif; ?> |
| 2194 | |
| 2195 | <p class="submit" style="padding-top:0;"> |
| 2196 | <input type="hidden" name="action" value="update" /> |
| 2197 | <input type="hidden" name="current" value="<?php echo esc_attr($default); ?>" /> |
| 2198 | |
| 2199 | <?php |
| 2200 | $save_caption = (in_array(sanitize_key(get_locale()), ['en_EN', 'en_US'])) ? 'Save Capabilities' : esc_html__('Save Changes'); |
| 2201 | ?> |
| 2202 | <input type="submit" name="SaveRole" value="<?php echo esc_attr($save_caption);?>" class="button-primary" style="float: right;" /> |
| 2203 | </p> |
| 2204 | |
| 2205 | </div><!-- .pp-column-left --> |
| 2206 | </div><!-- .pp-columns-wrapper --> |
| 2207 | </td></tr></table> <!-- .akmin --> |
| 2208 | </fieldset> |
| 2209 | </form> |
| 2210 | |
| 2211 | <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) { |
| 2212 | cme_publishpressFooter(); |
| 2213 | } |
| 2214 | ?> |
| 2215 | </div> |
| 2216 | |
| 2217 | <?php |
| 2218 | function cme_network_role_ui( $default ) { |
| 2219 | if (!is_multisite() || !is_super_admin() || !is_main_site()) { |
| 2220 | return false; |
| 2221 | } |
| 2222 | ?> |
| 2223 | <?php |
| 2224 | if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) ) |
| 2225 | $autocreate_roles = array(); |
| 2226 | ?> |
| 2227 | <div style="margin-bottom: 5px"> |
| 2228 | <label for="cme_autocreate_role" title="<?php esc_attr_e('Create this role definition in new (future) sites', 'capability-manager-enhanced');?>"><input type="checkbox" name="cme_autocreate_role" id="cme_autocreate_role" autocomplete="off" value="1" <?php echo checked(in_array($default, $autocreate_roles));?>> <?php esc_html_e('Include in new sites.', 'capability-manager-enhanced'); ?> </label> |
| 2229 | </div> |
| 2230 | <div> |
| 2231 | <label for="cme_net_sync_role" title="<?php echo esc_attr__('Copy / update this role definition to all sites now', 'capability-manager-enhanced');?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" autocomplete="off" value="1"> <?php esc_html_e('Sync role to all sites.', 'capability-manager-enhanced'); ?> </label> |
| 2232 | </div> |
| 2233 | <div> |
| 2234 | <label for="cme_net_sync_options" title="<?php echo esc_attr__('Copy option settings to all sites now', 'capability-manager-enhanced');?>"><input type="checkbox" name="cme_net_sync_options" id="cme_net_sync_options" autocomplete="off" value="1"> <?php esc_html_e('Sync options to all sites.', 'capability-manager-enhanced'); ?> </label> |
| 2235 | </div> |
| 2236 | <?php |
| 2237 | return true; |
| 2238 | } |
| 2239 | |
| 2240 | function cme_plugin_info_url( $plugin_slug ) { |
| 2241 | $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678"; |
| 2242 | return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url); |
| 2243 | } |
| 2244 |