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