Date.php
927 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
<?php
namespace ACP\Editing\Service\Post;
use ACP\Editing\Service;
use ACP\Editing\Storage;
use ACP\Editing\View;
class Date extends Service\DateTime implements Service\Editability
{
public function __construct()
{
parent::__construct(new View\DateTime(), new Storage\Post\Date());
}
public function is_editable(int $id): bool
{
return ! $this->is_unsupported_status(get_post($id)->post_status);
}
public function get_not_editable_reason(int $id): string
{
$post = get_post($id);
return sprintf(
__('Date can not be updated for %s with %s status.', 'codepress-admin-columns'),
get_post_type_object($post->post_type)->labels->singular_name,
$post->post_status
);
}
protected function is_unsupported_status(string $status): bool
{
return in_array($status, ['draft', 'inherit'], true);
}
}