Sticky.php
732 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
<?php
namespace AC\Column\Post;
use AC\Column;
/**
* @since 2.0
*/
class Sticky extends Column {
private $stickies;
public function __construct() {
$this->set_type( 'column-sticky' );
$this->set_label( __( 'Sticky', 'codepress-admin-columns' ) );
}
function is_valid() {
return 'post' === $this->get_post_type();
}
function get_value( $post_id ) {
return ac_helper()->icon->yes_or_no( $this->is_sticky( $post_id ) );
}
function get_raw_value( $post_id ) {
return $this->is_sticky( $post_id );
}
// Helpers
private function is_sticky( $post_id ) {
if ( null === $this->stickies ) {
$this->stickies = get_option( 'sticky_posts' );
}
return in_array( $post_id, (array) $this->stickies );
}
}