PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.1
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.1
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.1, at uninstall.php

99 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 ( $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_key = 'uwp_usermeta';
52 $meta_value = ''; // Also ignored. The meta will be deleted regardless of value.
53 $delete_all = true;
54
55 foreach ( $rows as $row ) {
56 delete_metadata( $meta_type, $user_id, $row->htmlvar_name, $meta_value, $delete_all );
57 }
58
59 // Drop form fields table
60 $table_name = $wpdb->prefix . 'uwp_form_fields';
61 $sql = "DROP TABLE IF EXISTS $table_name";
62 $wpdb->query( $sql );
63
64 // Drop form extras table
65 $extras_table_name = $wpdb->prefix . 'uwp_form_extras';
66 $sql = "DROP TABLE IF EXISTS $extras_table_name";
67 $wpdb->query( $sql );
68
69 // Drop form profile tabs table
70 $profile_table_name = $wpdb->prefix . 'uwp_profile_tabs';
71 $sql = "DROP TABLE IF EXISTS $profile_table_name";
72 $wpdb->query( $sql );
73
74 // Delete pages
75 wp_delete_post( $uwp_options['register_page'], true );
76 wp_delete_post( $uwp_options['login_page'], true );
77 wp_delete_post( $uwp_options['profile_page'], true );
78 wp_delete_post( $uwp_options['account_page'], true );
79 wp_delete_post( $uwp_options['change_page'], true );
80 wp_delete_post( $uwp_options['forgot_page'], true );
81 wp_delete_post( $uwp_options['reset_page'], true );
82 wp_delete_post( $uwp_options['users_page'], true );
83
84 // Delete options
85 delete_option( 'uwp_settings' );
86 delete_option( 'uwp_activation_redirect' );
87 delete_option( 'uwp_flush_rewrite' );
88 delete_option( 'uwp_default_data_installed' );
89 delete_option( 'uwp_db_version' );
90 }
91 }
92
93 function uwp_drop_usermeta_table() {
94 global $wpdb;
95 // Drop usermeta table
96 $meta_table_name = $wpdb->prefix . 'uwp_usermeta';
97 $sql = "DROP TABLE IF EXISTS $meta_table_name";
98 $wpdb->query( $sql );
99 }