Plugin Directory

Changeset 2117865


Ignore:
Timestamp:
07/05/2019 05:51:02 AM (7 years ago)
Author:
sanzeeb3
Message:

Version 1.2.2

Location:
wp-force-logout/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-force-logout/trunk/includes/class-wp-force-logout-process.php

    r2070470 r2117865  
    1818        add_filter( 'manage_users_columns', array( $this, 'add_column_title' ) );
    1919        add_filter( 'manage_users_custom_column', array( $this, 'add_column_value' ), 10, 3 );
     20        add_filter( 'manage_users_sortable_columns', array( $this, 'sortable_login_activity' ) );
     21        add_filter( 'users_list_table_query_args', array( $this, 'sortby_login_activity' ) );
    2022        add_action( 'init', array( $this, 'update_online_users_status' ) );
    2123        add_action( 'init', array( $this, 'update_last_login' ) );
     24        add_action( 'load-users.php', array( $this, 'add_last_login' ) );
    2225        add_action( 'load-users.php', array( $this, 'trigger_query_actions' ) );
    2326        add_action( 'load-users.php', array( $this, 'trigger_bulk_actions' ) );
     
    129132
    130133    /**
     134     * Make login activity column sortable
     135     *
     136     * @param  array $columns Sortable columns.
     137     * @since  1.2.2
     138     *
     139     * @return array
     140     */
     141    public function sortable_login_activity( $columns ) {
     142        $columns['wpfl'] = 'wpfl';
     143
     144        return $columns;
     145    }
     146
     147    /**
     148     *
     149     * Sort users by login activity.
     150     *
     151     * @param array $args.
     152     * @since 1.2.2
     153     *
     154     * @return array
     155     */
     156    public function sortby_login_activity( $args ) {
     157
     158        if ( isset( $args['orderby'] ) && 'wpfl' == $args['orderby'] ) {
     159   
     160            $order = isset( $args['order'] ) && $args['order'] === 'asc' ? 'desc' : 'asc';  // Wierd way of reversing the order. Still works.
     161
     162            $args = array_merge( $args, array(
     163                'meta_key' => 'last_login',
     164                'orderby'  => 'meta_value',
     165                'order'    =>  $order,
     166                'fields' => 'all',
     167            ) );
     168        }
     169
     170        $users = get_users( $args );
     171
     172        return $args;
     173    }
     174
     175    /**
    131176     * Checks if the current user is online or not.
    132177     * @param  int  $user_id    User ID.
     
    184229
    185230    /**
     231     * Add last_login meta key for all users with a random number to later compare.
     232     *
     233     * @todo :: this might gets slower for sites with large number of users.
     234     * @since  1.2.2
     235     *
     236     * @return  void.
     237     */
     238    public function add_last_login() {
     239        $users = get_users();
     240        foreach( $users as $user ) {
     241            $last_login = get_user_meta( $user->ID, 'last_login', true );
     242            if( empty( $last_login ) ) {
     243                update_user_meta( $user->ID, 'last_login', 0.00058373 );    // Store random number to identify.
     244            }
     245        }
     246    }
     247
     248    /**
    186249     * Get last login time.
    187250     *
     
    194257        $the_login_date = '';
    195258
    196         if( ! empty( $last_login ) ) {
     259        if( ! empty( $last_login ) && 0.00058373 != $last_login ) {     // Also check against the random number.
    197260            $the_login_date = human_time_diff( $last_login );
    198261        }
  • wp-force-logout/trunk/includes/class-wp-force-logout.php

    r2070470 r2117865  
    1717     * @var string
    1818     */
    19     public $version = '1.2.1';
     19    public $version = '1.2.2';
    2020
    2121
  • wp-force-logout/trunk/readme.txt

    r2070470 r2117865  
    11=== WPForce Logout ===
    22Contributors: sanzeeb3
    3 Tags: logout, force, online, last seen
     3Tags: logout, force, online, last seen, last login
    44Requires at least: 4.0
    55Tested up to: 5.0
    66Requires PHP: 5.3
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1717If you need to work on your WordPress website without any users being logged in, you can force all user accounts to be logged out. If you suspect that your WordPress site is hacked, then forcing logout will allow you to properly clean up your hacked WordPress site. Next, if you are using a membership or pay per view site and fear that users may be sharing their passwords to access content, then this plugin will come in handy. Furthermore, you can view the online/offline users from users tab at a glance.
    1818
     19See who's online, last login activity right from the users tab. No need of any settings. Install and activate the plugin, go to users tab and view user's activity.
    1920
    20 [Installation And Documentation](https://wpmissing.com/plugins/force-logout-wpforce/)
    2121
    2222[Contact The Author](http://www.sanjeebaryal.com.np)
     
    3030* Logout Specific User(s)
    3131* Bulk Logout Users
    32 * Users Online/Offline Status Display
     32* See who's online
    3333* Last Login Activity
    3434* Well Documented
     
    5555== Changelog ==
    5656
     57= 1.2.2 - 07/05/2019 =
     58* Feature - Sortby login activity.
     59
    5760= 1.2.1 - 04/18/2019 =
    5861* Fix - Login activity for all timestamps.
  • wp-force-logout/trunk/wp-force-logout.php

    r2070470 r2117865  
    33 * Plugin Name: WPForce Logout
    44 * Description: Forcefully logout WordPress user(s).
    5  * Version: 1.2.1
     5 * Version: 1.2.2
    66 * Author: Sanjeev Aryal
    77 * Author URI: http://www.sanjeebaryal.com.np
Note: See TracChangeset for help on using the changeset viewer.