PluginProbe
When Last Login / trunk
When Last Login vtrunk
trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3
when-last-login / uninstall.php

uninstall.php in When Last Login trunk, at uninstall.php

32 lines 932 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If uninstall is not called from WordPress, exit
4 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5 exit();
6 }
7
8 global $wpdb;
9
10 $users_id = get_users( array(
11 'fields' => 'ID'
12 ) );
13
14 foreach( $users_id as $user_id ){
15 delete_user_meta( $user_id, 'when_last_login' );
16 delete_user_meta( $user_id, 'when_last_login_count' );
17 delete_user_meta( $user_id, 'wll_consent_to_track' );
18 delete_user_meta( $user_id, 'wll_consent_to_track_date' );
19 }
20
21 //Delete CPT's from databse if you uninstall When Last Login and Post Meta.
22 $sql = "DELETE p, pm FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON pm.post_id = p.ID WHERE p.post_type = 'wll_records'";
23 $wpdb->query( $sql );
24
25 //Delete custom table if it exists
26 $delete_table = $wpdb->prefix . 'wll_login_attempts' ;
27 $sql = "DROP TABLE IF EXISTS `$delete_table`";
28 $wpdb->query( $sql );
29
30 $sqlQuery = "DELETE FROM $wpdb->options WHERE option_name LIKE 'wll%'";
31 $wpdb->query($sqlQuery);
32