@@ -14,14 +14,14 @@ |
||
14 | 14 | { |
15 | 15 | foreach( $command->shortcodes as $slug => $label ) { |
16 | 16 | $buttonClass = glsr( Helper::class )->buildClassName( $slug.'-button', 'Shortcodes' ); |
17 | - if( !class_exists( $buttonClass )) { |
|
18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass )); |
|
17 | + if( !class_exists( $buttonClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | $shortcode = glsr( $buttonClass )->register( $slug, [ |
22 | 22 | 'label' => $label, |
23 | 23 | 'title' => $label, |
24 | - ]); |
|
24 | + ] ); |
|
25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
26 | 26 | } |
27 | 27 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | foreach( $command->shortcodes as $shortcode ) { |
16 | 16 | $shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
17 | - if( !class_exists( $shortcodeClass )) { |
|
18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass )); |
|
17 | + if( !class_exists( $shortcodeClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
@@ -16,8 +16,8 @@ |
||
16 | 16 | global $wp_widget_factory; |
17 | 17 | foreach( $command->widgets as $key => $values ) { |
18 | 18 | $widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' ); |
19 | - if( !class_exists( $widgetClass )) { |
|
20 | - glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass )); |
|
19 | + if( !class_exists( $widgetClass ) ) { |
|
20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - if( !get_post( $command->id )) { |
|
15 | + if( !get_post( $command->id ) ) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | - if( is_null( $command->pinned )) { |
|
18 | + if( is_null( $command->pinned ) ) { |
|
19 | 19 | $meta = get_post_meta( $command->id, 'pinned', true ); |
20 | 20 | $command->pinned = !wp_validate_boolean( $meta ); |
21 | 21 | } |
@@ -38,20 +38,20 @@ |
||
38 | 38 | */ |
39 | 39 | public function run() |
40 | 40 | { |
41 | - add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
42 | - add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
43 | - add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
41 | + add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
42 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
43 | + add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
44 | 44 | // add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
45 | 45 | // add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
46 | 46 | // add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 ); |
47 | 47 | // add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 ); |
48 | 48 | // add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
49 | - add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
50 | - add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
51 | - add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
52 | - add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
49 | + add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
50 | + add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
51 | + add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
52 | + add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
53 | 53 | add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] ); |
54 | - add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
54 | + add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
55 | 55 | // add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
56 | 56 | // add_filter( 'query_vars', [$this->public, 'filterQueryVars'] ); |
57 | 57 | // add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 ); |
@@ -22,7 +22,8 @@ |
||
22 | 22 | // protected $public; |
23 | 23 | // protected $translator; |
24 | 24 | |
25 | - public function __construct( Application $app ) { |
|
25 | + public function __construct( Application $app ) |
|
26 | + { |
|
26 | 27 | $this->app = $app; |
27 | 28 | $this->admin = $app->make( AdminController::class ); |
28 | 29 | $this->basename = plugin_basename( $app->file ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
29 | 29 | 'published' => __( 'Approved', 'site-reviews' ), |
30 | 30 | ]; |
31 | - if( $this->canModifyTranslation() && isset( $wp_scripts->registered['post']->extra['data'] )) { |
|
31 | + if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) { |
|
32 | 32 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
33 | 33 | foreach( $strings as $search => $replace ) { |
34 | 34 | $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', "$1".$replace, $l10n ); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function filterPostStatusLabels( $translation, $text, $domain ) |
78 | 78 | { |
79 | - if( $this->canModifyTranslation( $domain )) { |
|
79 | + if( $this->canModifyTranslation( $domain ) ) { |
|
80 | 80 | $replacements = [ |
81 | 81 | 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
82 | 82 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | public function filterUpdateMessages( array $messages ) |
112 | 112 | { |
113 | 113 | $post = get_post(); |
114 | - if( !( $post instanceof WP_Post ))return; |
|
114 | + if( !($post instanceof WP_Post) )return; |
|
115 | 115 | $strings = glsr( Strings::class )->post_updated_messages(); |
116 | 116 | $restored = filter_input( INPUT_GET, 'revision' ); |
117 | - if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
|
117 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
118 | 118 | $restored = sprintf( $strings['restored'], $revisionTitle ); |
119 | 119 | } |
120 | - $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date )); |
|
121 | - $messages[ Application::POST_TYPE ] = [ |
|
120 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
121 | + $messages[Application::POST_TYPE] = [ |
|
122 | 122 | 1 => $strings['updated'], |
123 | 123 | 4 => $strings['updated'], |
124 | 124 | 5 => $restored, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function onCreateReview( $postData, $meta, $postId ) |
144 | 144 | { |
145 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
145 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
146 | 146 | $this->updateAssignedToPost( $review ); |
147 | 147 | } |
148 | 148 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function onDeleteReview( $postId ) |
155 | 155 | { |
156 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
156 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
157 | 157 | $review->post_status = 'deleted'; // important to change the post_status here first! |
158 | 158 | $this->updateAssignedToPost( $review ); |
159 | 159 | } |
@@ -207,24 +207,24 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function renderAssignedToMetabox( WP_Post $post ) |
209 | 209 | { |
210 | - if( !$this->isReviewPostType( $post ))return; |
|
210 | + if( !$this->isReviewPostType( $post ) )return; |
|
211 | 211 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
212 | 212 | $template = ''; |
213 | - if( $assignedPost = get_post( $assignedTo )) { |
|
213 | + if( $assignedPost = get_post( $assignedTo ) ) { |
|
214 | 214 | ob_start(); |
215 | 215 | glsr( Html::class )->renderTemplate( 'edit/assigned-post', [ |
216 | 216 | 'context' => [ |
217 | 217 | 'url' => (string)get_permalink( $assignedPost ), |
218 | 218 | 'title' => get_the_title( $assignedPost ), |
219 | 219 | ], |
220 | - ]); |
|
220 | + ] ); |
|
221 | 221 | $template = ob_get_clean(); |
222 | 222 | } |
223 | 223 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
224 | 224 | glsr()->render( 'edit/metabox-assigned-to', [ |
225 | 225 | 'id' => $assignedTo, |
226 | 226 | 'template' => $template, |
227 | - ]); |
|
227 | + ] ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function renderDetailsMetaBox( WP_Post $post ) |
235 | 235 | { |
236 | - if( !$this->isReviewPostType( $post ))return; |
|
236 | + if( !$this->isReviewPostType( $post ) )return; |
|
237 | 237 | $review = glsr_db()->getReview( $post ); |
238 | 238 | glsr()->render( 'edit/metabox-details', [ |
239 | 239 | 'button' => $this->getMetaboxButton( $review, $post ), |
240 | 240 | 'metabox' => $this->getMetaboxDetails( $review ), |
241 | - ]); |
|
241 | + ] ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function renderMetaBoxPinned() |
249 | 249 | { |
250 | - if( !$this->isReviewPostType( get_post() ))return; |
|
250 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
251 | 251 | $pinned = get_post_meta( get_the_ID(), 'pinned', true ); |
252 | 252 | glsr()->render( 'edit/pinned', [ |
253 | 253 | 'pinned' => $pinned, |
254 | - ]); |
|
254 | + ] ); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function renderResponseMetaBox( WP_Post $post ) |
262 | 262 | { |
263 | - if( !$this->isReviewPostType( $post ))return; |
|
263 | + if( !$this->isReviewPostType( $post ) )return; |
|
264 | 264 | $review = glsr_db()->getReview( $post ); |
265 | 265 | wp_nonce_field( 'response', '_nonce-response', false ); |
266 | 266 | glsr()->render( 'edit/metabox-response', [ |
267 | 267 | 'response' => $review->response, |
268 | - ]); |
|
268 | + ] ); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function renderTaxonomyMetabox( WP_Post $post ) |
277 | 277 | { |
278 | - if( !$this->isReviewPostType( $post ))return; |
|
278 | + if( !$this->isReviewPostType( $post ) )return; |
|
279 | 279 | glsr()->render( 'edit/metabox-categories', [ |
280 | 280 | 'post' => $post, |
281 | 281 | 'tax_name' => esc_attr( Application::TAXONOMY ), |
282 | 282 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
283 | - ]); |
|
283 | + ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function revert() |
292 | 292 | { |
293 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
293 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
294 | 294 | glsr_db()->revertReview( $postId ); |
295 | 295 | $this->redirect( $postId, 52 ); |
296 | 296 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | protected function getAssignedToPostId( $postId ) |
325 | 325 | { |
326 | 326 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
327 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
327 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
328 | 328 | return $post->ID; |
329 | 329 | } |
330 | 330 | return false; |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | 'revert-review_'.$post->ID |
348 | 348 | ); |
349 | 349 | return !$modified |
350 | - ? sprintf( '<button id="revert" class="button button-large" disabled>%s</button>', __( 'Nothing to Revert', 'site-reviews' )) |
|
351 | - : sprintf( '<a href="%s" id="revert" class="button button-large">%s</a>', $revertUrl, __( 'Revert Changes', 'site-reviews' )); |
|
350 | + ? sprintf( '<button id="revert" class="button button-large" disabled>%s</button>', __( 'Nothing to Revert', 'site-reviews' ) ) |
|
351 | + : sprintf( '<a href="%s" id="revert" class="button button-large">%s</a>', $revertUrl, __( 'Revert Changes', 'site-reviews' ) ); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | */ |
358 | 358 | protected function getMetaboxDetails( $review ) |
359 | 359 | { |
360 | - $reviewer = empty( $review->user_id ) |
|
360 | + $reviewer = empty($review->user_id) |
|
361 | 361 | ? __( 'Unregistered user', 'site-reviews' ) |
362 | 362 | : $this->generateLink( get_the_author_meta( 'display_name', $review->user_id ), [ |
363 | 363 | 'href' => get_author_posts_url( $review->user_id ), |
364 | - ]); |
|
365 | - $email = empty( $review->email ) |
|
364 | + ] ); |
|
365 | + $email = empty($review->email) |
|
366 | 366 | ? '—' |
367 | 367 | : $this->generateLink( $review->email, [ |
368 | 368 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
369 | - ]); |
|
369 | + ] ); |
|
370 | 370 | $metabox = [ |
371 | 371 | __( 'Rating', 'site-reviews' ) => glsr( Html::class )->renderPartial( 'star-rating', ['rating' => $review->rating] ), |
372 | 372 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | protected function getReviewType( $review ) |
388 | 388 | { |
389 | 389 | $reviewType = $review->review_type; |
390 | - $reviewTypeFallback = !empty( $review->review_type ) |
|
390 | + $reviewTypeFallback = !empty($review->review_type) |
|
391 | 391 | ? ucfirst( $review->review_type ) |
392 | 392 | : __( 'Unknown', 'site-reviews' ); |
393 | - if( !empty( $review->url )) { |
|
393 | + if( !empty($review->url) ) { |
|
394 | 394 | $reviewType = $this->generateLink( $reviewType, [ |
395 | 395 | 'href' => $review->url, |
396 | 396 | 'target' => '_blank', |
397 | - ]); |
|
397 | + ] ); |
|
398 | 398 | } |
399 | 399 | return sprintf( __( '%s review', 'site-reviews' ), |
400 | 400 | glsr( Strings::class )->review_types( $reviewType, $reviewTypeFallback ) |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | protected function isReviewEditable() |
408 | 408 | { |
409 | - $postId = intval( filter_input( INPUT_GET, 'post' )); |
|
409 | + $postId = intval( filter_input( INPUT_GET, 'post' ) ); |
|
410 | 410 | return $postId > 0 |
411 | 411 | && get_post_meta( $postId, 'review_type', true ) == 'local' |
412 | 412 | && $this->isReviewEditor(); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $redirectUri = $hasReferer |
462 | 462 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
463 | 463 | : get_edit_post_link( $postId, false ); |
464 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
464 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
465 | 465 | exit; |
466 | 466 | } |
467 | 467 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | protected function saveAssignedToMetabox( $postId ) |
473 | 473 | { |
474 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
474 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
475 | 475 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
476 | 476 | $assignedTo || $assignedTo = ''; |
477 | 477 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -486,14 +486,14 @@ discard block |
||
486 | 486 | */ |
487 | 487 | protected function saveResponseMetabox( $postId ) |
488 | 488 | { |
489 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
489 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return; |
|
490 | 490 | $response = filter_input( INPUT_POST, 'response' ); |
491 | 491 | $response || $response = ''; |
492 | 492 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
493 | 493 | 'a' => ['href' => [], 'title' => []], |
494 | 494 | 'em' => [], |
495 | 495 | 'strong' => [], |
496 | - ]))); |
|
496 | + ] ) ) ); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -501,21 +501,21 @@ discard block |
||
501 | 501 | */ |
502 | 502 | protected function updateAssignedToPost( WP_Post $review ) |
503 | 503 | { |
504 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
504 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
505 | 505 | $reviewIds = get_post_meta( $postId, static::META_REVIEW_ID ); |
506 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
506 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
507 | 507 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
508 | - if( empty( $updatedReviewIds )) { |
|
508 | + if( empty($updatedReviewIds) ) { |
|
509 | 509 | delete_post_meta( $postId, static::META_RANKING ); |
510 | 510 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
511 | 511 | } |
512 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
513 | - $reviews = glsr_db()->getReviews([ |
|
512 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
513 | + $reviews = glsr_db()->getReviews( [ |
|
514 | 514 | 'count' => -1, |
515 | 515 | 'post__in' => $updatedReviewIds, |
516 | - ]); |
|
517 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
518 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
516 | + ] ); |
|
517 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
518 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | if( $review->post_status != 'publish' ) { |
529 | 529 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
530 | 530 | } |
531 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
531 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
532 | 532 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
533 | 533 | } |
534 | 534 | } |
@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | 'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ), |
86 | 86 | ]; |
87 | 87 | foreach( $replacements as $search => $replacement ) { |
88 | - if( $translation != $search )continue; |
|
88 | + if( $translation != $search ) { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | $translation = $replacement; |
90 | 92 | } |
91 | 93 | } |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | public function filterUpdateMessages( array $messages ) |
112 | 114 | { |
113 | 115 | $post = get_post(); |
114 | - if( !( $post instanceof WP_Post ))return; |
|
116 | + if( !( $post instanceof WP_Post )) { |
|
117 | + return; |
|
118 | + } |
|
115 | 119 | $strings = glsr( Strings::class )->post_updated_messages(); |
116 | 120 | $restored = filter_input( INPUT_GET, 'revision' ); |
117 | 121 | if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
@@ -142,7 +146,9 @@ discard block |
||
142 | 146 | */ |
143 | 147 | public function onCreateReview( $postData, $meta, $postId ) |
144 | 148 | { |
145 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
149 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
150 | + return; |
|
151 | + } |
|
146 | 152 | $this->updateAssignedToPost( $review ); |
147 | 153 | } |
148 | 154 | |
@@ -153,7 +159,9 @@ discard block |
||
153 | 159 | */ |
154 | 160 | public function onDeleteReview( $postId ) |
155 | 161 | { |
156 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
162 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
163 | + return; |
|
164 | + } |
|
157 | 165 | $review->post_status = 'deleted'; // important to change the post_status here first! |
158 | 166 | $this->updateAssignedToPost( $review ); |
159 | 167 | } |
@@ -175,7 +183,9 @@ discard block |
||
175 | 183 | */ |
176 | 184 | public function registerMetaBoxes( $postType ) |
177 | 185 | { |
178 | - if( $postType != Application::POST_TYPE )return; |
|
186 | + if( $postType != Application::POST_TYPE ) { |
|
187 | + return; |
|
188 | + } |
|
179 | 189 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
180 | 190 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
181 | 191 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -207,7 +217,9 @@ discard block |
||
207 | 217 | */ |
208 | 218 | public function renderAssignedToMetabox( WP_Post $post ) |
209 | 219 | { |
210 | - if( !$this->isReviewPostType( $post ))return; |
|
220 | + if( !$this->isReviewPostType( $post )) { |
|
221 | + return; |
|
222 | + } |
|
211 | 223 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
212 | 224 | $template = ''; |
213 | 225 | if( $assignedPost = get_post( $assignedTo )) { |
@@ -233,7 +245,9 @@ discard block |
||
233 | 245 | */ |
234 | 246 | public function renderDetailsMetaBox( WP_Post $post ) |
235 | 247 | { |
236 | - if( !$this->isReviewPostType( $post ))return; |
|
248 | + if( !$this->isReviewPostType( $post )) { |
|
249 | + return; |
|
250 | + } |
|
237 | 251 | $review = glsr_db()->getReview( $post ); |
238 | 252 | glsr()->render( 'edit/metabox-details', [ |
239 | 253 | 'button' => $this->getMetaboxButton( $review, $post ), |
@@ -247,7 +261,9 @@ discard block |
||
247 | 261 | */ |
248 | 262 | public function renderMetaBoxPinned() |
249 | 263 | { |
250 | - if( !$this->isReviewPostType( get_post() ))return; |
|
264 | + if( !$this->isReviewPostType( get_post() )) { |
|
265 | + return; |
|
266 | + } |
|
251 | 267 | $pinned = get_post_meta( get_the_ID(), 'pinned', true ); |
252 | 268 | glsr()->render( 'edit/pinned', [ |
253 | 269 | 'pinned' => $pinned, |
@@ -260,7 +276,9 @@ discard block |
||
260 | 276 | */ |
261 | 277 | public function renderResponseMetaBox( WP_Post $post ) |
262 | 278 | { |
263 | - if( !$this->isReviewPostType( $post ))return; |
|
279 | + if( !$this->isReviewPostType( $post )) { |
|
280 | + return; |
|
281 | + } |
|
264 | 282 | $review = glsr_db()->getReview( $post ); |
265 | 283 | wp_nonce_field( 'response', '_nonce-response', false ); |
266 | 284 | glsr()->render( 'edit/metabox-response', [ |
@@ -275,7 +293,9 @@ discard block |
||
275 | 293 | */ |
276 | 294 | public function renderTaxonomyMetabox( WP_Post $post ) |
277 | 295 | { |
278 | - if( !$this->isReviewPostType( $post ))return; |
|
296 | + if( !$this->isReviewPostType( $post )) { |
|
297 | + return; |
|
298 | + } |
|
279 | 299 | glsr()->render( 'edit/metabox-categories', [ |
280 | 300 | 'post' => $post, |
281 | 301 | 'tax_name' => esc_attr( Application::TAXONOMY ), |
@@ -471,7 +491,9 @@ discard block |
||
471 | 491 | */ |
472 | 492 | protected function saveAssignedToMetabox( $postId ) |
473 | 493 | { |
474 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
494 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' )) { |
|
495 | + return; |
|
496 | + } |
|
475 | 497 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
476 | 498 | $assignedTo || $assignedTo = ''; |
477 | 499 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -486,7 +508,9 @@ discard block |
||
486 | 508 | */ |
487 | 509 | protected function saveResponseMetabox( $postId ) |
488 | 510 | { |
489 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
511 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' )) { |
|
512 | + return; |
|
513 | + } |
|
490 | 514 | $response = filter_input( INPUT_POST, 'response' ); |
491 | 515 | $response || $response = ''; |
492 | 516 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -501,7 +525,9 @@ discard block |
||
501 | 525 | */ |
502 | 526 | protected function updateAssignedToPost( WP_Post $review ) |
503 | 527 | { |
504 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
528 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
529 | + return; |
|
530 | + } |
|
505 | 531 | $reviewIds = get_post_meta( $postId, static::META_REVIEW_ID ); |
506 | 532 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
507 | 533 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function download( $filename, $content ) |
17 | 17 | { |
18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
18 | + if( !current_user_can( Application::CAPABILITY ) )return; |
|
19 | 19 | nocache_headers(); |
20 | 20 | header( 'Content-Type: text/plain' ); |
21 | 21 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
22 | - echo html_entity_decode( wp_strip_all_tags( $content )); |
|
22 | + echo html_entity_decode( wp_strip_all_tags( $content ) ); |
|
23 | 23 | exit; |
24 | 24 | } |
25 | 25 | |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function execute( $command ) |
32 | 32 | { |
33 | - $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command )); |
|
34 | - if( !class_exists( $handlerClass )) { |
|
33 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
34 | + if( !class_exists( $handlerClass ) ) { |
|
35 | 35 | throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
36 | 36 | } |
37 | 37 | try { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | catch( Exception $e ) { |
41 | 41 | status_header( 400 ); |
42 | - glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() )); |
|
42 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
43 | 43 | glsr_log()->error( $e->getMessage() ); |
44 | 44 | } |
45 | 45 | } |
@@ -49,6 +49,6 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function getPostId() |
51 | 51 | { |
52 | - return intval( filter_input( INPUT_GET, 'post' )); |
|
52 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
53 | 53 | } |
54 | 54 | } |
@@ -15,7 +15,9 @@ |
||
15 | 15 | */ |
16 | 16 | public function download( $filename, $content ) |
17 | 17 | { |
18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
18 | + if( !current_user_can( Application::CAPABILITY )) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | nocache_headers(); |
20 | 22 | header( 'Content-Type: text/plain' ); |
21 | 23 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function run() |
44 | 44 | { |
45 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
46 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'registerPointers'], 13 ); |
|
47 | - add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
48 | - add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
49 | - add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
50 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
51 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
52 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
53 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
54 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
55 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
45 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
46 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'registerPointers'], 13 ); |
|
47 | + add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
48 | + add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
49 | + add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
50 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
51 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
52 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
53 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
54 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
55 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
56 | 56 | // add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
57 | 57 | // add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
58 | 58 | // add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] ); |
@@ -63,27 +63,27 @@ discard block |
||
63 | 63 | // add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderMetaBoxPinned'] ); |
64 | 64 | // add_action( 'admin_action_revert', [$this->editor, 'revert'] ); |
65 | 65 | // add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
66 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
67 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
68 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
69 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'] ); |
|
70 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
71 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
72 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
73 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
74 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
75 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
76 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
77 | - add_action( 'wp_footer', [$this->main, 'renderSchema'] ); |
|
78 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
79 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
66 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
67 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
68 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
69 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'] ); |
|
70 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
71 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
72 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
73 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
74 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
75 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
76 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
77 | + add_action( 'wp_footer', [$this->main, 'renderSchema'] ); |
|
78 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
79 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
80 | 80 | // add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
81 | 81 | // add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
82 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
83 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
82 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
83 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
84 | 84 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
85 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
86 | - add_action( 'admin_init', [$this->router, 'routeWebhookRequest'] ); |
|
85 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
86 | + add_action( 'admin_init', [$this->router, 'routeWebhookRequest'] ); |
|
87 | 87 | // add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
88 | 88 | } |
89 | 89 | } |
@@ -25,7 +25,8 @@ |
||
25 | 25 | protected $router; |
26 | 26 | // protected $settings; |
27 | 27 | |
28 | - public function __construct( Application $app ) { |
|
28 | + public function __construct( Application $app ) |
|
29 | + { |
|
29 | 30 | $this->app = $app; |
30 | 31 | $this->admin = $app->make( AdminController::class ); |
31 | 32 | // $this->editor = $app->make( EditorController::class ); |
@@ -82,7 +82,7 @@ |
||
82 | 82 | { |
83 | 83 | $this->render()->div( glsr( Notice::class )->get(), [ |
84 | 84 | 'id' => 'glsr-notices', |
85 | - ]); |
|
85 | + ] ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |