arc-hive-wordpress-plugin/includes/arcHIVE-delete-capabilities...

60 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Delete capabilities created in development and in plugin removal.
*
* @link https://arc-hive.zone
* @since 1.1.0
*
* @package archive_wpplugin
* @subpackage archive_wpplugin/includes
*/
/**
* Delete capabilities created in development and in plugin removal.
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.1.0
* @package archive_wpplugin
* @subpackage archive_wpplugin/includes
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
*/
// Function to delete capabilities
// Based on http://chrisburbridge.com/delete-unwanted-wordpress-custom-capabilities/
function clean_unwanted_caps() {
global $wp_roles;
$delete_caps = array(
'read_archive_resource',
'publish_archive_resources',
'edit_archive_resources',
'edit_archive_published_resources',
'edit_other_archive_resources',
'delete_archive_resources',
'delete_archive_published_resources',
'delete_archive_others_resources',
'delete_archive_private_resources',
'upload_media_files',
'manage_archive_resources_types',
'archive_read_resource',
'archive_publish_resources',
'archive_edit_resources',
'archive_edit_published_resources',
'archive_edit_other_resources',
'archive_delete_resources',
'archive_delete_published_resources',
'archive_delete_others_resources',
'archive_delete_private_resources',
'archive_upload_media_files',
'archive_manage_resources_types',
'archive_manage_resources_types'
);
foreach ($delete_caps as $cap) {
foreach (array_keys($wp_roles->roles) as $role) {
$wp_roles->remove_cap($role, $cap);
}
}
}
add_action( 'admin_init', 'clean_unwanted_caps' );
// register_activation_hook( __FILE__, 'archive_wpplugin_add_roles_on_plugin_activation' );