|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterPostType; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterShortcodes; |
|
7
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterTaxonomy; |
|
8
|
|
|
use GeminiLabs\SiteReviews\Commands\RegisterWidgets; |
|
9
|
|
|
use GeminiLabs\SiteReviews\Database\Query; |
|
10
|
|
|
use GeminiLabs\SiteReviews\Helpers\Arr; |
|
11
|
|
|
use GeminiLabs\SiteReviews\Install; |
|
12
|
|
|
|
|
13
|
|
|
class MainController extends Controller |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* switch_to_blog() was run before this hook was triggered. |
|
17
|
|
|
* @param array $tables |
|
18
|
|
|
* @return array |
|
19
|
|
|
* @see http://developer.wordpress.org/reference/functions/wp_uninitialize_site/ |
|
20
|
|
|
* @filter wpmu_drop_tables |
|
21
|
|
|
*/ |
|
22
|
|
|
public function filterDropTables($tables) |
|
23
|
|
|
{ |
|
24
|
|
|
$customTables = [ // order is intentional |
|
25
|
|
|
glsr()->prefix.'ratings' => glsr(Query::class)->table('ratings'), |
|
26
|
|
|
glsr()->prefix.'assigned_posts' => glsr(Query::class)->table('assigned_posts'), |
|
27
|
|
|
glsr()->prefix.'assigned_terms' => glsr(Query::class)->table('assigned_terms'), |
|
28
|
|
|
glsr()->prefix.'assigned_users' => glsr(Query::class)->table('assigned_users'), |
|
29
|
|
|
]; |
|
30
|
|
|
foreach ($customTables as $key => $table) { |
|
31
|
|
|
$tables = Arr::prepend($tables, $table, $key); // Custom tables have foreign indexes so they must be removed first! |
|
32
|
|
|
} |
|
33
|
|
|
return $tables; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @return void |
|
38
|
|
|
* @action init |
|
39
|
|
|
*/ |
|
40
|
|
|
public function initDefaults() |
|
41
|
|
|
{ |
|
42
|
|
|
// This cannot be done before plugins_loaded as it uses the gettext functions |
|
43
|
|
|
glsr()->storeDefaults(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \WP_Site $site |
|
|
|
|
|
|
48
|
|
|
* @return void |
|
49
|
|
|
* @action wp_insert_site |
|
50
|
|
|
*/ |
|
51
|
|
|
public function installOnNewSite($site) |
|
52
|
|
|
{ |
|
53
|
|
|
if (is_plugin_active_for_network(plugin_basename(glsr()->file))) { |
|
|
|
|
|
|
54
|
|
|
glsr(Install::class)->runOnSite($site->blog_id); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return void |
|
60
|
|
|
* @action admin_footer |
|
61
|
|
|
* @action wp_footer |
|
62
|
|
|
*/ |
|
63
|
|
|
public function logOnce() |
|
64
|
|
|
{ |
|
65
|
|
|
glsr_log()->logOnce(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return void |
|
70
|
|
|
* @action plugins_loaded |
|
71
|
|
|
*/ |
|
72
|
|
|
public function registerAddons() |
|
73
|
|
|
{ |
|
74
|
|
|
glsr()->action('addon/register', glsr()); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return void |
|
79
|
|
|
* @action plugins_loaded |
|
80
|
|
|
*/ |
|
81
|
|
|
public function registerLanguages() |
|
82
|
|
|
{ |
|
83
|
|
|
load_plugin_textdomain(glsr()->id, false, |
|
|
|
|
|
|
84
|
|
|
trailingslashit(plugin_basename(glsr()->path()).'/'.glsr()->languages) |
|
|
|
|
|
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return void |
|
90
|
|
|
* @action init |
|
91
|
|
|
*/ |
|
92
|
|
|
public function registerPostType() |
|
93
|
|
|
{ |
|
94
|
|
|
$this->execute(new RegisterPostType()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return void |
|
99
|
|
|
* @action plugins_loaded |
|
100
|
|
|
*/ |
|
101
|
|
|
public function registerReviewTypes() |
|
102
|
|
|
{ |
|
103
|
|
|
$types = glsr()->filterArray('addon/types', []); |
|
104
|
|
|
$types = wp_parse_args($types, [ |
|
|
|
|
|
|
105
|
|
|
'local' => _x('Local Review', 'admin-text', 'site-reviews'), |
|
|
|
|
|
|
106
|
|
|
]); |
|
107
|
|
|
glsr()->store('review_types', $types); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return void |
|
112
|
|
|
* @action init |
|
113
|
|
|
*/ |
|
114
|
|
|
public function registerShortcodes() |
|
115
|
|
|
{ |
|
116
|
|
|
$this->execute(new RegisterShortcodes([ |
|
117
|
|
|
'site_reviews', |
|
118
|
|
|
'site_reviews_form', |
|
119
|
|
|
'site_reviews_summary', |
|
120
|
|
|
])); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return void |
|
125
|
|
|
* @action init |
|
126
|
|
|
*/ |
|
127
|
|
|
public function registerTaxonomy() |
|
128
|
|
|
{ |
|
129
|
|
|
$this->execute(new RegisterTaxonomy([ |
|
130
|
|
|
'hierarchical' => true, |
|
131
|
|
|
'meta_box_cb' => [glsr(MetaboxController::class), 'renderTaxonomyMetabox'], |
|
132
|
|
|
'public' => false, |
|
133
|
|
|
'rest_controller_class' => RestCategoryController::class, |
|
134
|
|
|
'show_admin_column' => true, |
|
135
|
|
|
'show_in_rest' => true, |
|
136
|
|
|
'show_ui' => true, |
|
137
|
|
|
])); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @return void |
|
142
|
|
|
* @action widgets_init |
|
143
|
|
|
*/ |
|
144
|
|
|
public function registerWidgets() |
|
145
|
|
|
{ |
|
146
|
|
|
$this->execute(new RegisterWidgets([ |
|
147
|
|
|
'site-reviews' => [ |
|
148
|
|
|
'description' => _x('Site Reviews: Display your recent reviews.', 'admin-text', 'site-reviews'), |
|
|
|
|
|
|
149
|
|
|
'name' => _x('Recent Reviews', 'admin-text', 'site-reviews'), |
|
150
|
|
|
], |
|
151
|
|
|
'site-reviews-form' => [ |
|
152
|
|
|
'description' => _x('Site Reviews: Display a form to submit reviews.', 'admin-text', 'site-reviews'), |
|
153
|
|
|
'name' => _x('Submit a Review', 'admin-text', 'site-reviews'), |
|
154
|
|
|
], |
|
155
|
|
|
'site-reviews-summary' => [ |
|
156
|
|
|
'description' => _x('Site Reviews: Display a summary of your reviews.', 'admin-text', 'site-reviews'), |
|
157
|
|
|
'name' => _x('Summary of Reviews', 'admin-text', 'site-reviews'), |
|
158
|
|
|
], |
|
159
|
|
|
])); |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths