@@ -18,248 +18,248 @@ |
||
18 | 18 | |
19 | 19 | class AdminController extends Controller |
20 | 20 | { |
21 | - /** |
|
22 | - * @return void |
|
23 | - * @action admin_enqueue_scripts |
|
24 | - */ |
|
25 | - public function enqueueAssets() |
|
26 | - { |
|
27 | - $command = new EnqueueAdminAssets([ |
|
28 | - 'pointers' => [[ |
|
29 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
30 | - 'id' => 'glsr-pointer-pinned', |
|
31 | - 'position' => [ |
|
32 | - 'edge' => 'right', |
|
33 | - 'align' => 'middle', |
|
34 | - ], |
|
35 | - 'screen' => Application::POST_TYPE, |
|
36 | - 'target' => '#misc-pub-pinned', |
|
37 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
38 | - ]], |
|
39 | - ]); |
|
40 | - $this->execute($command); |
|
41 | - } |
|
21 | + /** |
|
22 | + * @return void |
|
23 | + * @action admin_enqueue_scripts |
|
24 | + */ |
|
25 | + public function enqueueAssets() |
|
26 | + { |
|
27 | + $command = new EnqueueAdminAssets([ |
|
28 | + 'pointers' => [[ |
|
29 | + 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
30 | + 'id' => 'glsr-pointer-pinned', |
|
31 | + 'position' => [ |
|
32 | + 'edge' => 'right', |
|
33 | + 'align' => 'middle', |
|
34 | + ], |
|
35 | + 'screen' => Application::POST_TYPE, |
|
36 | + 'target' => '#misc-pub-pinned', |
|
37 | + 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
38 | + ]], |
|
39 | + ]); |
|
40 | + $this->execute($command); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - * @filter plugin_action_links_site-reviews/site-reviews.php |
|
46 | - */ |
|
47 | - public function filterActionLinks(array $links) |
|
48 | - { |
|
49 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
50 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
51 | - ]); |
|
52 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
53 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
54 | - ]); |
|
55 | - return $links; |
|
56 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + * @filter plugin_action_links_site-reviews/site-reviews.php |
|
46 | + */ |
|
47 | + public function filterActionLinks(array $links) |
|
48 | + { |
|
49 | + $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
50 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
51 | + ]); |
|
52 | + $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
53 | + 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
54 | + ]); |
|
55 | + return $links; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param array $capabilities |
|
60 | - * @param string $capability |
|
61 | - * @return array |
|
62 | - * @filter map_meta_cap |
|
63 | - */ |
|
64 | - public function filterCreateCapability($capabilities, $capability) |
|
65 | - { |
|
66 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
67 | - $capabilities[] = 'do_not_allow'; |
|
68 | - } |
|
69 | - return $capabilities; |
|
70 | - } |
|
58 | + /** |
|
59 | + * @param array $capabilities |
|
60 | + * @param string $capability |
|
61 | + * @return array |
|
62 | + * @filter map_meta_cap |
|
63 | + */ |
|
64 | + public function filterCreateCapability($capabilities, $capability) |
|
65 | + { |
|
66 | + if ($capability == 'create_'.Application::POST_TYPE) { |
|
67 | + $capabilities[] = 'do_not_allow'; |
|
68 | + } |
|
69 | + return $capabilities; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param array $items |
|
74 | - * @return array |
|
75 | - * @filter dashboard_glance_items |
|
76 | - */ |
|
77 | - public function filterDashboardGlanceItems($items) |
|
78 | - { |
|
79 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
80 | - if (empty($postCount->publish)) { |
|
81 | - return $items; |
|
82 | - } |
|
83 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
84 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
85 | - $items = Arr::consolidateArray($items); |
|
86 | - $items[] = glsr()->can('edit_posts') |
|
87 | - ? glsr(Builder::class)->a($text, [ |
|
88 | - 'class' => 'glsr-review-count', |
|
89 | - 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
|
90 | - ]) |
|
91 | - : glsr(Builder::class)->span($text, [ |
|
92 | - 'class' => 'glsr-review-count', |
|
93 | - ]); |
|
94 | - return $items; |
|
95 | - } |
|
72 | + /** |
|
73 | + * @param array $items |
|
74 | + * @return array |
|
75 | + * @filter dashboard_glance_items |
|
76 | + */ |
|
77 | + public function filterDashboardGlanceItems($items) |
|
78 | + { |
|
79 | + $postCount = wp_count_posts(Application::POST_TYPE); |
|
80 | + if (empty($postCount->publish)) { |
|
81 | + return $items; |
|
82 | + } |
|
83 | + $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
84 | + $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
85 | + $items = Arr::consolidateArray($items); |
|
86 | + $items[] = glsr()->can('edit_posts') |
|
87 | + ? glsr(Builder::class)->a($text, [ |
|
88 | + 'class' => 'glsr-review-count', |
|
89 | + 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
|
90 | + ]) |
|
91 | + : glsr(Builder::class)->span($text, [ |
|
92 | + 'class' => 'glsr-review-count', |
|
93 | + ]); |
|
94 | + return $items; |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param array $plugins |
|
99 | - * @return array |
|
100 | - * @filter mce_external_plugins |
|
101 | - */ |
|
102 | - public function filterTinymcePlugins($plugins) |
|
103 | - { |
|
104 | - if (glsr()->can('edit_posts')) { |
|
105 | - $plugins = Arr::consolidateArray($plugins); |
|
106 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
107 | - } |
|
108 | - return $plugins; |
|
109 | - } |
|
97 | + /** |
|
98 | + * @param array $plugins |
|
99 | + * @return array |
|
100 | + * @filter mce_external_plugins |
|
101 | + */ |
|
102 | + public function filterTinymcePlugins($plugins) |
|
103 | + { |
|
104 | + if (glsr()->can('edit_posts')) { |
|
105 | + $plugins = Arr::consolidateArray($plugins); |
|
106 | + $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
107 | + } |
|
108 | + return $plugins; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return void |
|
113 | - * @action admin_init |
|
114 | - */ |
|
115 | - public function registerTinymcePopups() |
|
116 | - { |
|
117 | - $command = new RegisterTinymcePopups([ |
|
118 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
119 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
120 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
121 | - ]); |
|
122 | - $this->execute($command); |
|
123 | - } |
|
111 | + /** |
|
112 | + * @return void |
|
113 | + * @action admin_init |
|
114 | + */ |
|
115 | + public function registerTinymcePopups() |
|
116 | + { |
|
117 | + $command = new RegisterTinymcePopups([ |
|
118 | + 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
119 | + 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
120 | + 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
121 | + ]); |
|
122 | + $this->execute($command); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @param string $editorId |
|
127 | - * @return void|null |
|
128 | - * @action media_buttons |
|
129 | - */ |
|
130 | - public function renderTinymceButton($editorId) |
|
131 | - { |
|
132 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
133 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
134 | - return; |
|
135 | - } |
|
136 | - $shortcodes = []; |
|
137 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
138 | - $shortcodes[$shortcode] = $values; |
|
139 | - } |
|
140 | - if (empty($shortcodes)) { |
|
141 | - return; |
|
142 | - } |
|
143 | - glsr()->render('partials/editor/tinymce', [ |
|
144 | - 'shortcodes' => $shortcodes, |
|
145 | - ]); |
|
146 | - } |
|
125 | + /** |
|
126 | + * @param string $editorId |
|
127 | + * @return void|null |
|
128 | + * @action media_buttons |
|
129 | + */ |
|
130 | + public function renderTinymceButton($editorId) |
|
131 | + { |
|
132 | + $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
133 | + if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
134 | + return; |
|
135 | + } |
|
136 | + $shortcodes = []; |
|
137 | + foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
138 | + $shortcodes[$shortcode] = $values; |
|
139 | + } |
|
140 | + if (empty($shortcodes)) { |
|
141 | + return; |
|
142 | + } |
|
143 | + glsr()->render('partials/editor/tinymce', [ |
|
144 | + 'shortcodes' => $shortcodes, |
|
145 | + ]); |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - public function routerClearConsole() |
|
152 | - { |
|
153 | - glsr(Console::class)->clear(); |
|
154 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
155 | - } |
|
148 | + /** |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + public function routerClearConsole() |
|
152 | + { |
|
153 | + glsr(Console::class)->clear(); |
|
154 | + glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function routerCountReviews() |
|
161 | - { |
|
162 | - glsr(CountsManager::class)->updateAll(); |
|
163 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
164 | - } |
|
157 | + /** |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function routerCountReviews() |
|
161 | + { |
|
162 | + glsr(CountsManager::class)->updateAll(); |
|
163 | + glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - public function routerDownloadConsole() |
|
170 | - { |
|
171 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
172 | - } |
|
166 | + /** |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + public function routerDownloadConsole() |
|
170 | + { |
|
171 | + $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function routerDownloadSystemInfo() |
|
178 | - { |
|
179 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
180 | - } |
|
174 | + /** |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function routerDownloadSystemInfo() |
|
178 | + { |
|
179 | + $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function routerExportSettings() |
|
186 | - { |
|
187 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
188 | - } |
|
182 | + /** |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function routerExportSettings() |
|
186 | + { |
|
187 | + $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - public function routerFetchConsole() |
|
194 | - { |
|
195 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
196 | - } |
|
190 | + /** |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + public function routerFetchConsole() |
|
194 | + { |
|
195 | + glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - public function routerImportSettings() |
|
202 | - { |
|
203 | - $file = $_FILES['import-file']; |
|
204 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
205 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
206 | - } |
|
207 | - if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
208 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
209 | - } |
|
210 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
211 | - if (empty($settings)) { |
|
212 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
213 | - } |
|
214 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
215 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
216 | - } |
|
198 | + /** |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + public function routerImportSettings() |
|
202 | + { |
|
203 | + $file = $_FILES['import-file']; |
|
204 | + if (UPLOAD_ERR_OK !== $file['error']) { |
|
205 | + return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
206 | + } |
|
207 | + if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
208 | + return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
209 | + } |
|
210 | + $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
211 | + if (empty($settings)) { |
|
212 | + return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
213 | + } |
|
214 | + glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
215 | + glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - public function routerMigrateReviews() |
|
222 | - { |
|
223 | - glsr(Migrate::class)->runAll(); |
|
224 | - glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews')); |
|
225 | - } |
|
218 | + /** |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + public function routerMigrateReviews() |
|
222 | + { |
|
223 | + glsr(Migrate::class)->runAll(); |
|
224 | + glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews')); |
|
225 | + } |
|
226 | 226 | |
227 | - /** |
|
228 | - * @return void |
|
229 | - */ |
|
230 | - public function routerResetPermissions() |
|
231 | - { |
|
232 | - glsr(Role::class)->resetAll(); |
|
233 | - glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews')); |
|
234 | - } |
|
227 | + /** |
|
228 | + * @return void |
|
229 | + */ |
|
230 | + public function routerResetPermissions() |
|
231 | + { |
|
232 | + glsr(Role::class)->resetAll(); |
|
233 | + glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews')); |
|
234 | + } |
|
235 | 235 | |
236 | - /** |
|
237 | - * @return void |
|
238 | - * @action admin_init |
|
239 | - */ |
|
240 | - public function runMigrations() |
|
241 | - { |
|
242 | - if (glsr(Migrate::class)->isMigrationNeeded()) { |
|
243 | - glsr(Migrate::class)->run(); |
|
244 | - glsr(CountsManager::class)->updateAll(); |
|
245 | - } |
|
246 | - } |
|
236 | + /** |
|
237 | + * @return void |
|
238 | + * @action admin_init |
|
239 | + */ |
|
240 | + public function runMigrations() |
|
241 | + { |
|
242 | + if (glsr(Migrate::class)->isMigrationNeeded()) { |
|
243 | + glsr(Migrate::class)->run(); |
|
244 | + glsr(CountsManager::class)->updateAll(); |
|
245 | + } |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @param int $errorCode |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - protected function getUploadError($errorCode) |
|
253 | - { |
|
254 | - $errors = [ |
|
255 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
256 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
257 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
258 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
259 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
260 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
261 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
262 | - ]; |
|
263 | - return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
264 | - } |
|
248 | + /** |
|
249 | + * @param int $errorCode |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + protected function getUploadError($errorCode) |
|
253 | + { |
|
254 | + $errors = [ |
|
255 | + UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
256 | + UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
257 | + UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
258 | + UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
259 | + UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
260 | + UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
261 | + UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
262 | + ]; |
|
263 | + return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
264 | + } |
|
265 | 265 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function enqueueAssets() |
26 | 26 | { |
27 | - $command = new EnqueueAdminAssets([ |
|
27 | + $command = new EnqueueAdminAssets( [ |
|
28 | 28 | 'pointers' => [[ |
29 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
29 | + 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
|
30 | 30 | 'id' => 'glsr-pointer-pinned', |
31 | 31 | 'position' => [ |
32 | 32 | 'edge' => 'right', |
@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | ], |
35 | 35 | 'screen' => Application::POST_TYPE, |
36 | 36 | 'target' => '#misc-pub-pinned', |
37 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
37 | + 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
|
38 | 38 | ]], |
39 | - ]); |
|
40 | - $this->execute($command); |
|
39 | + ] ); |
|
40 | + $this->execute( $command ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @return array |
45 | 45 | * @filter plugin_action_links_site-reviews/site-reviews.php |
46 | 46 | */ |
47 | - public function filterActionLinks(array $links) |
|
47 | + public function filterActionLinks( array $links ) |
|
48 | 48 | { |
49 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
50 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
51 | - ]); |
|
52 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
53 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
54 | - ]); |
|
49 | + $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [ |
|
50 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ), |
|
51 | + ] ); |
|
52 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
53 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
|
54 | + ] ); |
|
55 | 55 | return $links; |
56 | 56 | } |
57 | 57 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @return array |
62 | 62 | * @filter map_meta_cap |
63 | 63 | */ |
64 | - public function filterCreateCapability($capabilities, $capability) |
|
64 | + public function filterCreateCapability( $capabilities, $capability ) |
|
65 | 65 | { |
66 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
66 | + if( $capability == 'create_'.Application::POST_TYPE ) { |
|
67 | 67 | $capabilities[] = 'do_not_allow'; |
68 | 68 | } |
69 | 69 | return $capabilities; |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | * @return array |
75 | 75 | * @filter dashboard_glance_items |
76 | 76 | */ |
77 | - public function filterDashboardGlanceItems($items) |
|
77 | + public function filterDashboardGlanceItems( $items ) |
|
78 | 78 | { |
79 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
80 | - if (empty($postCount->publish)) { |
|
79 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
80 | + if( empty($postCount->publish) ) { |
|
81 | 81 | return $items; |
82 | 82 | } |
83 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
84 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
85 | - $items = Arr::consolidateArray($items); |
|
86 | - $items[] = glsr()->can('edit_posts') |
|
87 | - ? glsr(Builder::class)->a($text, [ |
|
83 | + $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
|
84 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
85 | + $items = Arr::consolidateArray( $items ); |
|
86 | + $items[] = glsr()->can( 'edit_posts' ) |
|
87 | + ? glsr( Builder::class )->a( $text, [ |
|
88 | 88 | 'class' => 'glsr-review-count', |
89 | 89 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
90 | - ]) |
|
91 | - : glsr(Builder::class)->span($text, [ |
|
90 | + ] ) |
|
91 | + : glsr( Builder::class )->span( $text, [ |
|
92 | 92 | 'class' => 'glsr-review-count', |
93 | - ]); |
|
93 | + ] ); |
|
94 | 94 | return $items; |
95 | 95 | } |
96 | 96 | |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | * @return array |
100 | 100 | * @filter mce_external_plugins |
101 | 101 | */ |
102 | - public function filterTinymcePlugins($plugins) |
|
102 | + public function filterTinymcePlugins( $plugins ) |
|
103 | 103 | { |
104 | - if (glsr()->can('edit_posts')) { |
|
105 | - $plugins = Arr::consolidateArray($plugins); |
|
106 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
104 | + if( glsr()->can( 'edit_posts' ) ) { |
|
105 | + $plugins = Arr::consolidateArray( $plugins ); |
|
106 | + $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
|
107 | 107 | } |
108 | 108 | return $plugins; |
109 | 109 | } |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function registerTinymcePopups() |
116 | 116 | { |
117 | - $command = new RegisterTinymcePopups([ |
|
118 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
119 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
120 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
121 | - ]); |
|
122 | - $this->execute($command); |
|
117 | + $command = new RegisterTinymcePopups( [ |
|
118 | + 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
|
119 | + 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
|
120 | + 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
|
121 | + ] ); |
|
122 | + $this->execute( $command ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,22 +127,22 @@ discard block |
||
127 | 127 | * @return void|null |
128 | 128 | * @action media_buttons |
129 | 129 | */ |
130 | - public function renderTinymceButton($editorId) |
|
130 | + public function renderTinymceButton( $editorId ) |
|
131 | 131 | { |
132 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
133 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
132 | + $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
|
133 | + if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | $shortcodes = []; |
137 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
137 | + foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
|
138 | 138 | $shortcodes[$shortcode] = $values; |
139 | 139 | } |
140 | - if (empty($shortcodes)) { |
|
140 | + if( empty($shortcodes) ) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | - glsr()->render('partials/editor/tinymce', [ |
|
143 | + glsr()->render( 'partials/editor/tinymce', [ |
|
144 | 144 | 'shortcodes' => $shortcodes, |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function routerClearConsole() |
152 | 152 | { |
153 | - glsr(Console::class)->clear(); |
|
154 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
153 | + glsr( Console::class )->clear(); |
|
154 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function routerCountReviews() |
161 | 161 | { |
162 | - glsr(CountsManager::class)->updateAll(); |
|
163 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
162 | + glsr( CountsManager::class )->updateAll(); |
|
163 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function routerDownloadConsole() |
170 | 170 | { |
171 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
171 | + $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function routerDownloadSystemInfo() |
178 | 178 | { |
179 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
179 | + $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function routerExportSettings() |
186 | 186 | { |
187 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
187 | + $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function routerFetchConsole() |
194 | 194 | { |
195 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
195 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -201,18 +201,18 @@ discard block |
||
201 | 201 | public function routerImportSettings() |
202 | 202 | { |
203 | 203 | $file = $_FILES['import-file']; |
204 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
205 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
204 | + if( UPLOAD_ERR_OK !== $file['error'] ) { |
|
205 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
206 | 206 | } |
207 | - if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
208 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
207 | + if( 'application/json' !== $file['type'] || !Str::endsWith( '.json', $file['name'] ) ) { |
|
208 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
209 | 209 | } |
210 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
211 | - if (empty($settings)) { |
|
212 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
210 | + $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
|
211 | + if( empty($settings) ) { |
|
212 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
213 | 213 | } |
214 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
215 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
214 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
215 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function routerMigrateReviews() |
222 | 222 | { |
223 | - glsr(Migrate::class)->runAll(); |
|
224 | - glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews')); |
|
223 | + glsr( Migrate::class )->runAll(); |
|
224 | + glsr( Notice::class )->clear()->addSuccess( __( 'The plugin has been migrated to the latest version.', 'site-reviews' ) ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function routerResetPermissions() |
231 | 231 | { |
232 | - glsr(Role::class)->resetAll(); |
|
233 | - glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews')); |
|
232 | + glsr( Role::class )->resetAll(); |
|
233 | + glsr( Notice::class )->clear()->addSuccess( __( 'The permissions have been reset.', 'site-reviews' ) ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function runMigrations() |
241 | 241 | { |
242 | - if (glsr(Migrate::class)->isMigrationNeeded()) { |
|
243 | - glsr(Migrate::class)->run(); |
|
244 | - glsr(CountsManager::class)->updateAll(); |
|
242 | + if( glsr( Migrate::class )->isMigrationNeeded() ) { |
|
243 | + glsr( Migrate::class )->run(); |
|
244 | + glsr( CountsManager::class )->updateAll(); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | * @param int $errorCode |
250 | 250 | * @return string |
251 | 251 | */ |
252 | - protected function getUploadError($errorCode) |
|
252 | + protected function getUploadError( $errorCode ) |
|
253 | 253 | { |
254 | 254 | $errors = [ |
255 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
256 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
257 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
258 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
259 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
260 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
261 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
255 | + UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ), |
|
256 | + UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ), |
|
257 | + UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ), |
|
258 | + UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ), |
|
259 | + UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ), |
|
260 | + UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
|
261 | + UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
|
262 | 262 | ]; |
263 | - return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
263 | + return Arr::get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) ); |
|
264 | 264 | } |
265 | 265 | } |
@@ -10,86 +10,86 @@ |
||
10 | 10 | |
11 | 11 | class MainController extends Controller |
12 | 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 | - } |
|
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 | 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 | - } |
|
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 | 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 | - } |
|
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 | 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 | - } |
|
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 | 95 | } |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function registerPostType() |
18 | 18 | { |
19 | - if (!glsr()->hasPermission()) { |
|
19 | + if( !glsr()->hasPermission() ) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | - $command = new RegisterPostType([ |
|
22 | + $command = new RegisterPostType( [ |
|
23 | 23 | 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
24 | 24 | 'capability_type' => Application::POST_TYPE, |
25 | 25 | 'columns' => [ |
26 | 26 | 'title' => '', |
27 | 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'), |
|
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 | 36 | 'date' => '', |
37 | 37 | ], |
38 | 38 | 'menu_icon' => 'dashicons-star-half', |
39 | 39 | 'menu_name' => glsr()->name, |
40 | 40 | 'map_meta_cap' => true, |
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
41 | + 'plural' => __( 'Reviews', 'site-reviews' ), |
|
42 | 42 | 'post_type' => Application::POST_TYPE, |
43 | 43 | 'rest_controller_class' => RestReviewController::class, |
44 | 44 | 'show_in_rest' => true, |
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
45 | + 'single' => __( 'Review', 'site-reviews' ), |
|
46 | + ] ); |
|
47 | + $this->execute( $command ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function registerShortcodes() |
55 | 55 | { |
56 | - $command = new RegisterShortcodes([ |
|
56 | + $command = new RegisterShortcodes( [ |
|
57 | 57 | 'site_reviews', |
58 | 58 | 'site_reviews_form', |
59 | 59 | 'site_reviews_summary', |
60 | - ]); |
|
61 | - $this->execute($command); |
|
60 | + ] ); |
|
61 | + $this->execute( $command ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function registerTaxonomy() |
69 | 69 | { |
70 | - $command = new RegisterTaxonomy([ |
|
70 | + $command = new RegisterTaxonomy( [ |
|
71 | 71 | 'hierarchical' => true, |
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
72 | + 'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'], |
|
73 | 73 | 'public' => false, |
74 | 74 | 'rest_controller_class' => RestCategoryController::class, |
75 | 75 | 'show_admin_column' => true, |
76 | 76 | 'show_in_rest' => true, |
77 | 77 | 'show_ui' => true, |
78 | - ]); |
|
79 | - $this->execute($command); |
|
78 | + ] ); |
|
79 | + $this->execute( $command ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function registerWidgets() |
87 | 87 | { |
88 | - $command = new RegisterWidgets([ |
|
88 | + $command = new RegisterWidgets( [ |
|
89 | 89 | 'site-reviews', |
90 | 90 | 'site-reviews-form', |
91 | 91 | 'site-reviews-summary', |
92 | - ]); |
|
93 | - $this->execute($command); |
|
92 | + ] ); |
|
93 | + $this->execute( $command ); |
|
94 | 94 | } |
95 | 95 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class Migrate_4_4_0 |
8 | 8 | { |
9 | - /** |
|
10 | - * @return void |
|
11 | - */ |
|
12 | - public function run() |
|
13 | - { |
|
14 | - glsr(Role::class)->resetAll(); |
|
15 | - } |
|
9 | + /** |
|
10 | + * @return void |
|
11 | + */ |
|
12 | + public function run() |
|
13 | + { |
|
14 | + glsr(Role::class)->resetAll(); |
|
15 | + } |
|
16 | 16 | } |
@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | public function run() |
13 | 13 | { |
14 | - glsr(Role::class)->resetAll(); |
|
14 | + glsr( Role::class )->resetAll(); |
|
15 | 15 | } |
16 | 16 | } |
@@ -6,16 +6,16 @@ |
||
6 | 6 | <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
10 | - 'beta' => true, |
|
11 | - 'context' => [ |
|
12 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | - 'link' => 'https://niftyplugins.com/plugins/images/', |
|
14 | - 'slug' => 'images', |
|
15 | - 'title' => 'Images', |
|
16 | - ], |
|
17 | - 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
18 | - ]); |
|
19 | - ?> |
|
9 | + $template->render('partials/addons/addon', [ |
|
10 | + 'beta' => true, |
|
11 | + 'context' => [ |
|
12 | + 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | + 'link' => 'https://niftyplugins.com/plugins/images/', |
|
14 | + 'slug' => 'images', |
|
15 | + 'title' => 'Images', |
|
16 | + ], |
|
17 | + 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
18 | + ]); |
|
19 | + ?> |
|
20 | 20 | </div> |
21 | 21 | </div> |
@@ -1,21 +1,21 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | - <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1> |
|
4 | + <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1> |
|
5 | 5 | <?= $notices; ?> |
6 | - <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
|
6 | + <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p> |
|
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
9 | + $template->render( 'partials/addons/addon', [ |
|
10 | 10 | 'beta' => true, |
11 | 11 | 'context' => [ |
12 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
12 | + 'description' => __( 'This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews' ), |
|
13 | 13 | 'link' => 'https://niftyplugins.com/plugins/images/', |
14 | 14 | 'slug' => 'images', |
15 | 15 | 'title' => 'Images', |
16 | 16 | ], |
17 | 17 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | ?> |
20 | 20 | </div> |
21 | 21 | </div> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-addon-wrap"> |
4 | 4 | <div class="glsr-addon"> |
@@ -10,23 +10,23 @@ discard block |
||
10 | 10 | <p>{{ description }}</p> |
11 | 11 | </div> |
12 | 12 | <div class="glsr-addon-footer"> |
13 | - <?php if (!is_wp_error(validate_plugin($plugin))) : ?> |
|
14 | - <?php if (is_plugin_active($plugin)) : ?> |
|
13 | + <?php if( !is_wp_error( validate_plugin( $plugin ) ) ) : ?> |
|
14 | + <?php if( is_plugin_active( $plugin ) ) : ?> |
|
15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
16 | - <?= __('Installed', 'site-reviews'); ?> |
|
16 | + <?= __( 'Installed', 'site-reviews' ); ?> |
|
17 | 17 | </span> |
18 | 18 | <?php else: ?> |
19 | - <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); ?>" class="glsr-addon-link button button-secondary"> |
|
20 | - <?= __('Activate', 'site-reviews'); ?> |
|
19 | + <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin ); ?>" class="glsr-addon-link button button-secondary"> |
|
20 | + <?= __( 'Activate', 'site-reviews' ); ?> |
|
21 | 21 | </a> |
22 | 22 | <?php endif; ?> |
23 | - <?php elseif (!empty($beta)): ?> |
|
23 | + <?php elseif( !empty($beta) ): ?> |
|
24 | 24 | <a href="mailto:[email protected]?subject=I%20would%20like%20to%20become%20a%20beta%20tester%20({{ slug }})" class="glsr-addon-link glsr-external button button-secondary"> |
25 | - <?= __('Try the beta', 'site-reviews'); ?> |
|
25 | + <?= __( 'Try the beta', 'site-reviews' ); ?> |
|
26 | 26 | </a> |
27 | 27 | <?php else: ?> |
28 | 28 | <a href="{{ link }}" class="glsr-addon-link glsr-external button button-secondary"> |
29 | - <?= __('More Info', 'site-reviews'); ?> |
|
29 | + <?= __( 'More Info', 'site-reviews' ); ?> |
|
30 | 30 | </a> |
31 | 31 | <?php endif; ?> |
32 | 32 | </div> |
@@ -15,8 +15,11 @@ discard block |
||
15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
16 | 16 | <?= __('Installed', 'site-reviews'); ?> |
17 | 17 | </span> |
18 | - <?php else: ?> |
|
19 | - <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); ?>" class="glsr-addon-link button button-secondary"> |
|
18 | + <?php else { |
|
19 | + : ?> |
|
20 | + <a href="<?= wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin), 'activate-plugin_'.$plugin); |
|
21 | +} |
|
22 | +?>" class="glsr-addon-link button button-secondary"> |
|
20 | 23 | <?= __('Activate', 'site-reviews'); ?> |
21 | 24 | </a> |
22 | 25 | <?php endif; ?> |
@@ -24,9 +27,12 @@ discard block |
||
24 | 27 | <a href="mailto:[email protected]?subject=I%20would%20like%20to%20become%20a%20beta%20tester%20({{ slug }})" class="glsr-addon-link glsr-external button button-secondary"> |
25 | 28 | <?= __('Try the beta', 'site-reviews'); ?> |
26 | 29 | </a> |
27 | - <?php else: ?> |
|
30 | + <?php else { |
|
31 | + : ?> |
|
28 | 32 | <a href="{{ link }}" class="glsr-addon-link glsr-external button button-secondary"> |
29 | - <?= __('More Info', 'site-reviews'); ?> |
|
33 | + <?= __('More Info', 'site-reviews'); |
|
34 | +} |
|
35 | +?> |
|
30 | 36 | </a> |
31 | 37 | <?php endif; ?> |
32 | 38 | </div> |
@@ -40,7 +40,8 @@ |
||
40 | 40 | protected $trustalyze; |
41 | 41 | protected $welcome; |
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
43 | + public function __construct(Application $app ) |
|
44 | + { |
|
44 | 45 | $this->app = $app; |
45 | 46 | $this->admin = $app->make(AdminController::class); |
46 | 47 | $this->blocks = $app->make(BlocksController::class); |
@@ -21,112 +21,112 @@ |
||
21 | 21 | |
22 | 22 | class Actions implements HooksContract |
23 | 23 | { |
24 | - protected $about; |
|
25 | - protected $admin; |
|
26 | - protected $app; |
|
27 | - protected $blocks; |
|
28 | - protected $console; |
|
29 | - protected $editor; |
|
30 | - protected $listtable; |
|
31 | - protected $menu; |
|
32 | - protected $main; |
|
33 | - protected $notices; |
|
34 | - protected $public; |
|
35 | - protected $review; |
|
36 | - protected $router; |
|
37 | - protected $settings; |
|
38 | - protected $taxonomy; |
|
39 | - protected $translator; |
|
40 | - protected $trustalyze; |
|
41 | - protected $welcome; |
|
24 | + protected $about; |
|
25 | + protected $admin; |
|
26 | + protected $app; |
|
27 | + protected $blocks; |
|
28 | + protected $console; |
|
29 | + protected $editor; |
|
30 | + protected $listtable; |
|
31 | + protected $menu; |
|
32 | + protected $main; |
|
33 | + protected $notices; |
|
34 | + protected $public; |
|
35 | + protected $review; |
|
36 | + protected $router; |
|
37 | + protected $settings; |
|
38 | + protected $taxonomy; |
|
39 | + protected $translator; |
|
40 | + protected $trustalyze; |
|
41 | + protected $welcome; |
|
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
44 | - $this->app = $app; |
|
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
61 | - } |
|
43 | + public function __construct(Application $app ) { |
|
44 | + $this->app = $app; |
|
45 | + $this->admin = $app->make(AdminController::class); |
|
46 | + $this->blocks = $app->make(BlocksController::class); |
|
47 | + $this->console = $app->make(Console::class); |
|
48 | + $this->editor = $app->make(EditorController::class); |
|
49 | + $this->listtable = $app->make(ListTableController::class); |
|
50 | + $this->main = $app->make(MainController::class); |
|
51 | + $this->menu = $app->make(MenuController::class); |
|
52 | + $this->notices = $app->make(NoticeController::class); |
|
53 | + $this->public = $app->make(PublicController::class); |
|
54 | + $this->review = $app->make(ReviewController::class); |
|
55 | + $this->router = $app->make(Router::class); |
|
56 | + $this->settings = $app->make(SettingsController::class); |
|
57 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | + $this->translator = $app->make(TranslationController::class); |
|
59 | + $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | + $this->welcome = $app->make(WelcomeController::class); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function run() |
|
67 | - { |
|
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
131 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function run() |
|
67 | + { |
|
68 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | + add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | + add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | + add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | + add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | + add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | + add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | + add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | + add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | + add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | + add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | + add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
131 | + } |
|
132 | 132 | } |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | protected $trustalyze; |
41 | 41 | protected $welcome; |
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
43 | + public function __construct( Application $app ) { |
|
44 | 44 | $this->app = $app; |
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
45 | + $this->admin = $app->make( AdminController::class ); |
|
46 | + $this->blocks = $app->make( BlocksController::class ); |
|
47 | + $this->console = $app->make( Console::class ); |
|
48 | + $this->editor = $app->make( EditorController::class ); |
|
49 | + $this->listtable = $app->make( ListTableController::class ); |
|
50 | + $this->main = $app->make( MainController::class ); |
|
51 | + $this->menu = $app->make( MenuController::class ); |
|
52 | + $this->notices = $app->make( NoticeController::class ); |
|
53 | + $this->public = $app->make( PublicController::class ); |
|
54 | + $this->review = $app->make( ReviewController::class ); |
|
55 | + $this->router = $app->make( Router::class ); |
|
56 | + $this->settings = $app->make( SettingsController::class ); |
|
57 | + $this->taxonomy = $app->make( TaxonomyController::class ); |
|
58 | + $this->translator = $app->make( TranslationController::class ); |
|
59 | + $this->trustalyze = $app->make( TrustalyzeController::class ); |
|
60 | + $this->welcome = $app->make( WelcomeController::class ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,68 +65,68 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function run() |
67 | 67 | { |
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
68 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
69 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
70 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
71 | + add_action( 'admin_init', [$this->admin, 'runMigrations'] ); |
|
72 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
73 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
74 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
75 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
76 | + add_action( 'admin_init', [$this->app, 'setDefaults'] ); |
|
77 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
78 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
79 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
80 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
81 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
82 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
83 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
84 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
85 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
86 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
87 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
88 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3 ); |
|
89 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
90 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
91 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
92 | + add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
93 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
94 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
95 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
96 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
97 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
98 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
99 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
100 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
101 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
102 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
103 | + add_action( 'admin_notices', [$this->notices, 'filterAdminNotices'] ); |
|
104 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
105 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
106 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
107 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
108 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
109 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
110 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
111 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
112 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
113 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
114 | + add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
115 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
116 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
117 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
118 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
119 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
120 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
121 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
122 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
123 | + add_action( 'plugins_loaded', [$this->translator, 'addTranslationFilters'] ); |
|
124 | + add_action( 'admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels'] ); |
|
125 | + add_action( 'site-reviews/review/created', [$this->trustalyze, 'onCreated'] ); |
|
126 | + add_action( 'site-reviews/review/reverted', [$this->trustalyze, 'onReverted'] ); |
|
127 | + add_action( 'site-reviews/review/saved', [$this->trustalyze, 'onSaved'] ); |
|
128 | + add_action( 'updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3 ); |
|
129 | + add_action( 'activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2 ); |
|
130 | + add_action( 'admin_menu', [$this->welcome, 'registerPage'] ); |
|
131 | 131 | } |
132 | 132 | } |
@@ -10,114 +10,114 @@ |
||
10 | 10 | |
11 | 11 | class NoticeController extends Controller |
12 | 12 | { |
13 | - const USER_META_KEY = '_glsr_notices'; |
|
13 | + const USER_META_KEY = '_glsr_notices'; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $dismissValuesMap; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $dismissValuesMap; |
|
19 | 19 | |
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->dismissValuesMap = [ |
|
23 | - 'trustalyze' => glsr()->version('major'), |
|
24 | - 'welcome' => glsr()->version('minor'), |
|
25 | - ]; |
|
26 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->dismissValuesMap = [ |
|
23 | + 'trustalyze' => glsr()->version('major'), |
|
24 | + 'welcome' => glsr()->version('minor'), |
|
25 | + ]; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return void |
|
30 | - * @action admin_notices |
|
31 | - */ |
|
32 | - public function filterAdminNotices() |
|
33 | - { |
|
34 | - $screen = glsr_current_screen(); |
|
35 | - $this->renderWelcomeNotice($screen->post_type); |
|
36 | - $this->renderTrustalyzeNotice($screen->post_type); |
|
37 | - } |
|
28 | + /** |
|
29 | + * @return void |
|
30 | + * @action admin_notices |
|
31 | + */ |
|
32 | + public function filterAdminNotices() |
|
33 | + { |
|
34 | + $screen = glsr_current_screen(); |
|
35 | + $this->renderWelcomeNotice($screen->post_type); |
|
36 | + $this->renderTrustalyzeNotice($screen->post_type); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function routerDismissNotice(array $request) |
|
43 | - { |
|
44 | - if ($key = Arr::get($request, 'notice')) { |
|
45 | - $this->dismissNotice($key); |
|
46 | - } |
|
47 | - } |
|
39 | + /** |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function routerDismissNotice(array $request) |
|
43 | + { |
|
44 | + if ($key = Arr::get($request, 'notice')) { |
|
45 | + $this->dismissNotice($key); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $key |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - protected function dismissNotice($key) |
|
54 | - { |
|
55 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
56 | - } |
|
49 | + /** |
|
50 | + * @param string $key |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + protected function dismissNotice($key) |
|
54 | + { |
|
55 | + $this->setUserMeta($key, $this->getVersionFor($key)); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param string $key |
|
60 | - * @param mixed $fallback |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - protected function getUserMeta($key, $fallback) |
|
64 | - { |
|
65 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | - return Arr::get($meta, $key, $fallback); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @param string $key |
|
60 | + * @param mixed $fallback |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + protected function getUserMeta($key, $fallback) |
|
64 | + { |
|
65 | + $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | + return Arr::get($meta, $key, $fallback); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $noticeKey |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - protected function getVersionFor($noticeKey) |
|
74 | - { |
|
75 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
76 | - } |
|
69 | + /** |
|
70 | + * @param string $noticeKey |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + protected function getVersionFor($noticeKey) |
|
74 | + { |
|
75 | + return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $screenPostType |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - protected function renderTrustalyzeNotice($screenPostType) |
|
83 | - { |
|
84 | - if (Application::POST_TYPE == $screenPostType |
|
85 | - && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | - && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | - && glsr()->can('manage_options')) { |
|
88 | - glsr()->render('partials/notices/trustalyze'); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * @param string $screenPostType |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + protected function renderTrustalyzeNotice($screenPostType) |
|
83 | + { |
|
84 | + if (Application::POST_TYPE == $screenPostType |
|
85 | + && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | + && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | + && glsr()->can('manage_options')) { |
|
88 | + glsr()->render('partials/notices/trustalyze'); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @param string $screenPostType |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - protected function renderWelcomeNotice($screenPostType) |
|
97 | - { |
|
98 | - if (Application::POST_TYPE == $screenPostType |
|
99 | - && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | - && glsr()->can('edit_others_posts')) { |
|
101 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | - ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | - : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | - glsr()->render('partials/notices/welcome', [ |
|
105 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | - ]); |
|
107 | - } |
|
108 | - } |
|
92 | + /** |
|
93 | + * @param string $screenPostType |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + protected function renderWelcomeNotice($screenPostType) |
|
97 | + { |
|
98 | + if (Application::POST_TYPE == $screenPostType |
|
99 | + && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | + && glsr()->can('edit_others_posts')) { |
|
101 | + $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | + ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | + : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | + glsr()->render('partials/notices/welcome', [ |
|
105 | + 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | + ]); |
|
107 | + } |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param string $key |
|
112 | - * @param mixed $fallback |
|
113 | - * @return mixed |
|
114 | - */ |
|
115 | - protected function setUserMeta($key, $value) |
|
116 | - { |
|
117 | - $userId = get_current_user_id(); |
|
118 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
120 | - $meta[$key] = $value; |
|
121 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
122 | - } |
|
110 | + /** |
|
111 | + * @param string $key |
|
112 | + * @param mixed $fallback |
|
113 | + * @return mixed |
|
114 | + */ |
|
115 | + protected function setUserMeta($key, $value) |
|
116 | + { |
|
117 | + $userId = get_current_user_id(); |
|
118 | + $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | + $meta = array_filter(wp_parse_args($meta, [])); |
|
120 | + $meta[$key] = $value; |
|
121 | + update_user_meta($userId, static::USER_META_KEY, $meta); |
|
122 | + } |
|
123 | 123 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | public function __construct() |
21 | 21 | { |
22 | 22 | $this->dismissValuesMap = [ |
23 | - 'trustalyze' => glsr()->version('major'), |
|
24 | - 'welcome' => glsr()->version('minor'), |
|
23 | + 'trustalyze' => glsr()->version( 'major' ), |
|
24 | + 'welcome' => glsr()->version( 'minor' ), |
|
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | public function filterAdminNotices() |
33 | 33 | { |
34 | 34 | $screen = glsr_current_screen(); |
35 | - $this->renderWelcomeNotice($screen->post_type); |
|
36 | - $this->renderTrustalyzeNotice($screen->post_type); |
|
35 | + $this->renderWelcomeNotice( $screen->post_type ); |
|
36 | + $this->renderTrustalyzeNotice( $screen->post_type ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @return void |
41 | 41 | */ |
42 | - public function routerDismissNotice(array $request) |
|
42 | + public function routerDismissNotice( array $request ) |
|
43 | 43 | { |
44 | - if ($key = Arr::get($request, 'notice')) { |
|
45 | - $this->dismissNotice($key); |
|
44 | + if( $key = Arr::get( $request, 'notice' ) ) { |
|
45 | + $this->dismissNotice( $key ); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * @param string $key |
51 | 51 | * @return void |
52 | 52 | */ |
53 | - protected function dismissNotice($key) |
|
53 | + protected function dismissNotice( $key ) |
|
54 | 54 | { |
55 | - $this->setUserMeta($key, $this->getVersionFor($key)); |
|
55 | + $this->setUserMeta( $key, $this->getVersionFor( $key ) ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,32 +60,32 @@ discard block |
||
60 | 60 | * @param mixed $fallback |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - protected function getUserMeta($key, $fallback) |
|
63 | + protected function getUserMeta( $key, $fallback ) |
|
64 | 64 | { |
65 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
66 | - return Arr::get($meta, $key, $fallback); |
|
65 | + $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true ); |
|
66 | + return Arr::get( $meta, $key, $fallback ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @param string $noticeKey |
71 | 71 | * @return string |
72 | 72 | */ |
73 | - protected function getVersionFor($noticeKey) |
|
73 | + protected function getVersionFor( $noticeKey ) |
|
74 | 74 | { |
75 | - return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major')); |
|
75 | + return Arr::get( $this->dismissValuesMap, $noticeKey, glsr()->version( 'major' ) ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $screenPostType |
80 | 80 | * @return void |
81 | 81 | */ |
82 | - protected function renderTrustalyzeNotice($screenPostType) |
|
82 | + protected function renderTrustalyzeNotice( $screenPostType ) |
|
83 | 83 | { |
84 | - if (Application::POST_TYPE == $screenPostType |
|
85 | - && Helper::isGreaterThan($this->getVersionFor('trustalyze'), $this->getUserMeta('trustalyze', 0)) |
|
86 | - && !glsr(OptionManager::class)->getBool('settings.general.trustalyze') |
|
87 | - && glsr()->can('manage_options')) { |
|
88 | - glsr()->render('partials/notices/trustalyze'); |
|
84 | + if( Application::POST_TYPE == $screenPostType |
|
85 | + && Helper::isGreaterThan( $this->getVersionFor( 'trustalyze' ), $this->getUserMeta( 'trustalyze', 0 ) ) |
|
86 | + && !glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' ) |
|
87 | + && glsr()->can( 'manage_options' ) ) { |
|
88 | + glsr()->render( 'partials/notices/trustalyze' ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @param string $screenPostType |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - protected function renderWelcomeNotice($screenPostType) |
|
96 | + protected function renderWelcomeNotice( $screenPostType ) |
|
97 | 97 | { |
98 | - if (Application::POST_TYPE == $screenPostType |
|
99 | - && Helper::isGreaterThan($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0)) |
|
100 | - && glsr()->can('edit_others_posts')) { |
|
101 | - $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from') |
|
102 | - ? __('Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews') |
|
103 | - : __('Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews'); |
|
104 | - glsr()->render('partials/notices/welcome', [ |
|
105 | - 'text' => sprintf($welcomeText, glsr()->version), |
|
106 | - ]); |
|
98 | + if( Application::POST_TYPE == $screenPostType |
|
99 | + && Helper::isGreaterThan( $this->getVersionFor( 'welcome' ), $this->getUserMeta( 'welcome', 0 ) ) |
|
100 | + && glsr()->can( 'edit_others_posts' ) ) { |
|
101 | + $welcomeText = '0.0.0' == glsr( OptionManager::class )->get( 'version_upgraded_from' ) |
|
102 | + ? __( 'Thanks for installing Site Reviews v%s, we hope you love it!', 'site-reviews' ) |
|
103 | + : __( 'Thanks for updating to Site Reviews v%s, we hope you love the changes!', 'site-reviews' ); |
|
104 | + glsr()->render( 'partials/notices/welcome', [ |
|
105 | + 'text' => sprintf( $welcomeText, glsr()->version ), |
|
106 | + ] ); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @param mixed $fallback |
113 | 113 | * @return mixed |
114 | 114 | */ |
115 | - protected function setUserMeta($key, $value) |
|
115 | + protected function setUserMeta( $key, $value ) |
|
116 | 116 | { |
117 | 117 | $userId = get_current_user_id(); |
118 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
119 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
118 | + $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true ); |
|
119 | + $meta = array_filter( wp_parse_args( $meta, [] ) ); |
|
120 | 120 | $meta[$key] = $value; |
121 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
121 | + update_user_meta( $userId, static::USER_META_KEY, $meta ); |
|
122 | 122 | } |
123 | 123 | } |
@@ -10,143 +10,143 @@ |
||
10 | 10 | |
11 | 11 | class Trustalyze |
12 | 12 | { |
13 | - const API_URL = 'https://www.trustalyze.com/api/rbs/'; |
|
14 | - const WEB_URL = 'https://trustalyze.com/plans?ref=105'; |
|
13 | + const API_URL = 'https://www.trustalyze.com/api/rbs/'; |
|
14 | + const WEB_URL = 'https://trustalyze.com/plans?ref=105'; |
|
15 | 15 | |
16 | - public $message; |
|
17 | - public $response; |
|
18 | - public $success; |
|
16 | + public $message; |
|
17 | + public $response; |
|
18 | + public $success; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function __get($key) |
|
24 | - { |
|
25 | - return property_exists($this, $key) |
|
26 | - ? $this->$key |
|
27 | - : Arr::get($this->response, $key, null); |
|
28 | - } |
|
20 | + /** |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function __get($key) |
|
24 | + { |
|
25 | + return property_exists($this, $key) |
|
26 | + ? $this->$key |
|
27 | + : Arr::get($this->response, $key, null); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return self |
|
32 | - */ |
|
33 | - public function activateKey($apiKey = '', $email = '') |
|
34 | - { |
|
35 | - $this->send('api_key_activation.php', [ |
|
36 | - 'body' => [ |
|
37 | - 'apikey' => $apiKey ?: 0, |
|
38 | - 'domain' => get_home_url(), |
|
39 | - 'email' => $email ?: 0, |
|
40 | - ], |
|
41 | - ]); |
|
42 | - return $this; |
|
43 | - } |
|
30 | + /** |
|
31 | + * @return self |
|
32 | + */ |
|
33 | + public function activateKey($apiKey = '', $email = '') |
|
34 | + { |
|
35 | + $this->send('api_key_activation.php', [ |
|
36 | + 'body' => [ |
|
37 | + 'apikey' => $apiKey ?: 0, |
|
38 | + 'domain' => get_home_url(), |
|
39 | + 'email' => $email ?: 0, |
|
40 | + ], |
|
41 | + ]); |
|
42 | + return $this; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return self |
|
47 | - */ |
|
48 | - public function reset() |
|
49 | - { |
|
50 | - $this->message = ''; |
|
51 | - $this->response = []; |
|
52 | - $this->success = false; |
|
53 | - return $this; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @return self |
|
47 | + */ |
|
48 | + public function reset() |
|
49 | + { |
|
50 | + $this->message = ''; |
|
51 | + $this->response = []; |
|
52 | + $this->success = false; |
|
53 | + return $this; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return self |
|
58 | - */ |
|
59 | - public function sendReview(Review $review) |
|
60 | - { |
|
61 | - $this->send('index.php', [ |
|
62 | - 'body' => $this->getBodyForReview($review), |
|
63 | - 'timeout' => 120, |
|
64 | - ]); |
|
65 | - return $this; |
|
66 | - } |
|
56 | + /** |
|
57 | + * @return self |
|
58 | + */ |
|
59 | + public function sendReview(Review $review) |
|
60 | + { |
|
61 | + $this->send('index.php', [ |
|
62 | + 'body' => $this->getBodyForReview($review), |
|
63 | + 'timeout' => 120, |
|
64 | + ]); |
|
65 | + return $this; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return self |
|
70 | - */ |
|
71 | - public function sendReviewResponse(Review $review) |
|
72 | - { |
|
73 | - $this->send('fetch_customer_reply.php', [ |
|
74 | - 'body' => $this->getBodyForResponse($review), |
|
75 | - ]); |
|
76 | - return $this; |
|
77 | - } |
|
68 | + /** |
|
69 | + * @return self |
|
70 | + */ |
|
71 | + public function sendReviewResponse(Review $review) |
|
72 | + { |
|
73 | + $this->send('fetch_customer_reply.php', [ |
|
74 | + 'body' => $this->getBodyForResponse($review), |
|
75 | + ]); |
|
76 | + return $this; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - protected function getBodyForResponse(Review $review) |
|
83 | - { |
|
84 | - $trustalyzeResponse = [ |
|
85 | - 'reply' => Str::truncate($review->response, 300), |
|
86 | - 'review_id' => glsr(Database::class)->get($review->ID, 'trustalyze'), // this is the trustalyze review ID |
|
87 | - 'review_transaction_id' => $review->review_id, |
|
88 | - 'type' => 'M', |
|
89 | - ]; |
|
90 | - return apply_filters('site-reviews/trustalyze/response', $trustalyzeResponse, $review); |
|
91 | - } |
|
79 | + /** |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + protected function getBodyForResponse(Review $review) |
|
83 | + { |
|
84 | + $trustalyzeResponse = [ |
|
85 | + 'reply' => Str::truncate($review->response, 300), |
|
86 | + 'review_id' => glsr(Database::class)->get($review->ID, 'trustalyze'), // this is the trustalyze review ID |
|
87 | + 'review_transaction_id' => $review->review_id, |
|
88 | + 'type' => 'M', |
|
89 | + ]; |
|
90 | + return apply_filters('site-reviews/trustalyze/response', $trustalyzeResponse, $review); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - protected function getBodyForReview(Review $review) |
|
97 | - { |
|
98 | - $trustalyzeReview = [ |
|
99 | - 'domain' => get_home_url(), |
|
100 | - 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
101 | - 'rate' => $review->rating, |
|
102 | - 'review_transaction_id' => $review->review_id, |
|
103 | - 'reviews' => Str::truncate($review->content, 280), |
|
104 | - 'title' => Str::truncate($review->title, 35), |
|
105 | - 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
|
106 | - ]; |
|
107 | - return apply_filters('site-reviews/trustalyze/review', $trustalyzeReview, $review); |
|
108 | - } |
|
93 | + /** |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + protected function getBodyForReview(Review $review) |
|
97 | + { |
|
98 | + $trustalyzeReview = [ |
|
99 | + 'domain' => get_home_url(), |
|
100 | + 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
101 | + 'rate' => $review->rating, |
|
102 | + 'review_transaction_id' => $review->review_id, |
|
103 | + 'reviews' => Str::truncate($review->content, 280), |
|
104 | + 'title' => Str::truncate($review->title, 35), |
|
105 | + 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
|
106 | + ]; |
|
107 | + return apply_filters('site-reviews/trustalyze/review', $trustalyzeReview, $review); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param \WP_Error|array $response |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - protected function handleResponse($response) |
|
115 | - { |
|
116 | - if (is_wp_error($response)) { |
|
117 | - $this->message = $response->get_error_message(); |
|
118 | - } else { |
|
119 | - $responseBody = wp_remote_retrieve_body($response); |
|
120 | - $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | - $responseData = (array) json_decode($responseBody, true); |
|
122 | - $this->response = array_shift($responseData); |
|
123 | - $this->message = Arr::get($this->response, 'msg'); |
|
124 | - $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | - if (200 !== $responseCode) { |
|
126 | - glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
127 | - } |
|
128 | - if (!$this->success) { |
|
129 | - glsr_log()->error($this->message); |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
110 | + /** |
|
111 | + * @param \WP_Error|array $response |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + protected function handleResponse($response) |
|
115 | + { |
|
116 | + if (is_wp_error($response)) { |
|
117 | + $this->message = $response->get_error_message(); |
|
118 | + } else { |
|
119 | + $responseBody = wp_remote_retrieve_body($response); |
|
120 | + $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | + $responseData = (array) json_decode($responseBody, true); |
|
122 | + $this->response = array_shift($responseData); |
|
123 | + $this->message = Arr::get($this->response, 'msg'); |
|
124 | + $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | + if (200 !== $responseCode) { |
|
126 | + glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
127 | + } |
|
128 | + if (!$this->success) { |
|
129 | + glsr_log()->error($this->message); |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @param string $endpoint |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - protected function send($endpoint, array $args = []) |
|
139 | - { |
|
140 | - $args = wp_parse_args($args, [ |
|
141 | - 'body' => null, |
|
142 | - 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
143 | - 'redirection' => 5, |
|
144 | - 'sslverify' => false, |
|
145 | - 'timeout' => 5, |
|
146 | - ]); |
|
147 | - $this->reset(); |
|
148 | - $this->handleResponse( |
|
149 | - wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
150 | - ); |
|
151 | - } |
|
134 | + /** |
|
135 | + * @param string $endpoint |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + protected function send($endpoint, array $args = []) |
|
139 | + { |
|
140 | + $args = wp_parse_args($args, [ |
|
141 | + 'body' => null, |
|
142 | + 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
143 | + 'redirection' => 5, |
|
144 | + 'sslverify' => false, |
|
145 | + 'timeout' => 5, |
|
146 | + ]); |
|
147 | + $this->reset(); |
|
148 | + $this->handleResponse( |
|
149 | + wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
150 | + ); |
|
151 | + } |
|
152 | 152 | } |
@@ -20,25 +20,25 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @return mixed |
22 | 22 | */ |
23 | - public function __get($key) |
|
23 | + public function __get( $key ) |
|
24 | 24 | { |
25 | - return property_exists($this, $key) |
|
25 | + return property_exists( $this, $key ) |
|
26 | 26 | ? $this->$key |
27 | - : Arr::get($this->response, $key, null); |
|
27 | + : Arr::get( $this->response, $key, null ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return self |
32 | 32 | */ |
33 | - public function activateKey($apiKey = '', $email = '') |
|
33 | + public function activateKey( $apiKey = '', $email = '' ) |
|
34 | 34 | { |
35 | - $this->send('api_key_activation.php', [ |
|
35 | + $this->send( 'api_key_activation.php', [ |
|
36 | 36 | 'body' => [ |
37 | 37 | 'apikey' => $apiKey ?: 0, |
38 | 38 | 'domain' => get_home_url(), |
39 | 39 | 'email' => $email ?: 0, |
40 | 40 | ], |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
@@ -56,77 +56,77 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @return self |
58 | 58 | */ |
59 | - public function sendReview(Review $review) |
|
59 | + public function sendReview( Review $review ) |
|
60 | 60 | { |
61 | - $this->send('index.php', [ |
|
62 | - 'body' => $this->getBodyForReview($review), |
|
61 | + $this->send( 'index.php', [ |
|
62 | + 'body' => $this->getBodyForReview( $review ), |
|
63 | 63 | 'timeout' => 120, |
64 | - ]); |
|
64 | + ] ); |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return self |
70 | 70 | */ |
71 | - public function sendReviewResponse(Review $review) |
|
71 | + public function sendReviewResponse( Review $review ) |
|
72 | 72 | { |
73 | - $this->send('fetch_customer_reply.php', [ |
|
74 | - 'body' => $this->getBodyForResponse($review), |
|
75 | - ]); |
|
73 | + $this->send( 'fetch_customer_reply.php', [ |
|
74 | + 'body' => $this->getBodyForResponse( $review ), |
|
75 | + ] ); |
|
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - protected function getBodyForResponse(Review $review) |
|
82 | + protected function getBodyForResponse( Review $review ) |
|
83 | 83 | { |
84 | 84 | $trustalyzeResponse = [ |
85 | - 'reply' => Str::truncate($review->response, 300), |
|
86 | - 'review_id' => glsr(Database::class)->get($review->ID, 'trustalyze'), // this is the trustalyze review ID |
|
85 | + 'reply' => Str::truncate( $review->response, 300 ), |
|
86 | + 'review_id' => glsr( Database::class )->get( $review->ID, 'trustalyze' ), // this is the trustalyze review ID |
|
87 | 87 | 'review_transaction_id' => $review->review_id, |
88 | 88 | 'type' => 'M', |
89 | 89 | ]; |
90 | - return apply_filters('site-reviews/trustalyze/response', $trustalyzeResponse, $review); |
|
90 | + return apply_filters( 'site-reviews/trustalyze/response', $trustalyzeResponse, $review ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - protected function getBodyForReview(Review $review) |
|
96 | + protected function getBodyForReview( Review $review ) |
|
97 | 97 | { |
98 | 98 | $trustalyzeReview = [ |
99 | 99 | 'domain' => get_home_url(), |
100 | - 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
100 | + 'firstname' => Str::truncate( Str::convertName( $review->author, 'first' ), 25 ), |
|
101 | 101 | 'rate' => $review->rating, |
102 | 102 | 'review_transaction_id' => $review->review_id, |
103 | - 'reviews' => Str::truncate($review->content, 280), |
|
104 | - 'title' => Str::truncate($review->title, 35), |
|
103 | + 'reviews' => Str::truncate( $review->content, 280 ), |
|
104 | + 'title' => Str::truncate( $review->title, 35 ), |
|
105 | 105 | 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
106 | 106 | ]; |
107 | - return apply_filters('site-reviews/trustalyze/review', $trustalyzeReview, $review); |
|
107 | + return apply_filters( 'site-reviews/trustalyze/review', $trustalyzeReview, $review ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @param \WP_Error|array $response |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function handleResponse($response) |
|
114 | + protected function handleResponse( $response ) |
|
115 | 115 | { |
116 | - if (is_wp_error($response)) { |
|
116 | + if( is_wp_error( $response ) ) { |
|
117 | 117 | $this->message = $response->get_error_message(); |
118 | 118 | } else { |
119 | - $responseBody = wp_remote_retrieve_body($response); |
|
120 | - $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | - $responseData = (array) json_decode($responseBody, true); |
|
122 | - $this->response = array_shift($responseData); |
|
123 | - $this->message = Arr::get($this->response, 'msg'); |
|
124 | - $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | - if (200 !== $responseCode) { |
|
126 | - glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
119 | + $responseBody = wp_remote_retrieve_body( $response ); |
|
120 | + $responseCode = wp_remote_retrieve_response_code( $response ); |
|
121 | + $responseData = (array)json_decode( $responseBody, true ); |
|
122 | + $this->response = array_shift( $responseData ); |
|
123 | + $this->message = Arr::get( $this->response, 'msg' ); |
|
124 | + $this->success = 'success' === Arr::get( $this->response, 'result' ) || 'yes' === Arr::get( $this->response, 'success' ); // @todo remove this ugly hack! |
|
125 | + if( 200 !== $responseCode ) { |
|
126 | + glsr_log()->error( 'Bad response code ['.$responseCode.']' ); |
|
127 | 127 | } |
128 | - if (!$this->success) { |
|
129 | - glsr_log()->error($this->message); |
|
128 | + if( !$this->success ) { |
|
129 | + glsr_log()->error( $this->message ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | * @param string $endpoint |
136 | 136 | * @return void |
137 | 137 | */ |
138 | - protected function send($endpoint, array $args = []) |
|
138 | + protected function send( $endpoint, array $args = [] ) |
|
139 | 139 | { |
140 | - $args = wp_parse_args($args, [ |
|
140 | + $args = wp_parse_args( $args, [ |
|
141 | 141 | 'body' => null, |
142 | 142 | 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
143 | 143 | 'redirection' => 5, |
144 | 144 | 'sslverify' => false, |
145 | 145 | 'timeout' => 5, |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | $this->reset(); |
148 | 148 | $this->handleResponse( |
149 | - wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
149 | + wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args ) |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } |
@@ -101,7 +101,8 @@ |
||
101 | 101 | { |
102 | 102 | if (is_wp_error($response)) { |
103 | 103 | $this->message = $response->get_error_message(); |
104 | - } else { |
|
104 | + } |
|
105 | + else { |
|
105 | 106 | $responseBody = wp_remote_retrieve_body($response); |
106 | 107 | $responseCode = wp_remote_retrieve_response_code($response); |
107 | 108 | $responseData = (array) json_decode($responseBody, true); |
@@ -1,7 +1,7 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description"> |
4 | - Still need help with <?= glsr()->name; ?>? We offer excellent support, but don't forget to check our <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">documentation</a> first. |
|
4 | + Still need help with <?= glsr()->name; ?>? We offer excellent support, but don't forget to check our <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">documentation</a> first. |
|
5 | 5 | </p> |
6 | 6 | <div class="is-fullwidth"> |
7 | 7 | <div class="glsr-flex-row glsr-has-2-columns"> |