Sticky.php
629 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 ACP\Editing\Storage\Post;
use ACP\Editing\Storage;
class Sticky implements Storage {
/**
* @var array
*/
private $stickies;
private function is_sticky( int $id ): bool {
if ( null === $this->stickies ) {
$this->stickies = get_option( 'sticky_posts' );
}
return in_array( $id, $this->stickies, true );
}
public function get( $id ) {
return $this->is_sticky( $id )
? 'yes'
: 'no';
}
public function update( int $id, $data ): bool {
if ( 'yes' === $data ) {
stick_post( $id );
} else {
unstick_post( $id );
}
wp_update_post( [ 'ID' => $id ] );
return true;
}
}