|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Application; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterPostType; |
|
7
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterShortcodes; |
|
8
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterTaxonomy; |
|
9
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterWidgets; |
|
10
|
|
|
|
|
11
|
|
|
class MainController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @return void |
|
15
|
|
|
* @action init |
|
16
|
|
|
*/ |
|
17
|
|
|
public function registerPostType() |
|
18
|
|
|
{ |
|
19
|
|
|
if (!glsr()->hasPermission()) { |
|
20
|
|
|
return; |
|
21
|
|
|
} |
|
22
|
|
|
$command = new RegisterPostType([ |
|
23
|
|
|
'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
|
24
|
|
|
'capability_type' => Application::POST_TYPE, |
|
25
|
|
|
'columns' => [ |
|
26
|
|
|
'title' => '', |
|
27
|
|
|
'category' => '', |
|
28
|
|
|
'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29
|
|
|
'reviewer' => __('Author', 'site-reviews'), |
|
30
|
|
|
'email' => __('Email', 'site-reviews'), |
|
31
|
|
|
'ip_address' => __('IP Address', 'site-reviews'), |
|
32
|
|
|
'response' => __('Response', 'site-reviews'), |
|
33
|
|
|
'review_type' => __('Type', 'site-reviews'), |
|
34
|
|
|
'rating' => __('Rating', 'site-reviews'), |
|
35
|
|
|
'pinned' => __('Pinned', 'site-reviews'), |
|
36
|
|
|
'date' => '', |
|
37
|
|
|
], |
|
38
|
|
|
'menu_icon' => 'dashicons-star-half', |
|
39
|
|
|
'menu_name' => glsr()->name, |
|
40
|
|
|
'map_meta_cap' => true, |
|
41
|
|
|
'plural' => __('Reviews', 'site-reviews'), |
|
42
|
|
|
'post_type' => Application::POST_TYPE, |
|
43
|
|
|
'rest_controller_class' => RestReviewController::class, |
|
44
|
|
|
'show_in_rest' => true, |
|
45
|
|
|
'single' => __('Review', 'site-reviews'), |
|
46
|
|
|
]); |
|
47
|
|
|
$this->execute($command); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return void |
|
52
|
|
|
* @action init |
|
53
|
|
|
*/ |
|
54
|
|
|
public function registerShortcodes() |
|
55
|
|
|
{ |
|
56
|
|
|
$command = new RegisterShortcodes([ |
|
57
|
|
|
'site_reviews', |
|
58
|
|
|
'site_reviews_form', |
|
59
|
|
|
'site_reviews_summary', |
|
60
|
|
|
]); |
|
61
|
|
|
$this->execute($command); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return void |
|
66
|
|
|
* @action init |
|
67
|
|
|
*/ |
|
68
|
|
|
public function registerTaxonomy() |
|
69
|
|
|
{ |
|
70
|
|
|
$command = new RegisterTaxonomy([ |
|
71
|
|
|
'hierarchical' => true, |
|
72
|
|
|
'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
73
|
|
|
'public' => false, |
|
74
|
|
|
'rest_controller_class' => RestCategoryController::class, |
|
75
|
|
|
'show_admin_column' => true, |
|
76
|
|
|
'show_in_rest' => true, |
|
77
|
|
|
'show_ui' => true, |
|
78
|
|
|
]); |
|
79
|
|
|
$this->execute($command); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return void |
|
84
|
|
|
* @action widgets_init |
|
85
|
|
|
*/ |
|
86
|
|
|
public function registerWidgets() |
|
87
|
|
|
{ |
|
88
|
|
|
$command = new RegisterWidgets([ |
|
89
|
|
|
'site-reviews', |
|
90
|
|
|
'site-reviews-form', |
|
91
|
|
|
'site-reviews-summary', |
|
92
|
|
|
]); |
|
93
|
|
|
$this->execute($command); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|