LastSeen.php
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace ACA\BP\Column\User;
use AC;
use ACA\BP\Filtering;
use ACA\BP\Search;
use ACA\BP\Settings;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
class LastSeen extends AC\Column\Meta
implements ACP\Filtering\Filterable, ACP\Sorting\Sortable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
public function __construct() {
$this->set_type( 'column-buddypress_user_last_seen' )
->set_label( __( 'Last Seen', 'codepress-admin-columns' ) )
->set_group( 'buddypress' );
}
public function get_meta_key() {
return 'last_activity';
}
public function get_value( $id ) {
$value = $this->get_formatted_value( $this->get_raw_value( $id ) );
return $value ?: $this->get_empty_char();
}
public function get_raw_value( $id ) {
return bp_get_user_last_activity( $id );
}
public function register_settings() {
$this->add_setting( new Settings\Date( $this ) );
}
public function filtering() {
return new Filtering\User\LastSeen( $this );
}
public function sorting() {
return new ACP\Sorting\Model\User\Meta( $this->get_meta_key() );
}
public function search() {
return new Search\User\Date( $this->get_meta_key(), $this->get_meta_type() );
}
public function conditional_format(): ?FormattableConfig {
return new FormattableConfig( new ACP\ConditionalFormat\Formatter\DateFormatter\FormatFormatter() );
}
}