@@ -79,8 +79,8 @@ |
||
79 | 79 | foreach( $blocks as $block ) { |
80 | 80 | $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
81 | 81 | $blockClass = glsr( Helper::class )->buildClassName( $id.'-block', 'Blocks' ); |
82 | - if( !class_exists( $blockClass )) { |
|
83 | - glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass )); |
|
82 | + if( !class_exists( $blockClass ) ) { |
|
83 | + glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) ); |
|
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | glsr( $blockClass )->register( $block ); |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function renderAssignedToMetabox( WP_Post $post ) |
131 | 131 | { |
132 | - if( !$this->isReviewPostType( $post ))return; |
|
132 | + if( !$this->isReviewPostType( $post ) )return; |
|
133 | 133 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
134 | 134 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
135 | 135 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
136 | 136 | 'id' => $assignedTo, |
137 | 137 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
138 | - ]); |
|
138 | + ] ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function renderDetailsMetaBox( WP_Post $post ) |
146 | 146 | { |
147 | - if( !$this->isReviewPostType( $post ))return; |
|
147 | + if( !$this->isReviewPostType( $post ) )return; |
|
148 | 148 | $review = glsr( ReviewManager::class )->single( $post ); |
149 | 149 | glsr()->render( 'partials/editor/metabox-details', [ |
150 | 150 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
151 | 151 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
152 | - ]); |
|
152 | + ] ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function renderPinnedInPublishMetaBox() |
160 | 160 | { |
161 | - if( !$this->isReviewPostType( get_post() ))return; |
|
161 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
162 | 162 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
163 | 163 | 'context' => [ |
164 | 164 | 'no' => __( 'No', 'site-reviews' ), |
165 | 165 | 'yes' => __( 'Yes', 'site-reviews' ), |
166 | 166 | ], |
167 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
168 | - ]); |
|
167 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
168 | + ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function renderResponseMetaBox( WP_Post $post ) |
176 | 176 | { |
177 | - if( !$this->isReviewPostType( $post ))return; |
|
177 | + if( !$this->isReviewPostType( $post ) )return; |
|
178 | 178 | wp_nonce_field( 'response', '_nonce-response', false ); |
179 | 179 | glsr()->render( 'partials/editor/metabox-response', [ |
180 | 180 | 'response' => get_post_meta( $post->ID, 'response', true ), |
181 | - ]); |
|
181 | + ] ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function renderReviewEditor( WP_Post $post ) |
189 | 189 | { |
190 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
190 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
191 | 191 | glsr()->render( 'partials/editor/review', [ |
192 | 192 | 'post' => $post, |
193 | 193 | 'response' => get_post_meta( $post->ID, 'response', true ), |
194 | - ]); |
|
194 | + ] ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $screen = glsr_current_screen(); |
204 | 204 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
205 | 205 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
206 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
206 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function renderReviewNotice( WP_Post $post ) |
214 | 214 | { |
215 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
215 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
216 | 216 | glsr( Notice::class )->addWarning( sprintf( |
217 | 217 | __( '%s reviews are read-only.', 'site-reviews' ), |
218 | 218 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
219 | - )); |
|
219 | + ) ); |
|
220 | 220 | glsr( Template::class )->render( 'partials/editor/notice', [ |
221 | 221 | 'context' => [ |
222 | 222 | 'notices' => glsr( Notice::class )->get(), |
223 | 223 | ], |
224 | - ]); |
|
224 | + ] ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function renderTaxonomyMetabox( WP_Post $post ) |
233 | 233 | { |
234 | - if( !$this->isReviewPostType( $post ))return; |
|
234 | + if( !$this->isReviewPostType( $post ) )return; |
|
235 | 235 | glsr()->render( 'partials/editor/metabox-categories', [ |
236 | 236 | 'post' => $post, |
237 | 237 | 'tax_name' => Application::TAXONOMY, |
238 | 238 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
239 | - ]); |
|
239 | + ] ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function revertReview() |
248 | 248 | { |
249 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
249 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
250 | 250 | glsr( ReviewManager::class )->revert( $postId ); |
251 | 251 | $this->redirect( $postId, 52 ); |
252 | 252 | } |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
270 | 270 | { |
271 | 271 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
272 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
272 | + if( !($assignedPost instanceof WP_Post) )return; |
|
273 | 273 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
274 | 274 | 'context' => [ |
275 | 275 | 'data.url' => (string)get_permalink( $assignedPost ), |
276 | 276 | 'data.title' => get_the_title( $assignedPost ), |
277 | 277 | ], |
278 | - ]); |
|
278 | + ] ); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | 'class' => 'button button-large', |
300 | 300 | 'href' => $revertUrl, |
301 | 301 | 'id' => 'revert', |
302 | - ]); |
|
302 | + ] ); |
|
303 | 303 | } |
304 | 304 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
305 | 305 | 'class' => 'button button-large', |
306 | 306 | 'disabled' => true, |
307 | 307 | 'id' => 'revert', |
308 | - ]); |
|
308 | + ] ); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
319 | 319 | ? glsr()->reviewTypes[$review->review_type] |
320 | 320 | : __( 'Unknown', 'site-reviews' ); |
321 | - if( !empty( $review->url )) { |
|
321 | + if( !empty($review->url) ) { |
|
322 | 322 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
323 | 323 | 'href' => $review->url, |
324 | 324 | 'target' => '_blank', |
325 | - ]); |
|
325 | + ] ); |
|
326 | 326 | } |
327 | 327 | return $reviewType; |
328 | 328 | } |
@@ -351,16 +351,16 @@ discard block |
||
351 | 351 | */ |
352 | 352 | protected function normalizeDetailsMetaBox( Review $review ) |
353 | 353 | { |
354 | - $user = empty( $review->user_id ) |
|
354 | + $user = empty($review->user_id) |
|
355 | 355 | ? __( 'Unregistered user', 'site-reviews' ) |
356 | 356 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
357 | 357 | 'href' => get_author_posts_url( $review->user_id ), |
358 | - ]); |
|
359 | - $email = empty( $review->email ) |
|
358 | + ] ); |
|
359 | + $email = empty($review->email) |
|
360 | 360 | ? '—' |
361 | 361 | : glsr( Builder::class )->a( $review->email, [ |
362 | 362 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
363 | - ]); |
|
363 | + ] ); |
|
364 | 364 | $metabox = [ |
365 | 365 | __( 'Rating', 'site-reviews' ) => glsr( Partial::class )->build( 'star-rating', ['rating' => $review->rating] ), |
366 | 366 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
372 | 372 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
373 | 373 | ]; |
374 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
374 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $redirectUri = $hasReferer |
389 | 389 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
390 | 390 | : get_edit_post_link( $postId ); |
391 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
391 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
392 | 392 | exit; |
393 | 393 | } |
394 | 394 | } |
@@ -90,10 +90,14 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function registerMetaBoxes( $postType, $post ) |
92 | 92 | { |
93 | - if( $postType != Application::POST_TYPE )return; |
|
93 | + if( $postType != Application::POST_TYPE ) { |
|
94 | + return; |
|
95 | + } |
|
94 | 96 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
95 | 97 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
96 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
98 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
99 | + return; |
|
100 | + } |
|
97 | 101 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
98 | 102 | } |
99 | 103 | |
@@ -129,7 +133,9 @@ discard block |
||
129 | 133 | */ |
130 | 134 | public function renderAssignedToMetabox( WP_Post $post ) |
131 | 135 | { |
132 | - if( !$this->isReviewPostType( $post ))return; |
|
136 | + if( !$this->isReviewPostType( $post )) { |
|
137 | + return; |
|
138 | + } |
|
133 | 139 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
134 | 140 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
135 | 141 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -144,7 +150,9 @@ discard block |
||
144 | 150 | */ |
145 | 151 | public function renderDetailsMetaBox( WP_Post $post ) |
146 | 152 | { |
147 | - if( !$this->isReviewPostType( $post ))return; |
|
153 | + if( !$this->isReviewPostType( $post )) { |
|
154 | + return; |
|
155 | + } |
|
148 | 156 | $review = glsr( ReviewManager::class )->single( $post ); |
149 | 157 | glsr()->render( 'partials/editor/metabox-details', [ |
150 | 158 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -158,7 +166,9 @@ discard block |
||
158 | 166 | */ |
159 | 167 | public function renderPinnedInPublishMetaBox() |
160 | 168 | { |
161 | - if( !$this->isReviewPostType( get_post() ))return; |
|
169 | + if( !$this->isReviewPostType( get_post() )) { |
|
170 | + return; |
|
171 | + } |
|
162 | 172 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
163 | 173 | 'context' => [ |
164 | 174 | 'no' => __( 'No', 'site-reviews' ), |
@@ -174,7 +184,9 @@ discard block |
||
174 | 184 | */ |
175 | 185 | public function renderResponseMetaBox( WP_Post $post ) |
176 | 186 | { |
177 | - if( !$this->isReviewPostType( $post ))return; |
|
187 | + if( !$this->isReviewPostType( $post )) { |
|
188 | + return; |
|
189 | + } |
|
178 | 190 | wp_nonce_field( 'response', '_nonce-response', false ); |
179 | 191 | glsr()->render( 'partials/editor/metabox-response', [ |
180 | 192 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -187,7 +199,9 @@ discard block |
||
187 | 199 | */ |
188 | 200 | public function renderReviewEditor( WP_Post $post ) |
189 | 201 | { |
190 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
202 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
203 | + return; |
|
204 | + } |
|
191 | 205 | glsr()->render( 'partials/editor/review', [ |
192 | 206 | 'post' => $post, |
193 | 207 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -201,7 +215,9 @@ discard block |
||
201 | 215 | public function renderReviewFields() |
202 | 216 | { |
203 | 217 | $screen = glsr_current_screen(); |
204 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
218 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
219 | + return; |
|
220 | + } |
|
205 | 221 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
206 | 222 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
207 | 223 | } |
@@ -212,7 +228,9 @@ discard block |
||
212 | 228 | */ |
213 | 229 | public function renderReviewNotice( WP_Post $post ) |
214 | 230 | { |
215 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
231 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
232 | + return; |
|
233 | + } |
|
216 | 234 | glsr( Notice::class )->addWarning( sprintf( |
217 | 235 | __( '%s reviews are read-only.', 'site-reviews' ), |
218 | 236 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -231,7 +249,9 @@ discard block |
||
231 | 249 | */ |
232 | 250 | public function renderTaxonomyMetabox( WP_Post $post ) |
233 | 251 | { |
234 | - if( !$this->isReviewPostType( $post ))return; |
|
252 | + if( !$this->isReviewPostType( $post )) { |
|
253 | + return; |
|
254 | + } |
|
235 | 255 | glsr()->render( 'partials/editor/metabox-categories', [ |
236 | 256 | 'post' => $post, |
237 | 257 | 'tax_name' => Application::TAXONOMY, |
@@ -269,7 +289,9 @@ discard block |
||
269 | 289 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
270 | 290 | { |
271 | 291 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
272 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
292 | + if( !( $assignedPost instanceof WP_Post )) { |
|
293 | + return; |
|
294 | + } |
|
273 | 295 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
274 | 296 | 'context' => [ |
275 | 297 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -314,7 +336,9 @@ discard block |
||
314 | 336 | */ |
315 | 337 | protected function getReviewType( $review ) |
316 | 338 | { |
317 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
339 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
340 | + return; |
|
341 | + } |
|
318 | 342 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
319 | 343 | ? glsr()->reviewTypes[$review->review_type] |
320 | 344 | : __( 'Unknown', 'site-reviews' ); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | register_rest_route( $this->namespace, '/types', [ |
29 | 29 | 'callback' => [$this, 'get_types'], |
30 | 30 | 'methods' => Server::READABLE, |
31 | - ]); |
|
31 | + ] ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -33,6 +33,6 @@ |
||
33 | 33 | 'permission_callback' => [$this, 'get_items_permissions_check'], |
34 | 34 | ], |
35 | 35 | 'schema' => [$this, 'get_public_item_schema'], |
36 | - ]); |
|
36 | + ] ); |
|
37 | 37 | } |
38 | 38 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'title' => 'Images', |
18 | 18 | ], |
19 | 19 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | $template->render( 'partials/addons/addon', [ |
22 | 22 | 'context' => [ |
23 | 23 | 'description' => __( 'Sync your Tripadvisor reviews to your website and manage them with Site Reviews.', 'site-reviews' ), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'title' => 'Tripadvisor Reviews', |
27 | 27 | ], |
28 | 28 | 'plugin' => 'site-reviews-tripadvisor/site-reviews-tripadvisor.php', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | ?> |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function renderTaxonomyFilter() |
37 | 37 | { |
38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) )return; |
|
39 | 39 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
40 | 40 | 'class' => 'screen-reader-text', |
41 | 41 | 'for' => Application::TAXONOMY, |
42 | - ]); |
|
43 | - wp_dropdown_categories([ |
|
42 | + ] ); |
|
43 | + wp_dropdown_categories( [ |
|
44 | 44 | 'depth' => 3, |
45 | 45 | 'hide_empty' => true, |
46 | 46 | 'hide_if_empty' => true, |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'show_option_all' => $this->getShowOptionAll(), |
53 | 53 | 'taxonomy' => Application::TAXONOMY, |
54 | 54 | 'value_field' => 'slug', |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | protected function getSelected() |
62 | 62 | { |
63 | 63 | global $wp_query; |
64 | - return isset( $wp_query->query[Application::TAXONOMY] ) |
|
64 | + return isset($wp_query->query[Application::TAXONOMY]) |
|
65 | 65 | ? $wp_query->query[Application::TAXONOMY] |
66 | 66 | : ''; |
67 | 67 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $taxonomy = get_taxonomy( Application::TAXONOMY ); |
75 | 75 | return $taxonomy |
76 | - ? ucfirst( strtolower( $taxonomy->labels->all_items )) |
|
76 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
77 | 77 | : ''; |
78 | 78 | } |
79 | 79 | } |
@@ -35,7 +35,9 @@ |
||
35 | 35 | */ |
36 | 36 | public function renderTaxonomyFilter() |
37 | 37 | { |
38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY )) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
40 | 42 | 'class' => 'screen-reader-text', |
41 | 43 | 'for' => Application::TAXONOMY, |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | 'post_type' => Application::POST_TYPE, |
36 | 36 | ]; |
37 | 37 | $postId = wp_insert_post( $postValues, true ); |
38 | - if( is_wp_error( $postId )) { |
|
38 | + if( is_wp_error( $postId ) ) { |
|
39 | 39 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | $this->setTerms( $postId, $command->category ); |
43 | - $review = $this->single( get_post( $postId )); |
|
43 | + $review = $this->single( get_post( $postId ) ); |
|
44 | 44 | do_action( 'site-reviews/review/created', $review, $command ); |
45 | 45 | return $review; |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function delete( $metaReviewId ) |
53 | 53 | { |
54 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
54 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
55 | 55 | wp_delete_post( $postId, true ); |
56 | 56 | } |
57 | 57 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $paged = glsr( QueryBuilder::class )->getPaged( |
74 | 74 | wp_validate_boolean( $args['pagination'] ) |
75 | 75 | ); |
76 | - $reviews = new WP_Query([ |
|
76 | + $reviews = new WP_Query( [ |
|
77 | 77 | 'meta_key' => 'pinned', |
78 | 78 | 'meta_query' => $metaQuery, |
79 | 79 | 'offset' => $args['offset'], |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'post_type' => Application::POST_TYPE, |
87 | 87 | 'posts_per_page' => $args['count'], |
88 | 88 | 'tax_query' => $taxQuery, |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | return (object)[ |
91 | 91 | 'results' => array_map( [$this, 'single'], $reviews->posts ), |
92 | 92 | 'max_num_pages' => $reviews->max_num_pages, |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $terms = []; |
112 | 112 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
113 | 113 | foreach( $termIds as $termId ) { |
114 | - if( is_numeric( $termId )) { |
|
114 | + if( is_numeric( $termId ) ) { |
|
115 | 115 | $termId = intval( $termId ); |
116 | 116 | } |
117 | 117 | $term = term_exists( $termId, Application::TAXONOMY ); |
118 | - if( !isset( $term['term_id'] ))continue; |
|
118 | + if( !isset($term['term_id']) )continue; |
|
119 | 119 | $terms[] = intval( $term['term_id'] ); |
120 | 120 | } |
121 | 121 | return $terms; |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | { |
130 | 130 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
131 | 131 | delete_post_meta( $postId, '_edit_last' ); |
132 | - $result = wp_update_post([ |
|
132 | + $result = wp_update_post( [ |
|
133 | 133 | 'ID' => $postId, |
134 | 134 | 'post_content' => get_post_meta( $postId, 'content', true ), |
135 | 135 | 'post_date' => get_post_meta( $postId, 'date', true ), |
136 | 136 | 'post_title' => get_post_meta( $postId, 'title', true ), |
137 | - ]); |
|
138 | - if( is_wp_error( $result )) { |
|
137 | + ] ); |
|
138 | + if( is_wp_error( $result ) ) { |
|
139 | 139 | glsr_log()->error( $result->get_error_message() ); |
140 | 140 | } |
141 | 141 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
158 | 158 | { |
159 | 159 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
160 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
160 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
161 | 161 | ? 'pending' |
162 | 162 | : 'publish'; |
163 | 163 | } |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | protected function setTerms( $postId, $termIds ) |
171 | 171 | { |
172 | 172 | $terms = $this->normalizeTerms( $termIds ); |
173 | - if( empty( $terms ))return; |
|
173 | + if( empty($terms) )return; |
|
174 | 174 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
175 | - if( is_wp_error( $result )) { |
|
175 | + if( is_wp_error( $result ) ) { |
|
176 | 176 | glsr_log()->error( $result->get_error_message() ); |
177 | 177 | } |
178 | 178 | } |
@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | $termId = intval( $termId ); |
116 | 116 | } |
117 | 117 | $term = term_exists( $termId, Application::TAXONOMY ); |
118 | - if( !isset( $term['term_id'] ))continue; |
|
118 | + if( !isset( $term['term_id'] )) { |
|
119 | + continue; |
|
120 | + } |
|
119 | 121 | $terms[] = intval( $term['term_id'] ); |
120 | 122 | } |
121 | 123 | return $terms; |
@@ -127,7 +129,9 @@ discard block |
||
127 | 129 | */ |
128 | 130 | public function revert( $postId ) |
129 | 131 | { |
130 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
132 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
133 | + return; |
|
134 | + } |
|
131 | 135 | delete_post_meta( $postId, '_edit_last' ); |
132 | 136 | $result = wp_update_post([ |
133 | 137 | 'ID' => $postId, |
@@ -145,7 +149,9 @@ discard block |
||
145 | 149 | */ |
146 | 150 | public function single( WP_Post $post ) |
147 | 151 | { |
148 | - if( $post->post_type != Application::POST_TYPE )return; |
|
152 | + if( $post->post_type != Application::POST_TYPE ) { |
|
153 | + return; |
|
154 | + } |
|
149 | 155 | $review = new Review( $post ); |
150 | 156 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
151 | 157 | } |
@@ -170,7 +176,9 @@ discard block |
||
170 | 176 | protected function setTerms( $postId, $termIds ) |
171 | 177 | { |
172 | 178 | $terms = $this->normalizeTerms( $termIds ); |
173 | - if( empty( $terms ))return; |
|
179 | + if( empty( $terms )) { |
|
180 | + return; |
|
181 | + } |
|
174 | 182 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
175 | 183 | if( is_wp_error( $result )) { |
176 | 184 | glsr_log()->error( $result->get_error_message() ); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->getCounts(), |
67 | 67 | $review->review_type, |
68 | 68 | $review->rating |
69 | - )); |
|
69 | + ) ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return; |
|
78 | 78 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 79 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function decreaseTermCounts( Review $review ) |
86 | 86 | { |
87 | 87 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
88 | + if( empty($counts = $this->getTermCounts( $termId )) )continue; |
|
89 | 89 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 90 | $this->setTermCounts( $termId, $counts ); |
91 | 91 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | public function flatten( array $reviewCounts, array $args = [] ) |
98 | 98 | { |
99 | 99 | $counts = []; |
100 | - array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) { |
|
101 | - $counts[$index] = isset( $counts[$index] ) |
|
100 | + array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) { |
|
101 | + $counts[$index] = isset($counts[$index]) |
|
102 | 102 | ? $num + $counts[$index] |
103 | 103 | : $num; |
104 | 104 | }); |
105 | 105 | $args = wp_parse_args( $args, [ |
106 | 106 | 'max' => Rating::MAX_RATING, |
107 | 107 | 'min' => Rating::MIN_RATING, |
108 | - ]); |
|
108 | + ] ); |
|
109 | 109 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
111 | 111 | $num = 0; |
112 | 112 | } |
113 | 113 | return $counts; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'post_ids' => [], |
123 | 123 | 'term_ids' => [], |
124 | 124 | 'type' => 'local', |
125 | - ]); |
|
125 | + ] ); |
|
126 | 126 | $counts = []; |
127 | 127 | foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) { |
128 | 128 | $counts[] = $this->getPostCounts( $postId ); |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | foreach( $args['term_ids'] as $termId ) { |
131 | 131 | $counts[] = $this->getTermCounts( $termId ); |
132 | 132 | } |
133 | - if( empty( $counts )) { |
|
133 | + if( empty($counts) ) { |
|
134 | 134 | $counts[] = $this->getCounts(); |
135 | 135 | } |
136 | 136 | return in_array( $args['type'], ['', 'all'] ) |
137 | 137 | ? $this->normalize( [$this->flatten( $counts )] ) |
138 | - : $this->normalize( array_column( $counts, $args['type'] )); |
|
138 | + : $this->normalize( array_column( $counts, $args['type'] ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function getCounts() |
145 | 145 | { |
146 | 146 | $counts = glsr( OptionManager::class )->get( 'counts', [] ); |
147 | - if( !is_array( $counts )) { |
|
147 | + if( !is_array( $counts ) ) { |
|
148 | 148 | glsr_log()->error( 'CountsManager: counts is not an array' )->debug( $counts ); |
149 | 149 | return []; |
150 | 150 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function getPostCounts( $postId ) |
159 | 159 | { |
160 | - return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true )); |
|
160 | + return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function getTermCounts( $termId ) |
168 | 168 | { |
169 | - return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true )); |
|
169 | + return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function increaseCounts( Review $review ) |
186 | 186 | { |
187 | - if( empty( $counts = $this->getCounts() )) { |
|
187 | + if( empty($counts = $this->getCounts()) ) { |
|
188 | 188 | $counts = $this->buildCounts(); |
189 | 189 | } |
190 | 190 | $this->setCounts( $this->increaseRating( |
191 | 191 | $counts, |
192 | 192 | $review->review_type, |
193 | 193 | $review->rating |
194 | - )); |
|
194 | + ) ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function increasePostCounts( Review $review ) |
201 | 201 | { |
202 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
202 | + if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return; |
|
203 | 203 | $counts = $this->getPostCounts( $review->assigned_to ); |
204 | - $counts = empty( $counts ) |
|
204 | + $counts = empty($counts) |
|
205 | 205 | ? $this->buildPostCounts( $review->assigned_to ) |
206 | 206 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
207 | 207 | $this->setPostCounts( $review->assigned_to, $counts ); |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function increaseTermCounts( Review $review ) |
214 | 214 | { |
215 | - $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids )); |
|
215 | + $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) ); |
|
216 | 216 | foreach( $termIds as $termId ) { |
217 | 217 | $counts = $this->getTermCounts( $termId ); |
218 | - $counts = empty( $counts ) |
|
218 | + $counts = empty($counts) |
|
219 | 219 | ? $this->buildTermCounts( $termId ) |
220 | 220 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
221 | 221 | $this->setTermCounts( $termId, $counts ); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | { |
239 | 239 | $ratingCounts = $this->flatten( $reviewCounts ); |
240 | 240 | update_post_meta( $postId, static::META_COUNT, $reviewCounts ); |
241 | - update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
242 | - update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
241 | + update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
242 | + update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function setTermCounts( $termId, array $reviewCounts ) |
250 | 250 | { |
251 | - if( !term_exists( $termId ))return; |
|
251 | + if( !term_exists( $termId ) )return; |
|
252 | 252 | $ratingCounts = $this->flatten( $reviewCounts ); |
253 | 253 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
254 | - update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
255 | - update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
254 | + update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
255 | + update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | { |
264 | 264 | $counts = []; |
265 | 265 | $lastPostId = 0; |
266 | - while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
|
267 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
268 | - $types = array_unique( array_merge( ['local'], $types )); |
|
266 | + while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) { |
|
267 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
268 | + $types = array_unique( array_merge( ['local'], $types ) ); |
|
269 | 269 | foreach( $types as $type ) { |
270 | 270 | $type = $this->normalizeType( $type ); |
271 | - if( isset( $counts[$type] ))continue; |
|
271 | + if( isset($counts[$type]) )continue; |
|
272 | 272 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
273 | 273 | } |
274 | 274 | foreach( $reviews as $review ) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function decreaseRating( array $reviewCounts, $type, $rating ) |
289 | 289 | { |
290 | - if( isset( $reviewCounts[$type][$rating] )) { |
|
290 | + if( isset($reviewCounts[$type][$rating]) ) { |
|
291 | 291 | $reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 ); |
292 | 292 | } |
293 | 293 | return $reviewCounts; |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | */ |
301 | 301 | protected function increaseRating( array $reviewCounts, $type, $rating ) |
302 | 302 | { |
303 | - if( !array_key_exists( $type, glsr()->reviewTypes )) { |
|
303 | + if( !array_key_exists( $type, glsr()->reviewTypes ) ) { |
|
304 | 304 | return $reviewCounts; |
305 | 305 | } |
306 | - if( !array_key_exists( $type, $reviewCounts )) { |
|
306 | + if( !array_key_exists( $type, $reviewCounts ) ) { |
|
307 | 307 | $reviewCounts[$type] = []; |
308 | 308 | } |
309 | 309 | $reviewCounts = $this->normalize( $reviewCounts ); |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | */ |
317 | 317 | protected function normalize( array $reviewCounts ) |
318 | 318 | { |
319 | - if( empty( $reviewCounts )) { |
|
319 | + if( empty($reviewCounts) ) { |
|
320 | 320 | $reviewCounts = [[]]; |
321 | 321 | } |
322 | 322 | foreach( $reviewCounts as &$counts ) { |
323 | 323 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
324 | - if( isset( $counts[$index] ))continue; |
|
324 | + if( isset($counts[$index]) )continue; |
|
325 | 325 | $counts[$index] = 0; |
326 | 326 | } |
327 | 327 | ksort( $counts ); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | protected function normalizeType( $type ) |
337 | 337 | { |
338 | - return empty( $type ) || !is_string( $type ) |
|
338 | + return empty($type) || !is_string( $type ) |
|
339 | 339 | ? 'local' |
340 | 340 | : $type; |
341 | 341 | } |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | */ |
348 | 348 | protected function queryReviews( array $args = [], $lastPostId, $limit ) |
349 | 349 | { |
350 | - $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' )); |
|
351 | - if( empty( array_filter( $args ))) { |
|
350 | + $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) ); |
|
351 | + if( empty(array_filter( $args )) ) { |
|
352 | 352 | return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit ); |
353 | 353 | } |
354 | - if( !empty( $args['post_id'] )) { |
|
354 | + if( !empty($args['post_id']) ) { |
|
355 | 355 | return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit ); |
356 | 356 | } |
357 | - if( !empty( $args['term_id'] )) { |
|
357 | + if( !empty($args['term_id']) ) { |
|
358 | 358 | return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit ); |
359 | 359 | } |
360 | 360 | } |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
78 | + return; |
|
79 | + } |
|
78 | 80 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 81 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 82 | } |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | public function decreaseTermCounts( Review $review ) |
86 | 88 | { |
87 | 89 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
90 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
91 | + continue; |
|
92 | + } |
|
89 | 93 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 94 | $this->setTermCounts( $termId, $counts ); |
91 | 95 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | 'min' => Rating::MIN_RATING, |
108 | 112 | ]); |
109 | 113 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
114 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
115 | + continue; |
|
116 | + } |
|
111 | 117 | $num = 0; |
112 | 118 | } |
113 | 119 | return $counts; |
@@ -199,7 +205,9 @@ discard block |
||
199 | 205 | */ |
200 | 206 | public function increasePostCounts( Review $review ) |
201 | 207 | { |
202 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
208 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
209 | + return; |
|
210 | + } |
|
203 | 211 | $counts = $this->getPostCounts( $review->assigned_to ); |
204 | 212 | $counts = empty( $counts ) |
205 | 213 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -248,7 +256,9 @@ discard block |
||
248 | 256 | */ |
249 | 257 | public function setTermCounts( $termId, array $reviewCounts ) |
250 | 258 | { |
251 | - if( !term_exists( $termId ))return; |
|
259 | + if( !term_exists( $termId )) { |
|
260 | + return; |
|
261 | + } |
|
252 | 262 | $ratingCounts = $this->flatten( $reviewCounts ); |
253 | 263 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
254 | 264 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -268,7 +278,9 @@ discard block |
||
268 | 278 | $types = array_unique( array_merge( ['local'], $types )); |
269 | 279 | foreach( $types as $type ) { |
270 | 280 | $type = $this->normalizeType( $type ); |
271 | - if( isset( $counts[$type] ))continue; |
|
281 | + if( isset( $counts[$type] )) { |
|
282 | + continue; |
|
283 | + } |
|
272 | 284 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
273 | 285 | } |
274 | 286 | foreach( $reviews as $review ) { |
@@ -321,7 +333,9 @@ discard block |
||
321 | 333 | } |
322 | 334 | foreach( $reviewCounts as &$counts ) { |
323 | 335 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
324 | - if( isset( $counts[$index] ))continue; |
|
336 | + if( isset( $counts[$index] )) { |
|
337 | + continue; |
|
338 | + } |
|
325 | 339 | $counts[$index] = 0; |
326 | 340 | } |
327 | 341 | ksort( $counts ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function enqueueAssets() |
25 | 25 | { |
26 | - $command = new EnqueueAdminAssets([ |
|
26 | + $command = new EnqueueAdminAssets( [ |
|
27 | 27 | 'pointers' => [[ |
28 | 28 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
29 | 29 | 'id' => 'glsr-pointer-pinned', |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'target' => '#misc-pub-pinned', |
36 | 36 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
37 | 37 | ]], |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | $this->execute( $command ); |
40 | 40 | } |
41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
49 | 49 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | return $links; |
52 | 52 | } |
53 | 53 | |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | public function filterDashboardGlanceItems( array $items ) |
59 | 59 | { |
60 | 60 | $postCount = wp_count_posts( Application::POST_TYPE ); |
61 | - if( empty( $postCount->publish )) { |
|
61 | + if( empty($postCount->publish) ) { |
|
62 | 62 | return $items; |
63 | 63 | } |
64 | 64 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
65 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
65 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
66 | 66 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
67 | 67 | ? glsr( Builder::class )->a( $text, [ |
68 | 68 | 'class' => 'glsr-review-count', |
69 | 69 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
70 | - ]) |
|
70 | + ] ) |
|
71 | 71 | : glsr( Builder::class )->span( $text, [ |
72 | 72 | 'class' => 'glsr-review-count', |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | return $items; |
75 | 75 | } |
76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function filterTinymcePlugins( array $plugins ) |
82 | 82 | { |
83 | - if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) { |
|
83 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
84 | 84 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
85 | 85 | } |
86 | 86 | return $plugins; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function registerTinymcePopups() |
94 | 94 | { |
95 | - $command = new RegisterTinymcePopups([ |
|
95 | + $command = new RegisterTinymcePopups( [ |
|
96 | 96 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
97 | 97 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
98 | 98 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
99 | - ]); |
|
99 | + ] ); |
|
100 | 100 | $this->execute( $command ); |
101 | 101 | } |
102 | 102 | |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | public function renderTinymceButton( $editorId ) |
109 | 109 | { |
110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] ); |
111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return; |
|
112 | 112 | $shortcodes = []; |
113 | 113 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
114 | 114 | $shortcodes[$shortcode] = $values; |
115 | 115 | } |
116 | - if( empty( $shortcodes ))return; |
|
116 | + if( empty($shortcodes) )return; |
|
117 | 117 | glsr()->render( 'partials/editor/tinymce', [ |
118 | 118 | 'shortcodes' => $shortcodes, |
119 | - ]); |
|
119 | + ] ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function routerClearConsole() |
126 | 126 | { |
127 | 127 | glsr( Console::class )->clear(); |
128 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
128 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function routerFetchConsole() |
135 | 135 | { |
136 | - glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' )); |
|
136 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,22 +143,22 @@ discard block |
||
143 | 143 | public function routerCountReviews( $showNotice = true ) |
144 | 144 | { |
145 | 145 | $countManager = glsr( CountsManager::class ); |
146 | - $terms = get_terms([ |
|
146 | + $terms = get_terms( [ |
|
147 | 147 | 'hide_empty' => true, |
148 | 148 | 'taxonomy' => Application::TAXONOMY, |
149 | - ]); |
|
149 | + ] ); |
|
150 | 150 | foreach( $terms as $term ) { |
151 | - $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id )); |
|
151 | + $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) ); |
|
152 | 152 | } |
153 | 153 | $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' ); |
154 | 154 | foreach( $postIds as $postId ) { |
155 | - $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId )); |
|
155 | + $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) ); |
|
156 | 156 | } |
157 | 157 | $countManager->setCounts( $countManager->buildCounts() ); |
158 | 158 | if( $showNotice ) { |
159 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
159 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
160 | 160 | } |
161 | - glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' )); |
|
161 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | { |
193 | 193 | $file = $_FILES['import-file']; |
194 | 194 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
195 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
195 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
196 | 196 | } |
197 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
198 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
197 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
198 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
199 | 199 | } |
200 | 200 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
201 | - if( empty( $settings )) { |
|
202 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
201 | + if( empty($settings) ) { |
|
202 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
203 | 203 | } |
204 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
205 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
204 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
205 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
221 | 221 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
222 | 222 | ]; |
223 | - return !isset( $errors[$errorCode] ) |
|
223 | + return !isset($errors[$errorCode]) |
|
224 | 224 | ? __( 'Unknown upload error.', 'site-reviews' ) |
225 | 225 | : $errors[$errorCode]; |
226 | 226 | } |
@@ -108,12 +108,16 @@ |
||
108 | 108 | public function renderTinymceButton( $editorId ) |
109 | 109 | { |
110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] ); |
111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | $shortcodes = []; |
113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
114 | 116 | $shortcodes[$shortcode] = $values; |
115 | 117 | } |
116 | - if( empty( $shortcodes ))return; |
|
118 | + if( empty( $shortcodes )) { |
|
119 | + return; |
|
120 | + } |
|
117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
118 | 122 | 'shortcodes' => $shortcodes, |
119 | 123 | ]); |