本文整理汇总了PHP中WP_Roles::remove_cap方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Roles::remove_cap方法的具体用法?PHP WP_Roles::remove_cap怎么用?PHP WP_Roles::remove_cap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Roles
的用法示例。
在下文中一共展示了WP_Roles::remove_cap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
/**
* Adds plugin-specific caps to all roles so that 3rd party plugins can manage them
*/
function add_caps()
{
$version = get_option('post_forking_cap_version');
// Bail Early if we have already set the caps and aren't updating them
if ($version !== false && $this->cap_version <= (int) $version) {
return;
}
add_option('post_forking_cap_version', $this->cap_version, '', 'yes');
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
foreach ($wp_roles->role_names as $role => $label) {
//if the role is a standard role, map the default caps, otherwise, map as a subscriber
$caps = array_key_exists($role, $this->defaults) ? $this->defaults[$role] : $this->defaults['subscriber'];
//loop and assign
foreach ($caps as $cap => $grant) {
//check to see if the user already has this capability, if so, don't re-add as that would override grant
if (!isset($wp_roles->roles[$role]['capabilities'][$cap])) {
$wp_roles->add_cap($role, $cap, $grant);
} else {
$wp_roles->remove_cap($role, $cap);
$wp_roles->add_cap($role, $cap, $grant);
}
}
}
}
示例2: handle_rhc_uninstall
function handle_rhc_uninstall()
{
$WP_Roles = new WP_Roles();
foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
$WP_Roles->remove_cap(RHC_ADMIN_ROLE, $cap);
}
//-----
}
示例3: wlb_uninstall
function wlb_uninstall()
{
$WP_Roles = new WP_Roles();
foreach (array('wlb_branding', 'wlb_navigation', 'wlb_login', 'wlb_color_scheme', 'wlb_options', 'wlb_role_manager', 'wlb_license', 'wlb_downloads', 'wlb_dashboard_tool') as $cap) {
$WP_Roles->remove_cap(WLB_ADMIN_ROLE, $cap);
}
//-----
}
示例4: handle_rhc_uninstall
function handle_rhc_uninstall()
{
$WP_Roles = new WP_Roles();
foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE . 's', 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
$WP_Roles->remove_cap(RHC_ADMIN_ROLE, $cap);
}
//-----
delete_site_transient('update_plugins');
delete_option('rhc_dismiss_help_notice');
$filename = get_home_path() . '.htaccess';
if (file_exists($filename)) {
insert_with_markers($filename, 'RHC', array());
}
}
示例5: disable_all_caps
public function disable_all_caps()
{
global $wp_roles;
if (!isset($wp_roles) || !is_object($wp_roles)) {
$wp_roles = new WP_Roles();
}
$ddl_capabilities = array_keys(self::ddl_get_capabilities());
foreach ($ddl_capabilities as $cap) {
foreach (array_keys($wp_roles->roles) as $role) {
$wp_roles->remove_cap($role, $cap);
}
}
//Remove caps for all Super Admins
$super_admins = get_super_admins();
foreach ($super_admins as $admin) {
$user = new WP_User($admin);
for ($i = 0, $caps_limit = count($ddl_capabilities); $i < $caps_limit; $i++) {
$user->remove_cap($ddl_capabilities[$i]);
}
}
$this->ddl_users_settings->update_options('updated_profiles', false, true);
}
示例6: un_deactivation_hook
function un_deactivation_hook()
{
delete_option('un_version');
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
foreach (un_get_capable_roles() as $role) {
foreach (un_get_feedback_capabilities() as $cap) {
$wp_roles->remove_cap($role, $cap);
}
}
flush_rewrite_rules();
}
示例7: disable_all_caps
public function disable_all_caps()
{
global $wp_roles;
if (!isset($wp_roles) || !is_object($wp_roles)) {
$wp_roles = new WP_Roles();
}
$wpcf_capabilities = array_keys(self::wpcf_get_capabilities());
foreach ($wpcf_capabilities as $cap) {
foreach (array_keys($wp_roles->roles) as $role) {
$wp_roles->remove_cap($role, $cap);
}
}
//Remove caps for all Super Admins
$super_admins = get_super_admins();
foreach ($super_admins as $admin) {
$user = new WP_User($admin);
for ($i = 0, $caps_limit = count($wpcf_capabilities); $i < $caps_limit; $i++) {
$user->remove_cap($wpcf_capabilities[$i]);
}
}
}
示例8: rbhn_role_caps_uninstall
function rbhn_role_caps_uninstall( $role_key ) {
$post_types_array = get_option( 'rbhn_post_types' );
if ( ! empty( $post_types_array ) ) {
foreach( $post_types_array as $array ) {
foreach( $array as $active_role=>$active_posttype ) {
if ( $role_key == $active_role ) {
$role = get_role( $active_role );
$capability_type = $active_posttype;
}
}
}
}
// if no post type found drop out.
if ( empty( $capability_type ) )
return;
$delete_caps = array(
"edit_{$capability_type}",
"read_{$capability_type}",
"delete_{$capability_type}",
"edit_{$capability_type}s",
"edit_others_{$capability_type}s",
"publish_{$capability_type}s",
"read_private_{$capability_type}s",
"delete_{$capability_type}s",
"delete_private_{$capability_type}s",
"delete_published_{$capability_type}s",
"delete_others_{$capability_type}s",
"edit_private_{$capability_type}s",
"edit_published_{$capability_type}s",
"create_{$capability_type}s",
"manage_categories_{$capability_type}"
);
global $wp_roles;
if ( ! isset( $wp_roles ) ) {
$wp_roles = new WP_Roles( );
}
$users = get_users( );
$administrator = get_role( 'administrator' );
// loop through the capability list.
foreach ( $delete_caps as $cap ) {
// Clean-up Capability from WordPress Roles
foreach ( array_keys( $wp_roles->roles ) as $role ) {
$wp_roles->remove_cap( $role, $cap );
}
// Clean-up Capability from WordPress Users where explicitly allocated
foreach ( $users as $user ) {
$user->remove_cap( $cap );
}
// Clean-up Capability from the Administrator Role
$administrator->remove_cap( $cap );
}
unset( $wp_roles );
}
示例9: foreach
/* @TODO: delete all transient, options and files you may have added
delete_transient( 'TRANSIENT_NAME' );
delete_option('OPTION_NAME');
//info: remove custom file directory for main site
$upload_dir = wp_upload_dir();
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
if (is_dir($directory)) {
foreach(glob($directory.'*.*') as $v){
unlink($v);
}
rmdir($directory);
}
//info: remove and optimize tables
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
*/
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
foreach ($wp_roles->role_names as $role => $label) {
//if the role is a standard role, map the default caps, otherwise, map as a subscriber
$caps = array_key_exists($role, $plugin_roles) ? $plugin_roles[$role] : $plugin_roles['subscriber'];
//loop and assign
foreach ($caps as $cap => $grant) {
//check to see if the user already has this capability, if so, don't re-add as that would override grant
if (!isset($wp_roles->roles[$role]['capabilities'][$cap])) {
$wp_roles->remove_cap($cap);
}
}
}
}
示例10:
function duplicate_roles_for_new_blog($blog_id, $user_id)
{
global $wpdb, $global, $wp_roles;
// get Id of 1st (main) blog
$blogIds = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} order by blog_id asc"));
if (!isset($blogIds[0])) {
return;
}
$current_blog = $wpdb->blogid;
switch_to_blog($blogIds[0]);
$main_roles = new WP_Roles();
// get roles from primary blog
$default_role = get_option('default_role');
// get default role from primary blog
switch_to_blog($blog_id);
// switch to the new created blog
$main_roles->use_db = false;
// do not touch DB
$main_roles->add_cap('administrator', 'dummy_123456');
// just to save current roles into new blog
$main_roles->role_key = $wp_roles->role_key;
$main_roles->use_db = true;
// save roles into new blog DB
$main_roles->remove_cap('administrator', 'dummy_123456');
// remove unneeded dummy capability
update_option('default_role', $default_role);
// set default role for new blog as it set for primary one
switch_to_blog($current_blog);
// return to blog where we were at the begin
}
示例11: foreach
/**
* Remove capabilities when a term is removed
* @param unknown $term
*/
function remove_caps($term)
{
$term_obj = get_term($term, $this->taxonomy);
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
foreach ($wp_roles->role_names as $role => $label) {
foreach ($this->base_caps as $base_cap) {
$wp_roles->remove_cap($role, $base_cap . '_in_' . $term_obj->slug);
}
}
}
示例12: removeCapability
public function removeCapability($role, $cap)
{
global $wp_roles;
/*
* Check to make sure $wp_roles has been initialized and set.
* If it hasn't it is initialized. This was done because this method
* can be called before the $wp_roles has been initialized.
*/
if (!isset($wp_roles))
{
$wp_roles = new WP_Roles();
}
//$wpRole = get_role($role);
if ($this->hasCapability($role, $cap)) $wp_roles->remove_cap($role, $cap);
}
示例13: remove_roles
/**
* Delete the roles and capabilities created by FUE
*/
public function remove_roles()
{
global $wp_roles;
if (class_exists('WP_Roles')) {
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
}
$capabilities = self::get_core_capabilities();
foreach ($capabilities as $cap_group) {
foreach ($cap_group as $cap) {
$wp_roles->remove_cap('fue_manager', $cap);
$wp_roles->remove_cap('administrator', $cap);
}
}
remove_role('fue_manager');
}
示例14: etm_uninstall_capabilities
function etm_uninstall_capabilities()
{
$caps = array();
$caps[] = 'etm_show_menu';
$caps[] = 'etm_translate_addon';
$caps[] = 'etm_translate_post';
$caps[] = 'etm_translate_category';
$caps[] = 'etm_translate_post_tag';
$caps[] = 'etm_translate_page';
$caps[] = 'etm_translate_menu';
$caps[] = 'etm_translate_seo';
$caps[] = 'etm_translate_theme';
$caps[] = 'etm_translate_plugin';
$caps[] = 'etm_options';
$caps[] = 'etm_license';
$caps[] = 'etm_string_create';
$caps[] = 'etm_view_addon';
$caps[] = 'etm_view_post';
$caps[] = 'etm_view_page';
$caps[] = 'etm_view_seo';
$caps[] = 'etm_view_menu';
$caps[] = 'etm_view_theme';
$caps[] = 'etm_view_plugin';
$caps[] = 'etm_view_site_options';
$caps[] = 'etm_translate_site_options';
//--
$WP_Roles = new WP_Roles();
foreach ($caps as $cap) {
$WP_Roles->remove_cap('administrator', $cap);
}
update_option('etm_options_plugin_tran', '');
update_option('etm_options_install', '');
}
示例15: deactivate
/**
* Deactivate the plugin
*/
public static function deactivate()
{
$WP_Roles = new WP_Roles();
foreach (array('chronosly_author', 'edit_' . CHRONOSLY_CAPABILITY_TYPE, 'read_' . CHRONOSLY_CAPABILITY_TYPE, 'delete_' . CHRONOSLY_CAPABILITY_TYPE, 'delete_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_others_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_published_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_published_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_private_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_others_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'publish_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'read_private_' . CHRONOSLY_CAPABILITY_TYPE . 's') as $cap) {
$WP_Roles->remove_cap(CHRONOSLY_ADMIN_ROLE, $cap);
}
delete_option("chronosly-settings");
wp_clear_scheduled_hook('chronosly_update_addons');
wp_clear_scheduled_hook('chronosly_update_templates');
}