1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the WordPress Standard project. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2015-present LIN3S <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace App; |
15
|
|
|
|
16
|
|
|
use LIN3S\WPFoundation\Configuration\Translations\Translations; |
17
|
|
|
use LIN3S\WPFoundation\PostTypes\PostType; |
18
|
|
|
|
19
|
|
|
class PostTypes |
20
|
|
|
{ |
21
|
|
|
const PAGE = 'page'; |
22
|
|
|
const POST = 'post'; |
23
|
|
|
const EXAMPLE_POST_TYPE = 'example_post_type'; |
24
|
|
|
|
25
|
|
|
public function __construct() |
26
|
|
|
{ |
27
|
|
|
$baseOptions = [ |
28
|
|
|
'public' => true, |
29
|
|
|
'show_in_rest' => true, |
30
|
|
|
'supports' => ['title', 'thumbnail', 'editor', 'excerpt'], |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
new PostType( |
34
|
|
|
self::EXAMPLE_POST_TYPE, |
35
|
|
|
array_merge($baseOptions, ['labels' => $this->labels('PostExample', 'PostsExample')]) |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
private function labels(string $singular, string $plural) |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
'name' => Translations::trans(sprintf('%s', $plural)), |
43
|
|
|
'singular_name' => Translations::trans(sprintf('%s', $singular)), |
44
|
|
|
'menu_name' => Translations::trans(sprintf('%s', $plural)), |
45
|
|
|
'name_admin_bar' => Translations::trans(sprintf('%s', $singular)), |
46
|
|
|
'all_items' => Translations::trans(sprintf('All %s', $plural)), |
47
|
|
|
'add_new' => Translations::trans(sprintf('New %s', $singular)), |
48
|
|
|
'add_new_item' => Translations::trans(sprintf('Add New %s', $singular)), |
49
|
|
|
'edit_item' => Translations::trans(sprintf('Edit %s', $singular)), |
50
|
|
|
'new_item' => Translations::trans(sprintf('New %s', $singular)), |
51
|
|
|
'view_item' => Translations::trans(sprintf('View %s', $singular)), |
52
|
|
|
'search_items' => Translations::trans(sprintf('Search %s', $singular)), |
53
|
|
|
'not_found' => Translations::trans(sprintf('No %s found', $plural)), |
54
|
|
|
'not_found_in_trash' => Translations::trans(sprintf('No %s found in trash', $plural)), |
55
|
|
|
'parent_item_colon' => Translations::trans(sprintf('Parent %s', $singular)), |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|