Changeset 3331720
- Timestamp:
- 07/21/2025 09:02:15 PM (5 months ago)
- Location:
- when-last-login
- Files:
-
- 4 edited
- 1 copied
-
tags/1.2.3 (copied) (copied from when-last-login/trunk)
-
tags/1.2.3/readme.txt (modified) (6 diffs)
-
tags/1.2.3/when-last-login.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (6 diffs)
-
trunk/when-last-login.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
when-last-login/tags/1.2.3/readme.txt
r3298506 r3331720 1 1 === When Last Login === 2 2 Contributors: andrewza, yoohooplugins, travislima 3 Tags: last login, user login, user login time, when last login, login record3 Tags: last login, user login, user login time, last logged in, last seen, user last seen, WordPress last login plugin, last login plugin, last seen plugin, when last login, when last user login, when last user seen, last login WordPress 4 4 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4GC4JEZH7KSKL 5 5 Requires at least: 5.0 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.2 8 Stable tag: 1.2. 28 Stable tag: 1.2.3 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 43 43 Here is a list of plugins we currently support: 44 44 45 * Paid Memberships Pro 45 * [Paid Memberships Pro](https://www.paidmembershipspro.com/) 46 * [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) 46 47 47 48 If you have a plugin and would like to integrate with When Last Login, please open a support thread. 48 49 49 50 50 = Need Help = … … 65 65 Since version 1.0, we have made it easier to be GDPR compliant. With this being said, you need to take the necessary steps in order to become GDPR compliant - we are not a law firm! 66 66 67 = Does this work with 2FA? = 68 Yes, this integrates with the [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) plugin. 69 67 70 = Is this plugin free? = 68 71 Yes, When Last Login is a free plugin for WordPress. We are looking into possibilities of creating a Pro version with a lot more features around the user data of WordPress users. We rely heavily on donations to keep all of our plugins free. If you wish to donate, please click on the donation link on the WordPress repository. … … 87 90 Add the following snippet of code to your theme's functions.php or custom plugin - add_filter( 'when_last_login_show_admin_widget', '__return_false' ); 88 91 89 90 92 == Screenshots == 91 93 1. When Last Login - User's list custom last login field with sorting according to "Last Login" time. … … 93 95 94 96 == Changelog == 97 = 1.2.3 - 2025-07-21 = 98 * ENHANCEMENT: Added support for 2FA plugin. 95 99 96 100 = 1.2.2 - 2023-02-28 = 97 101 * SECURITY: Added in nonce for hiding the admin notice shown on the settings page. 98 * BUG FIX: Fixed minor issue where admins weren 't being correctly excluded from the user query for the login widget.102 * BUG FIX: Fixed minor issue where admins weren’t being correctly excluded from the user query for the login widget. 99 103 100 104 = 1.2.1 - 2021-09-21 = … … 161 165 162 166 == Upgrade Notice == 167 = 1.2.3 = 168 * Upgrade to support 2FA plugin. 169 163 170 = 1.2.2 = 164 171 * Upgrade for minor security and bug improvements. -
when-last-login/tags/1.2.3/when-last-login.php
r2872354 r3331720 2 2 /* 3 3 Plugin Name: When Last Login 4 Plugin URI: https://w ordpress.org/plugins/when-last-login/4 Plugin URI: https://whenlastlogin.com 5 5 Description: See when a user logs into your WordPress site. 6 Version: 1.2. 26 Version: 1.2.3 7 7 Author: Yoohoo Plugins 8 8 Author URI: https://yoohooplugins.com … … 13 13 use geertw\IpAnonymizer\IpAnonymizer; 14 14 15 define( 'WLL_VER', '1.2. 2' );15 define( 'WLL_VER', '1.2.3' ); 16 16 17 17 class When_Last_Login { … … 41 41 add_action( 'wp_login', array( $this, 'last_login'), 10, 2 ); 42 42 add_action( 'user_register', array( $this, 'wll_user_register' ), 10, 1 ); 43 add_action( 'two_factor_user_authenticated', array( $this, 'two_factor_user_authenticated' ), 10, 2 ); 43 44 44 45 //Admin actions … … 161 162 } 162 163 163 public static function last_login( $user_login, $users ){ 164 /** 165 * Track the login process for the Two Factor Authentication plugin. 166 * 167 * @since TBD 168 * 169 * @param WP_User $user 170 * @param Two_Factor $two_factor (this is unused.) 171 */ 172 public static function two_factor_user_authenticated( $user, $two_factor ) { 173 // Let's call last_login function to record the login. 174 When_Last_Login::last_login( $user->user_login, $user ); 175 } 176 177 /** 178 * Track the user's login timestamp and "All Time Record". 179 * 180 * @param string $user_login The username that is logging in. 181 * @param WP_User $user The WordPress user object. 182 * @return void 183 */ 184 public static function last_login( $user_login, $user ) { 164 185 165 186 global $show_login_records; 166 187 167 //get/update user meta 'when_last_login' on login and add time() to it. 168 update_user_meta( $users->ID, 'when_last_login', time() ); 169 170 //get and update user meta 'when_last_login_count' on login for # of login counts. Thanks to Jarryd Long (@jarrydlong) for the assistance 171 $wll_count = get_user_meta( $users->ID, 'when_last_login_count', true ); 172 173 if( $wll_count === false ){ 174 update_user_meta($users->ID, 'when_last_login_count', 1); 175 } else { 176 $wll_new_value = intval($wll_count); 177 $wll_new_value = $wll_new_value + 1; 178 179 update_user_meta($users->ID, 'when_last_login_count', $wll_new_value); 180 } 181 if( $show_login_records == true ){ 182 $args = array( 183 'post_title' => $users->data->display_name . __( ' has logged in at ', 'when-last-login' ) . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), 188 $record_login = apply_filters( 'wll_record_login', true, $user, $user_login ); 189 190 // If filter isn't true, don't record login at all! 191 if ( ! $record_login ) { 192 return; 193 } 194 195 //get/update user meta 'when_last_login' on login and add time() to it. 196 update_user_meta( $user->ID, 'when_last_login', time() ); 197 198 //get and update user meta 'when_last_login_count' on login for # of login counts. Thanks to Jarryd Long (@jarrydlong) for the assistance 199 $wll_count = get_user_meta( $user->ID, 'when_last_login_count', true ); 200 201 if( $wll_count === false ){ 202 update_user_meta($user->ID, 'when_last_login_count', 1); 203 } else { 204 $wll_new_value = intval($wll_count); 205 $wll_new_value = $wll_new_value + 1; 206 207 update_user_meta($user->ID, 'when_last_login_count', $wll_new_value); 208 } 209 210 if( $show_login_records == true ){ 211 $args = array( 212 'post_title' => $user->data->display_name . __( ' has logged in at ', 'when-last-login' ) . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), 184 213 'post_status' => 'publish', 185 'post_author' => $user s->ID,214 'post_author' => $user->ID, 186 215 'post_type' => 'wll_records' 187 216 ); … … 191 220 } 192 221 193 $wll_settings = get_option( 'wll_settings' );194 195 if( isset( $wll_settings['record_ip_address'] ) && intval( $wll_settings['record_ip_address'] ) == 1 ){196 197 // call function to anonymize here.198 $ip = When_Last_Login::wll_get_user_ip_address();199 200 if ( ! empty( $post_id ) ) {201 update_post_meta( $post_id, 'wll_user_ip_address', $ip );202 }203 204 update_user_meta( $users->ID, 'wll_user_ip_address', $ip );205 }206 207 do_action( 'wll_logged_in_action', array( 'login_count' => $wll_new_value, 'user' => $users), $wll_settings );222 $wll_settings = get_option( 'wll_settings' ); 223 224 if( isset( $wll_settings['record_ip_address'] ) && intval( $wll_settings['record_ip_address'] ) == 1 ){ 225 226 // call function to anonymize here. 227 $ip = When_Last_Login::wll_get_user_ip_address(); 228 229 if ( ! empty( $post_id ) ) { 230 update_post_meta( $post_id, 'wll_user_ip_address', $ip ); 231 } 232 233 update_user_meta( $user->ID, 'wll_user_ip_address', $ip ); 234 } 235 236 do_action( 'wll_logged_in_action', array( 'login_count' => $wll_new_value, 'user' => $user ), $wll_settings ); 208 237 209 238 } … … 576 605 */ 577 606 public function wll_automatically_remove_logs() { 578 global $pagenow; 579 580 // Bail if not on our settings page. 581 if ( 'admin.php' == $pagenow && 'when-last-login-settings' != $_GET['page'] ) { 582 return; 583 } 584 585 global $wpdb; 607 global $pagenow, $wpdb; 608 609 // Bail if there is not ?page=xxx parameter 610 if ( empty( $_GET['page'] ) ) { 611 return; 612 } 613 614 // Bail if not on our settings page 615 if ( 'admin.php' == $pagenow && 'when-last-login-settings' != $_GET['page'] ) { 616 return; 617 } 586 618 587 $sql = "DELETE p, pm FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID WHERE p.post_type = 'wll_records'"; 588 589 if ( isset( $_REQUEST['remove_all_wll_records'] ) ) { 590 591 $nonce = $_REQUEST['wll_remove_all_records_nonce']; 592 if ( wp_verify_nonce( $nonce, 'wll_remove_all_records_nonce' ) ) { 593 594 if ( $wpdb->query( $sql ) > 0 ) { 595 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 596 } else { 597 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 598 } 619 $sql = "DELETE p, pm FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID WHERE p.post_type = 'wll_records'"; 620 621 if ( isset( $_REQUEST['remove_all_wll_records'] ) ) { 622 623 $nonce = $_REQUEST['wll_remove_all_records_nonce']; 624 if ( wp_verify_nonce( $nonce, 'wll_remove_all_records_nonce' ) ) { 625 626 if ( $wpdb->query( $sql ) > 0 ) { 627 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 599 628 } else { 600 die( 'nonce not valid.');629 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 601 630 } 602 } 603 604 if ( isset( $_REQUEST['remove_wll_records'] ) ) {605 606 $nonce = $_REQUEST['wll_remove_records_nonce']; 607 if ( wp_verify_nonce( $nonce, 'wll_remove_records_nonce') ) {608 609 $date = apply_filters( 'wll_automatically_remove_logs_date', date( 'Y-m-d', strtotime( '-3 months' ) ) );610 611 $sql .= " AND p.post_date <= '$date'"; 612 613 if ( $wpdb->query( $sql ) > 0 ) { 614 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) );615 } else { 616 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );617 }631 } else { 632 die( 'nonce not valid.' ); 633 } 634 } 635 636 if ( isset( $_REQUEST['remove_wll_records'] ) ) { 637 638 $nonce = $_REQUEST['wll_remove_records_nonce']; 639 if ( wp_verify_nonce( $nonce, 'wll_remove_records_nonce' ) ) { 640 641 $date = apply_filters( 'wll_automatically_remove_logs_date', date( 'Y-m-d', strtotime( '-3 months' ) ) ); 642 643 $sql .= " AND p.post_date <= '$date'"; 644 645 if ( $wpdb->query( $sql ) > 0 ) { 646 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 618 647 } else { 619 die( 'nonce not valid.');620 } 621 } 622 623 if ( isset( $_REQUEST['remove_wll_ip_addresses'] ) ) {624 625 $nonce = $_REQUEST['wll_remove_ip_nonce']; 626 if ( wp_verify_nonce( $nonce, 'wll_remove_ip_nonce') ) {627 628 $sql = "DELETE FROM $wpdb->usermeta WHERE meta_key = 'wll_user_ip_address'";629 630 if ( $wpdb->query( $sql ) > 0 ) { 631 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) );632 } else { 633 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );634 }648 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 649 } 650 } else { 651 die( 'nonce not valid.' ); 652 } 653 } 654 655 if ( isset( $_REQUEST['remove_wll_ip_addresses'] ) ) { 656 657 $nonce = $_REQUEST['wll_remove_ip_nonce']; 658 if ( wp_verify_nonce( $nonce, 'wll_remove_ip_nonce' ) ) { 659 660 $sql = "DELETE FROM $wpdb->usermeta WHERE meta_key = 'wll_user_ip_address'"; 661 662 if ( $wpdb->query( $sql ) > 0 ) { 663 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 635 664 } else { 636 die( 'nonce not valid.');665 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 637 666 } 638 } 667 } else { 668 die( 'nonce not valid.' ); 669 } 670 } 639 671 } 640 672 -
when-last-login/trunk/readme.txt
r3298506 r3331720 1 1 === When Last Login === 2 2 Contributors: andrewza, yoohooplugins, travislima 3 Tags: last login, user login, user login time, when last login, login record3 Tags: last login, user login, user login time, last logged in, last seen, user last seen, WordPress last login plugin, last login plugin, last seen plugin, when last login, when last user login, when last user seen, last login WordPress 4 4 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4GC4JEZH7KSKL 5 5 Requires at least: 5.0 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.2 8 Stable tag: 1.2. 28 Stable tag: 1.2.3 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 43 43 Here is a list of plugins we currently support: 44 44 45 * Paid Memberships Pro 45 * [Paid Memberships Pro](https://www.paidmembershipspro.com/) 46 * [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) 46 47 47 48 If you have a plugin and would like to integrate with When Last Login, please open a support thread. 48 49 49 50 50 = Need Help = … … 65 65 Since version 1.0, we have made it easier to be GDPR compliant. With this being said, you need to take the necessary steps in order to become GDPR compliant - we are not a law firm! 66 66 67 = Does this work with 2FA? = 68 Yes, this integrates with the [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) plugin. 69 67 70 = Is this plugin free? = 68 71 Yes, When Last Login is a free plugin for WordPress. We are looking into possibilities of creating a Pro version with a lot more features around the user data of WordPress users. We rely heavily on donations to keep all of our plugins free. If you wish to donate, please click on the donation link on the WordPress repository. … … 87 90 Add the following snippet of code to your theme's functions.php or custom plugin - add_filter( 'when_last_login_show_admin_widget', '__return_false' ); 88 91 89 90 92 == Screenshots == 91 93 1. When Last Login - User's list custom last login field with sorting according to "Last Login" time. … … 93 95 94 96 == Changelog == 97 = 1.2.3 - 2025-07-21 = 98 * ENHANCEMENT: Added support for 2FA plugin. 95 99 96 100 = 1.2.2 - 2023-02-28 = 97 101 * SECURITY: Added in nonce for hiding the admin notice shown on the settings page. 98 * BUG FIX: Fixed minor issue where admins weren 't being correctly excluded from the user query for the login widget.102 * BUG FIX: Fixed minor issue where admins weren’t being correctly excluded from the user query for the login widget. 99 103 100 104 = 1.2.1 - 2021-09-21 = … … 161 165 162 166 == Upgrade Notice == 167 = 1.2.3 = 168 * Upgrade to support 2FA plugin. 169 163 170 = 1.2.2 = 164 171 * Upgrade for minor security and bug improvements. -
when-last-login/trunk/when-last-login.php
r2872354 r3331720 2 2 /* 3 3 Plugin Name: When Last Login 4 Plugin URI: https://w ordpress.org/plugins/when-last-login/4 Plugin URI: https://whenlastlogin.com 5 5 Description: See when a user logs into your WordPress site. 6 Version: 1.2. 26 Version: 1.2.3 7 7 Author: Yoohoo Plugins 8 8 Author URI: https://yoohooplugins.com … … 13 13 use geertw\IpAnonymizer\IpAnonymizer; 14 14 15 define( 'WLL_VER', '1.2. 2' );15 define( 'WLL_VER', '1.2.3' ); 16 16 17 17 class When_Last_Login { … … 41 41 add_action( 'wp_login', array( $this, 'last_login'), 10, 2 ); 42 42 add_action( 'user_register', array( $this, 'wll_user_register' ), 10, 1 ); 43 add_action( 'two_factor_user_authenticated', array( $this, 'two_factor_user_authenticated' ), 10, 2 ); 43 44 44 45 //Admin actions … … 161 162 } 162 163 163 public static function last_login( $user_login, $users ){ 164 /** 165 * Track the login process for the Two Factor Authentication plugin. 166 * 167 * @since TBD 168 * 169 * @param WP_User $user 170 * @param Two_Factor $two_factor (this is unused.) 171 */ 172 public static function two_factor_user_authenticated( $user, $two_factor ) { 173 // Let's call last_login function to record the login. 174 When_Last_Login::last_login( $user->user_login, $user ); 175 } 176 177 /** 178 * Track the user's login timestamp and "All Time Record". 179 * 180 * @param string $user_login The username that is logging in. 181 * @param WP_User $user The WordPress user object. 182 * @return void 183 */ 184 public static function last_login( $user_login, $user ) { 164 185 165 186 global $show_login_records; 166 187 167 //get/update user meta 'when_last_login' on login and add time() to it. 168 update_user_meta( $users->ID, 'when_last_login', time() ); 169 170 //get and update user meta 'when_last_login_count' on login for # of login counts. Thanks to Jarryd Long (@jarrydlong) for the assistance 171 $wll_count = get_user_meta( $users->ID, 'when_last_login_count', true ); 172 173 if( $wll_count === false ){ 174 update_user_meta($users->ID, 'when_last_login_count', 1); 175 } else { 176 $wll_new_value = intval($wll_count); 177 $wll_new_value = $wll_new_value + 1; 178 179 update_user_meta($users->ID, 'when_last_login_count', $wll_new_value); 180 } 181 if( $show_login_records == true ){ 182 $args = array( 183 'post_title' => $users->data->display_name . __( ' has logged in at ', 'when-last-login' ) . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), 188 $record_login = apply_filters( 'wll_record_login', true, $user, $user_login ); 189 190 // If filter isn't true, don't record login at all! 191 if ( ! $record_login ) { 192 return; 193 } 194 195 //get/update user meta 'when_last_login' on login and add time() to it. 196 update_user_meta( $user->ID, 'when_last_login', time() ); 197 198 //get and update user meta 'when_last_login_count' on login for # of login counts. Thanks to Jarryd Long (@jarrydlong) for the assistance 199 $wll_count = get_user_meta( $user->ID, 'when_last_login_count', true ); 200 201 if( $wll_count === false ){ 202 update_user_meta($user->ID, 'when_last_login_count', 1); 203 } else { 204 $wll_new_value = intval($wll_count); 205 $wll_new_value = $wll_new_value + 1; 206 207 update_user_meta($user->ID, 'when_last_login_count', $wll_new_value); 208 } 209 210 if( $show_login_records == true ){ 211 $args = array( 212 'post_title' => $user->data->display_name . __( ' has logged in at ', 'when-last-login' ) . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), 184 213 'post_status' => 'publish', 185 'post_author' => $user s->ID,214 'post_author' => $user->ID, 186 215 'post_type' => 'wll_records' 187 216 ); … … 191 220 } 192 221 193 $wll_settings = get_option( 'wll_settings' );194 195 if( isset( $wll_settings['record_ip_address'] ) && intval( $wll_settings['record_ip_address'] ) == 1 ){196 197 // call function to anonymize here.198 $ip = When_Last_Login::wll_get_user_ip_address();199 200 if ( ! empty( $post_id ) ) {201 update_post_meta( $post_id, 'wll_user_ip_address', $ip );202 }203 204 update_user_meta( $users->ID, 'wll_user_ip_address', $ip );205 }206 207 do_action( 'wll_logged_in_action', array( 'login_count' => $wll_new_value, 'user' => $users), $wll_settings );222 $wll_settings = get_option( 'wll_settings' ); 223 224 if( isset( $wll_settings['record_ip_address'] ) && intval( $wll_settings['record_ip_address'] ) == 1 ){ 225 226 // call function to anonymize here. 227 $ip = When_Last_Login::wll_get_user_ip_address(); 228 229 if ( ! empty( $post_id ) ) { 230 update_post_meta( $post_id, 'wll_user_ip_address', $ip ); 231 } 232 233 update_user_meta( $user->ID, 'wll_user_ip_address', $ip ); 234 } 235 236 do_action( 'wll_logged_in_action', array( 'login_count' => $wll_new_value, 'user' => $user ), $wll_settings ); 208 237 209 238 } … … 576 605 */ 577 606 public function wll_automatically_remove_logs() { 578 global $pagenow; 579 580 // Bail if not on our settings page. 581 if ( 'admin.php' == $pagenow && 'when-last-login-settings' != $_GET['page'] ) { 582 return; 583 } 584 585 global $wpdb; 607 global $pagenow, $wpdb; 608 609 // Bail if there is not ?page=xxx parameter 610 if ( empty( $_GET['page'] ) ) { 611 return; 612 } 613 614 // Bail if not on our settings page 615 if ( 'admin.php' == $pagenow && 'when-last-login-settings' != $_GET['page'] ) { 616 return; 617 } 586 618 587 $sql = "DELETE p, pm FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID WHERE p.post_type = 'wll_records'"; 588 589 if ( isset( $_REQUEST['remove_all_wll_records'] ) ) { 590 591 $nonce = $_REQUEST['wll_remove_all_records_nonce']; 592 if ( wp_verify_nonce( $nonce, 'wll_remove_all_records_nonce' ) ) { 593 594 if ( $wpdb->query( $sql ) > 0 ) { 595 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 596 } else { 597 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 598 } 619 $sql = "DELETE p, pm FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pm ON pm.post_id = p.ID WHERE p.post_type = 'wll_records'"; 620 621 if ( isset( $_REQUEST['remove_all_wll_records'] ) ) { 622 623 $nonce = $_REQUEST['wll_remove_all_records_nonce']; 624 if ( wp_verify_nonce( $nonce, 'wll_remove_all_records_nonce' ) ) { 625 626 if ( $wpdb->query( $sql ) > 0 ) { 627 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 599 628 } else { 600 die( 'nonce not valid.');629 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 601 630 } 602 } 603 604 if ( isset( $_REQUEST['remove_wll_records'] ) ) {605 606 $nonce = $_REQUEST['wll_remove_records_nonce']; 607 if ( wp_verify_nonce( $nonce, 'wll_remove_records_nonce') ) {608 609 $date = apply_filters( 'wll_automatically_remove_logs_date', date( 'Y-m-d', strtotime( '-3 months' ) ) );610 611 $sql .= " AND p.post_date <= '$date'"; 612 613 if ( $wpdb->query( $sql ) > 0 ) { 614 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) );615 } else { 616 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );617 }631 } else { 632 die( 'nonce not valid.' ); 633 } 634 } 635 636 if ( isset( $_REQUEST['remove_wll_records'] ) ) { 637 638 $nonce = $_REQUEST['wll_remove_records_nonce']; 639 if ( wp_verify_nonce( $nonce, 'wll_remove_records_nonce' ) ) { 640 641 $date = apply_filters( 'wll_automatically_remove_logs_date', date( 'Y-m-d', strtotime( '-3 months' ) ) ); 642 643 $sql .= " AND p.post_date <= '$date'"; 644 645 if ( $wpdb->query( $sql ) > 0 ) { 646 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 618 647 } else { 619 die( 'nonce not valid.');620 } 621 } 622 623 if ( isset( $_REQUEST['remove_wll_ip_addresses'] ) ) {624 625 $nonce = $_REQUEST['wll_remove_ip_nonce']; 626 if ( wp_verify_nonce( $nonce, 'wll_remove_ip_nonce') ) {627 628 $sql = "DELETE FROM $wpdb->usermeta WHERE meta_key = 'wll_user_ip_address'";629 630 if ( $wpdb->query( $sql ) > 0 ) { 631 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) );632 } else { 633 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );634 }648 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 649 } 650 } else { 651 die( 'nonce not valid.' ); 652 } 653 } 654 655 if ( isset( $_REQUEST['remove_wll_ip_addresses'] ) ) { 656 657 $nonce = $_REQUEST['wll_remove_ip_nonce']; 658 if ( wp_verify_nonce( $nonce, 'wll_remove_ip_nonce' ) ) { 659 660 $sql = "DELETE FROM $wpdb->usermeta WHERE meta_key = 'wll_user_ip_address'"; 661 662 if ( $wpdb->query( $sql ) > 0 ) { 663 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__success' ) ); 635 664 } else { 636 die( 'nonce not valid.');665 add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) ); 637 666 } 638 } 667 } else { 668 die( 'nonce not valid.' ); 669 } 670 } 639 671 } 640 672
Note: See TracChangeset
for help on using the changeset viewer.