PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.27
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.27
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / uninstall.php

uninstall.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.27, at uninstall.php

102 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall UsersWP
4 *
5 * Uninstalling UsersWP deletes tables and plugin options.
6 *
7 * @package userswp
8 * @since 1.0.0
9 */
10
11 // Exit if accessed directly.
12 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13 exit;
14 }
15
16 global $wpdb;
17
18 $wpdb->hide_errors();
19
20 if ( is_multisite() ) {
21 $main_site = get_network()->site_id;
22 $sql = "SELECT blog_id FROM $wpdb->blogs
23 WHERE archived = '0' AND spam = '0'
24 AND deleted = '0'";
25
26 $blog_ids = $wpdb->get_col( $sql );
27
28 foreach ( $blog_ids as $blog_id ) {
29 switch_to_blog( $blog_id );
30 uwp_uninstall();
31 }
32 switch_to_blog( $main_site );
33 uwp_drop_usermeta_table();
34 restore_current_blog();
35 } else {
36 uwp_uninstall();
37 uwp_drop_usermeta_table();
38 }
39
40 function uwp_uninstall() {
41 $uwp_options = get_option( 'uwp_settings' );
42 if ( isset($uwp_options['uninstall_erase_data']) && $uwp_options['uninstall_erase_data'] == '1' ) {
43 global $wpdb;
44
45 $table_name = $wpdb->prefix . 'uwp_form_fields';
46 $rows = $wpdb->get_results( "select * from " . $table_name . "" );
47
48 // Delete user meta for all users
49 $meta_type = 'user';
50 $user_id = 0; // This will be ignored, since we are deleting for all users.
51 $meta_value = ''; // Also ignored. The meta will be deleted regardless of value.
52 $delete_all = true;
53
54 foreach ( $rows as $row ) {
55 delete_metadata( $meta_type, $user_id, $row->htmlvar_name, $meta_value, $delete_all );
56 }
57
58 // Drop form fields table
59 $table_name = $wpdb->prefix . 'uwp_form_fields';
60 $sql = "DROP TABLE IF EXISTS $table_name";
61 $wpdb->query( $sql );
62
63 // Drop form extras table
64 $extras_table_name = $wpdb->prefix . 'uwp_form_extras';
65 $sql = "DROP TABLE IF EXISTS $extras_table_name";
66 $wpdb->query( $sql );
67
68 // Drop form profile tabs table
69 $profile_table_name = $wpdb->prefix . 'uwp_profile_tabs';
70 $sql = "DROP TABLE IF EXISTS $profile_table_name";
71 $wpdb->query( $sql );
72
73 // Drop user sorting table
74 $sorting_table_name = $wpdb->prefix . 'uwp_user_sorting';
75 $sql = "DROP TABLE IF EXISTS $sorting_table_name";
76 $wpdb->query( $sql );
77
78 // Delete pages
79 $pages = array( 'register_page', 'login_page', 'profile_page', 'account_page', 'change_page', 'forgot_page', 'reset_page', 'users_page', 'user_list_item_page');
80
81 foreach ($pages as $page){
82 if(isset($uwp_options[$page]) && !empty($uwp_options[$page])){
83 wp_delete_post( $uwp_options[$page], true );
84 }
85 }
86
87 // Delete options
88 delete_option( 'uwp_settings' );
89 delete_option( 'uwp_activation_redirect' );
90 delete_option( 'uwp_flush_rewrite' );
91 delete_option( 'uwp_default_data_installed' );
92 delete_option( 'uwp_db_version' );
93 }
94 }
95
96 function uwp_drop_usermeta_table() {
97 global $wpdb;
98 // Drop usermeta table
99 $meta_table_name = $wpdb->prefix . 'uwp_usermeta';
100 $sql = "DROP TABLE IF EXISTS $meta_table_name";
101 $wpdb->query( $sql );
102 }