| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Last Login |
| 4 |
* Plugin URI: http://en.wp.obenland.it/wp-last-login/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login |
| 5 |
* Description: Displays the date of the last login in user lists. |
| 6 |
* Version: 5 |
| 7 |
* Author: Konstantin Obenland |
| 8 |
* Author URI: http://en.wp.obenland.it/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wp-last-login |
| 9 |
* Text Domain: wp-last-login |
| 10 |
* Domain Path: /lang |
| 11 |
* License: GPLv2 |
| 12 |
* |
| 13 |
* @package wp-last-login |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( ! class_exists( 'Obenland_Wp_Plugins_V5' ) ) { |
| 17 |
require_once 'class-obenland-wp-plugins-v5.php'; |
| 18 |
} |
| 19 |
|
| 20 |
require_once 'class-obenland-wp-last-login.php'; |
| 21 |
new Obenland_Wp_Last_Login(); |
| 22 |
|
| 23 |
/** |
| 24 |
* Sets a default meta value for all users. |
| 25 |
* |
| 26 |
* Allows sorting users by last login to work, even though some might not have |
| 27 |
* recorded login time. |
| 28 |
* |
| 29 |
* @see https://wordpress.org/support/topic/wp-40-sorting-by-date-doesnt-work |
| 30 |
*/ |
| 31 |
function wpll_activate() { |
| 32 |
$user_ids = get_users( |
| 33 |
array( |
| 34 |
'blog_id' => '', |
| 35 |
'fields' => 'ID', |
| 36 |
) |
| 37 |
); |
| 38 |
|
| 39 |
foreach ( $user_ids as $user_id ) { |
| 40 |
update_user_meta( $user_id, 'wp-last-login', 0 ); |
| 41 |
} |
| 42 |
} |
| 43 |
register_activation_hook( __FILE__, 'wpll_activate' ); |
| 44 |
|