Plugin Directory

Changeset 3331720


Ignore:
Timestamp:
07/21/2025 09:02:15 PM (5 months ago)
Author:
andrewza
Message:

V1.2.3 release, see changelog

Location:
when-last-login
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • when-last-login/tags/1.2.3/readme.txt

    r3298506 r3331720  
    11=== When Last Login ===
    22Contributors: andrewza, yoohooplugins, travislima
    3 Tags: last login, user login, user login time, when last login, login record
     3Tags: 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
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4GC4JEZH7KSKL
    55Requires at least: 5.0
    66Tested up to: 6.8
    77Requires PHP: 7.2
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4343Here is a list of plugins we currently support:
    4444
    45 * Paid Memberships Pro
     45* [Paid Memberships Pro](https://www.paidmembershipspro.com/)
     46* [Two Factor Authentication](https://wordpress.org/plugins/two-factor/)
    4647
    4748If you have a plugin and would like to integrate with When Last Login, please open a support thread.
    48 
    4949
    5050= Need Help =
     
    6565Since 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!
    6666
     67= Does this work with 2FA? =
     68Yes, this integrates with the [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) plugin.
     69
    6770= Is this plugin free? =
    6871Yes, 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.
     
    8790Add the following snippet of code to your theme's functions.php or custom plugin - add_filter( 'when_last_login_show_admin_widget', '__return_false' );
    8891
    89 
    9092== Screenshots ==
    91931. When Last Login - User's list custom last login field with sorting according to "Last Login" time.
     
    9395
    9496== Changelog ==
     97= 1.2.3 - 2025-07-21 =
     98* ENHANCEMENT: Added support for 2FA plugin.
    9599
    96100= 1.2.2 - 2023-02-28 =
    97101* 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 werent being correctly excluded from the user query for the login widget.
    99103
    100104= 1.2.1 - 2021-09-21 =
     
    161165
    162166== Upgrade Notice ==
     167= 1.2.3 =
     168* Upgrade to support 2FA plugin.
     169
    163170= 1.2.2 =
    164171* Upgrade for minor security and bug improvements.
  • when-last-login/tags/1.2.3/when-last-login.php

    r2872354 r3331720  
    22/*
    33Plugin Name: When Last Login
    4 Plugin URI: https://wordpress.org/plugins/when-last-login/
     4Plugin URI: https://whenlastlogin.com
    55Description: See when a user logs into your WordPress site.
    6 Version: 1.2.2
     6Version: 1.2.3
    77Author: Yoohoo Plugins
    88Author URI: https://yoohooplugins.com
     
    1313use geertw\IpAnonymizer\IpAnonymizer;
    1414
    15 define( 'WLL_VER', '1.2.2' );
     15define( 'WLL_VER', '1.2.3' );
    1616
    1717class When_Last_Login {
     
    4141      add_action( 'wp_login', array( $this, 'last_login'), 10, 2 );
    4242      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 );
    4344
    4445      //Admin actions
     
    161162    }
    162163
    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 ) {
    164185
    165186      global $show_login_records;
    166187
    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' ) ),
    184213          'post_status'   => 'publish',
    185           'post_author'   => $users->ID,
     214          'post_author'   => $user->ID,
    186215          'post_type'     => 'wll_records'
    187216        );
     
    191220      }
    192221
    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 );
    208237
    209238     }
     
    576605     */
    577606    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      }
    586618     
    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' ) );
    599628          } else {
    600             die( 'nonce not valid.' );
     629            add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );
    601630          }
    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' ) );
    618647          } 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' ) );
    635664          } else {
    636             die( 'nonce not valid.' );
     665            add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );
    637666          }
    638         }
     667        } else {
     668          die( 'nonce not valid.' );
     669        }
     670      }
    639671    }
    640672
  • when-last-login/trunk/readme.txt

    r3298506 r3331720  
    11=== When Last Login ===
    22Contributors: andrewza, yoohooplugins, travislima
    3 Tags: last login, user login, user login time, when last login, login record
     3Tags: 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
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4GC4JEZH7KSKL
    55Requires at least: 5.0
    66Tested up to: 6.8
    77Requires PHP: 7.2
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4343Here is a list of plugins we currently support:
    4444
    45 * Paid Memberships Pro
     45* [Paid Memberships Pro](https://www.paidmembershipspro.com/)
     46* [Two Factor Authentication](https://wordpress.org/plugins/two-factor/)
    4647
    4748If you have a plugin and would like to integrate with When Last Login, please open a support thread.
    48 
    4949
    5050= Need Help =
     
    6565Since 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!
    6666
     67= Does this work with 2FA? =
     68Yes, this integrates with the [Two Factor Authentication](https://wordpress.org/plugins/two-factor/) plugin.
     69
    6770= Is this plugin free? =
    6871Yes, 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.
     
    8790Add the following snippet of code to your theme's functions.php or custom plugin - add_filter( 'when_last_login_show_admin_widget', '__return_false' );
    8891
    89 
    9092== Screenshots ==
    91931. When Last Login - User's list custom last login field with sorting according to "Last Login" time.
     
    9395
    9496== Changelog ==
     97= 1.2.3 - 2025-07-21 =
     98* ENHANCEMENT: Added support for 2FA plugin.
    9599
    96100= 1.2.2 - 2023-02-28 =
    97101* 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 werent being correctly excluded from the user query for the login widget.
    99103
    100104= 1.2.1 - 2021-09-21 =
     
    161165
    162166== Upgrade Notice ==
     167= 1.2.3 =
     168* Upgrade to support 2FA plugin.
     169
    163170= 1.2.2 =
    164171* Upgrade for minor security and bug improvements.
  • when-last-login/trunk/when-last-login.php

    r2872354 r3331720  
    22/*
    33Plugin Name: When Last Login
    4 Plugin URI: https://wordpress.org/plugins/when-last-login/
     4Plugin URI: https://whenlastlogin.com
    55Description: See when a user logs into your WordPress site.
    6 Version: 1.2.2
     6Version: 1.2.3
    77Author: Yoohoo Plugins
    88Author URI: https://yoohooplugins.com
     
    1313use geertw\IpAnonymizer\IpAnonymizer;
    1414
    15 define( 'WLL_VER', '1.2.2' );
     15define( 'WLL_VER', '1.2.3' );
    1616
    1717class When_Last_Login {
     
    4141      add_action( 'wp_login', array( $this, 'last_login'), 10, 2 );
    4242      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 );
    4344
    4445      //Admin actions
     
    161162    }
    162163
    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 ) {
    164185
    165186      global $show_login_records;
    166187
    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' ) ),
    184213          'post_status'   => 'publish',
    185           'post_author'   => $users->ID,
     214          'post_author'   => $user->ID,
    186215          'post_type'     => 'wll_records'
    187216        );
     
    191220      }
    192221
    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 );
    208237
    209238     }
     
    576605     */
    577606    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      }
    586618     
    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' ) );
    599628          } else {
    600             die( 'nonce not valid.' );
     629            add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );
    601630          }
    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' ) );
    618647          } 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' ) );
    635664          } else {
    636             die( 'nonce not valid.' );
     665            add_action( 'admin_notices', array( $this, 'wll_remove_records_notice__warning' ) );
    637666          }
    638         }
     667        } else {
     668          die( 'nonce not valid.' );
     669        }
     670      }
    639671    }
    640672
Note: See TracChangeset for help on using the changeset viewer.