<?php class URE_Uninstall { protected $lib = null; protected $options = null; protected $own_caps = null; public function __construct() { $this->lib = URE_Lib::get_instance(); $this->init_options_list(); $this->own_caps = array_keys( URE_Own_Capabilities::get_caps() ); } // end of __construct() protected function init_options_list() { $this->options = array(); $this->options[] = 'ure_caps_readable'; $this->options[] = 'ure_show_deprecated_caps'; $this->options[] = 'ure_hide_pro_banner'; $this->options[] = 'ure_role_additional_options_values'; $this->options[] = 'ure_task_queue'; $this->options[] = 'user_role_editor'; } // end fo init_options_list() private function delete_options() { global $wpdb; $backup_option_name = $wpdb->prefix . 'backup_user_roles'; delete_option( $backup_option_name ); foreach ( $this->options as $option_name ) { delete_option( $option_name ); } } // end of delete_options() private function delete_caps() { $wp_roles = wp_roles(); if ( $wp_roles->use_db ) { $wp_roles->use_db = false; // minimize database update requests $use_db = true; } else { $use_db = false; } foreach( $wp_roles->roles as $role_id=>$role ) { foreach( $this->own_caps as $cap ) { if ( isset( $role['capabilities'][ $cap ]) ) { $wp_roles->remove_cap( $role_id, $cap ); } } } if ( $use_db ) { // save changes to the database $wp_roles->add_cap( 'subscriber', 'dummy_cap' ); $wp_roles->use_db = true; // restore original value $wp_roles->remove_cap( 'subscriber', 'dummy_cap' ); } } // end of delete_caps() public function act() { global $wpdb; if ( !is_multisite() ) { $this->delete_options(); $this->delete_caps(); } else { $old_blog = $wpdb->blogid; $blog_ids = $this->lib->get_blog_ids(); foreach ( $blog_ids as $blog_id ) { switch_to_blog( $blog_id ); $this->delete_options(); $this->delete_caps(); } $this->lib->restore_after_blog_switching( $old_blog ); } } // end of act() } // end of class URE_Uninstall
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
admin-notice.php | File | 833 B | 0644 |
|
advertisement.php | File | 2.58 KB | 0644 |
|
ajax-processor.php | File | 10.92 KB | 0644 |
|
assign-role.php | File | 5.68 KB | 0644 |
|
base-lib.php | File | 11.04 KB | 0644 |
|
bbpress.php | File | 2.81 KB | 0644 |
|
capabilities-groups-manager.php | File | 17.76 KB | 0644 |
|
capabilities.php | File | 15.09 KB | 0644 |
|
capability.php | File | 8.14 KB | 0644 |
|
editor.php | File | 56.29 KB | 0644 |
|
grant-roles.php | File | 19.88 KB | 0644 |
|
known-js-css-compatibility-issues.php | File | 2.59 KB | 0644 |
|
lib.php | File | 17.6 KB | 0644 |
|
own-capabilities.php | File | 5.22 KB | 0644 |
|
protect-admin.php | File | 8.01 KB | 0644 |
|
role-additional-options.php | File | 4.02 KB | 0644 |
|
role-view.php | File | 17.06 KB | 0644 |
|
screen-help.php | File | 5.77 KB | 0644 |
|
settings.php | File | 9.03 KB | 0644 |
|
task-queue.php | File | 3.94 KB | 0644 |
|
tools.php | File | 3.77 KB | 0644 |
|
uninstall.php | File | 2.62 KB | 0644 |
|
user-other-roles.php | File | 13.59 KB | 0644 |
|
user-role-editor.php | File | 37.1 KB | 0644 |
|
user-view.php | File | 8.09 KB | 0644 |
|
view.php | File | 13.86 KB | 0644 |
|
woocommerce-capabilities.php | File | 5.8 KB | 0644 |
|