ListScreenPost.php
1.19 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
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace AC;
use WP_Post;
abstract class ListScreenPost extends ListScreenWP {
/**
* @var string Post type
*/
private $post_type;
/**
* @param string $post_type
*/
public function __construct( $post_type ) {
$this->set_post_type( $post_type )
->set_meta_type( MetaType::POST );
}
/**
* @return string
*/
public function get_post_type() {
return $this->post_type;
}
/**
* @param string $post_type
*
* @return self
*/
protected function set_post_type( $post_type ) {
$this->post_type = (string) $post_type;
return $this;
}
/**
* @param int $id
*
* @return WP_Post
*/
protected function get_object( $id ) {
return get_post( $id );
}
/**
* @param string $var
*
* @return string|false
*/
protected function get_post_type_label_var( $var ) {
$post_type_object = get_post_type_object( $this->get_post_type() );
return $post_type_object && isset( $post_type_object->labels->{$var} ) ? $post_type_object->labels->{$var} : false;
}
/**
* Register post specific columns
*/
protected function register_column_types() {
$this->register_column_type( new Column\CustomField );
$this->register_column_type( new Column\Actions );
}
}