DatePublished.php
961 Bytes
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
<?php
namespace AC\Column\Post;
use AC\Column;
use AC\Settings;
/**
* @since 2.4
*/
class DatePublished extends Column {
public function __construct() {
$this->set_type( 'column-date_published' );
$this->set_label( __( 'Date Published', 'codepress-admin-columns' ) );
}
public function get_value( $id ) {
$value = parent::get_value( $id );
$post = get_post( $id );
switch ( get_post_status( $id ) ) {
// Icons
case 'private' :
case 'draft' :
case 'pending' :
case 'future' :
$value = ac_helper()->post->get_status_icon( $post );
break;
// Tooltip
default :
$value = ac_helper()->html->tooltip( $value, ac_helper()->date->date( $post->post_date, 'wp_date_time' ) );
}
return $value;
}
public function get_raw_value( $post_id ) {
$post = get_post( $post_id );
return $post->post_date;
}
public function register_settings() {
$this->add_setting( new Settings\Column\Date( $this ) );
}
}