| 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 |
|