Post.php
633 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
41
42
43
<?php
namespace ACP\Editing\Strategy;
use ACP\Editing\Strategy;
use WP_Post;
class Post implements Strategy {
/**
* @var string
*/
protected $post_type;
/**
* @param string $post_type
*/
public function __construct( $post_type ) {
$this->post_type = $post_type;
}
/**
* @param WP_Post|int $post
*
* @return bool
*/
public function user_has_write_permission( $post ) {
if ( ! $post instanceof WP_Post ) {
$post = get_post( $post );
if ( ! $post instanceof WP_Post ) {
return false;
}
}
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return false;
}
return true;
}
}