Completed
Pull Request — master (#142)
by Sudar
03:06 queued 01:33
created

simple-login-log.php ➔ bd_get_last_login()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Code to enable compatibility with other plugins.
4
 *
5
 * @since 5.5
6
 *
7
 * @author Sudar
8
 *
9
 * @package BulkDelete\Util\Compatibility
10
 */
11
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
12
13
/**
14
 * Find out if Simple Login Log is installed or not.
15
 * http://wordpress.org/plugins/simple-login-log/.
16
 *
17
 * @since 5.5
18
 *
19
 * @return bool True if plugin is installed, False otherwise
20
 */
21
function bd_is_simple_login_log_present() {
22
	global $wpdb;
23
	$simple_login_log_table = 'simple_login_log';
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $simple_login_log_table exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
24
25
	return (bool) $wpdb->get_row( "SHOW TABLES LIKE '{$wpdb->prefix}{$simple_login_log_table}'" );
26
}
27
28
/**
29
 * Find the last login date/time of a user.
30
 *
31
 * @since 5.5
32
 *
33
 * @param int $user_id
34
 *
35
 * @return string
36
 */
37
function bd_get_last_login( $user_id ) {
38
	global $wpdb;
39
40
	$simple_login_log_table = 'simple_login_log';
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $simple_login_log_table exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
41
42
	return $wpdb->get_var( $wpdb->prepare( "SELECT time FROM {$wpdb->prefix}{$simple_login_log_table} WHERE uid = %d ORDER BY time DESC LIMIT 1", $user_id ) );
43
}
44