PostVisibility.php
763 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
<?php
namespace ACP\Column\Post;
use AC;
use ACP\ConditionalFormat;
use ACP\Search;
class PostVisibility extends AC\Column
implements Search\Searchable, ConditionalFormat\Formattable {
use ConditionalFormat\ConditionalFormatTrait;
public function __construct() {
$this->set_type( 'column-post_visibility' );
$this->set_label( __( 'Post Visibility', 'codepress-admin-columns' ) );
}
public function get_raw_value( $post_id ) {
$states = get_post_states( get_post( $post_id ) );
if ( isset( $states['protected'] ) ) {
return $states['protected'];
}
if ( isset( $states['private'] ) ) {
return $states['private'];
}
return __( 'Public' );
}
public function search() {
return new Search\Comparison\Post\PostVisibility();
}
}