PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.9
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.9
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / includes / backup-handler.php
capability-manager-enhanced / includes Last commit date
admin.php 6 years ago backup-handler.php 7 years ago backup.php 6 years ago cap-helper.php 6 years ago filters-admin.php 6 years ago filters-woocommerce.php 7 years ago filters-wp_rest_workarounds.php 6 years ago filters.php 6 years ago functions-admin.php 6 years ago functions.php 6 years ago handler.php 6 years ago inflect-cme.php 7 years ago manager.php 6 years ago network.php 6 years ago pp-handler.php 6 years ago pp-ui.php 6 years ago publishpress-roles.php 6 years ago
backup-handler.php
115 lines
1 <?php
2
3 class Capsman_BackupHandler
4 {
5 var $cm;
6
7 function __construct( $manager_obj ) {
8 if ( ! is_super_admin() && ! current_user_can( 'restore_roles' ) )
9 wp_die( __( 'You do not have permission to restore roles.', 'capsman-enhanced' ) );
10
11 $this->cm = $manager_obj;
12 }
13
14 /**
15 * Processes backups and restores.
16 *
17 * @return void
18 */
19 function processBackupTool ()
20 {
21 if ( isset($_POST['Perform']) ) {
22 check_admin_referer('capsman-backup-tool');
23
24 global $wpdb;
25 $wp_roles = $wpdb->prefix . 'user_roles';
26 $cm_roles = $this->cm->ID . '_backup';
27 $cm_roles_initial = $this->cm->ID . '_backup_initial';
28
29 switch ( $_POST['action'] ) {
30 case 'backup':
31 if ( ! get_option( $cm_roles_initial ) ) {
32 if ( $current_backup = get_option( $cm_roles ) ) {
33 update_option( $cm_roles_initial, $current_backup, false );
34
35 if ( $initial_datestamp = get_option( $this->cm->ID . '_backup_datestamp' ) ) {
36 update_option($this->cm->ID . '_backup_initial_datestamp', $initial_datestamp, false );
37 }
38 }
39 }
40
41 $roles = get_option($wp_roles);
42 update_option($cm_roles, $roles, false);
43 update_option($this->cm->ID . '_backup_datestamp', current_time( 'timestamp' ), false );
44 ak_admin_notify(__('New backup saved.', 'capsman-enhanced'));
45 break;
46
47 case 'restore_initial':
48 $roles = get_option($cm_roles_initial);
49 if ( $roles ) {
50 update_option($wp_roles, $roles);
51 ak_admin_notify(__('Roles and Capabilities restored from initial backup.', 'capsman-enhanced'));
52 } else {
53 ak_admin_error(__('Restore failed. No backup found.', 'capsman-enhanced'));
54 }
55 break;
56
57 case 'restore':
58 $roles = get_option($cm_roles);
59 if ( $roles ) {
60 update_option($wp_roles, $roles);
61 ak_admin_notify(__('Roles and Capabilities restored from last backup.', 'capsman-enhanced'));
62 } else {
63 ak_admin_error(__('Restore failed. No backup found.', 'capsman-enhanced'));
64 }
65 break;
66 }
67 }
68 }
69
70 /**
71 * Resets roles to WordPress defaults.
72 *
73 * @return void
74 */
75 function backupToolReset ()
76 {
77 check_admin_referer('capsman-reset-defaults');
78
79 require_once(ABSPATH . 'wp-admin/includes/schema.php');
80
81 if ( ! function_exists('populate_roles') ) {
82 ak_admin_error(__('Needed function to create default roles not found!', 'capsman-enhanced'));
83 return;
84 }
85
86 $roles = array_keys( ak_get_roles(true) );
87
88 foreach ( $roles as $role) {
89 remove_role($role);
90 }
91
92 populate_roles();
93 $this->cm->setAdminCapability();
94
95 $msg = __('Roles and Capabilities reset to WordPress defaults', 'capsman-enhanced');
96
97 if ( function_exists( 'pp_populate_roles' ) ) {
98 pp_populate_roles();
99 } else {
100 // force PP to repopulate roles
101 $pp_ver = get_option( 'pp_c_version', true );
102 if ( $pp_ver && is_array($pp_ver) ) {
103 $pp_ver['version'] = ( preg_match( "/dev|alpha|beta|rc/i", $pp_ver['version'] ) ) ? '0.1-beta' : 0.1;
104 } else {
105 $pp_ver = array( 'version' => '0.1', 'db_version' => '1.0' );
106 }
107
108 update_option( 'pp_c_version', $pp_ver );
109 delete_option( 'ppperm_added_role_caps_10beta' );
110 }
111
112 ak_admin_notify($msg);
113 }
114 }
115