PostStatus.php
1.09 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
<?php
namespace AC\Settings\Column;
use AC\Settings;
use AC\View;
class PostStatus extends Settings\Column {
const NAME = 'post_status';
/**
* @var array
*/
private $post_status;
protected function define_options() {
return [ self::NAME => [ 'publish', 'private' ] ];
}
public function create_view() {
$options = [];
foreach ( get_post_stati( [ 'exclude_from_search' => false ] ) as $name ) {
$options[ $name ] = $this->get_post_status_label( $name );
}
$setting = $this->create_element( 'multi-select' )
->set_options( $options );
return new View( [
'label' => __( 'Post Status', 'codepress-admin-columns' ),
'setting' => $setting,
] );
}
private function get_post_status_label( $key ) {
$status = get_post_status_object( $key );
return $status ? $status->label : $key;
}
/**
* @return array
*/
public function get_post_status() {
return $this->post_status;
}
/**
* @param array $post_status
*
* @return true
*/
public function set_post_status( $post_status ) {
$this->post_status = $post_status;
return true;
}
}