@@ -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 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
| 25 | - wp_update_post([ |
|
| 24 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
| 25 | + wp_update_post( [ |
|
| 26 | 26 | 'ID' => $postId, |
| 27 | 27 | 'post_status' => 'publish', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | wp_safe_redirect( wp_get_referer() ); |
| 30 | 30 | exit; |
| 31 | 31 | } |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
| 57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 57 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
| 58 | 58 | $value = $columns[$key]; |
| 59 | 59 | } |
| 60 | - if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
|
| 61 | - unset( $postTypeColumns['review_type'] ); |
|
| 60 | + if( count( glsr( Database::class )->getReviewsMeta( 'type' ) ) < 2 ) { |
|
| 61 | + unset($postTypeColumns['review_type']); |
|
| 62 | 62 | } |
| 63 | 63 | return array_filter( $postTypeColumns, 'strlen' ); |
| 64 | 64 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
| 85 | 85 | return $actions; |
| 86 | 86 | } |
| 87 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
| 87 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
| 88 | 88 | $rowActions = [ |
| 89 | 89 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
| 90 | 90 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | admin_url( 'post.php?post='.$post->ID.'&action='.$key ), |
| 98 | 98 | $key.'-review_'.$post->ID |
| 99 | 99 | ), |
| 100 | - ]); |
|
| 100 | + ] ); |
|
| 101 | 101 | } |
| 102 | 102 | return $actions; |
| 103 | 103 | } |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | public function filterSortableColumns( array $columns ) |
| 110 | 110 | { |
| 111 | 111 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 112 | - unset( $postTypeColumns['cb'] ); |
|
| 112 | + unset($postTypeColumns['cb']); |
|
| 113 | 113 | foreach( $postTypeColumns as $key => $value ) { |
| 114 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 114 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
| 115 | 115 | $columns[$key] = $key; |
| 116 | 116 | } |
| 117 | 117 | return $columns; |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
| 131 | 131 | { |
| 132 | - if( $this->canModifyTranslation( $domain )) { |
|
| 132 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 133 | 133 | $strings = [ |
| 134 | 134 | 'Published' => __( 'Approved', 'site-reviews' ), |
| 135 | 135 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 136 | 136 | ]; |
| 137 | 137 | foreach( $strings as $search => $replace ) { |
| 138 | 138 | if( strpos( $single, $search ) === false )continue; |
| 139 | - $translation = $this->getTranslation([ |
|
| 139 | + $translation = $this->getTranslation( [ |
|
| 140 | 140 | 'number' => $number, |
| 141 | 141 | 'plural' => str_replace( $search, $replace, $plural ), |
| 142 | 142 | 'single' => str_replace( $search, $replace, $single ), |
| 143 | - ]); |
|
| 143 | + ] ); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | return $translation; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | public function renderColumnFilters( $post_type ) |
| 168 | 168 | { |
| 169 | 169 | if( $post_type !== Application::POST_TYPE )return; |
| 170 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
| 170 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
| 171 | 171 | $status = 'publish'; |
| 172 | 172 | } |
| 173 | 173 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function saveBulkEditFields( $postId ) |
| 200 | 200 | { |
| 201 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 202 | - if( $assignedTo = filter_input( INPUT_GET, 'assigned_to' ) && get_post( $assignedTo )) { |
|
| 201 | + if( !current_user_can( 'edit_posts' ) )return; |
|
| 202 | + if( $assignedTo = filter_input( INPUT_GET, 'assigned_to' ) && get_post( $assignedTo ) ) { |
|
| 203 | 203 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function setQueryForColumn( WP_Query $query ) |
| 212 | 212 | { |
| 213 | - if( !$this->hasPermission( $query ))return; |
|
| 213 | + if( !$this->hasPermission( $query ) )return; |
|
| 214 | 214 | $this->setMetaQuery( $query, [ |
| 215 | 215 | 'rating', 'review_type', |
| 216 | - ]); |
|
| 216 | + ] ); |
|
| 217 | 217 | $this->setOrderby( $query ); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function unapprove() |
| 225 | 225 | { |
| 226 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
| 227 | - wp_update_post([ |
|
| 226 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
| 227 | + wp_update_post( [ |
|
| 228 | 228 | 'ID' => $postId, |
| 229 | 229 | 'post_status' => 'pending', |
| 230 | - ]); |
|
| 230 | + ] ); |
|
| 231 | 231 | wp_safe_redirect( wp_get_referer() ); |
| 232 | 232 | exit; |
| 233 | 233 | } |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | protected function buildColumnAssignedTo( $postId ) |
| 240 | 240 | { |
| 241 | 241 | $post = get_post( glsr( Database::class )->getReviewMeta( $postId )->assigned_to ); |
| 242 | - if( !( $post instanceof WP_Post ) || $post->post_status != 'publish' ) { |
|
| 242 | + if( !($post instanceof WP_Post) || $post->post_status != 'publish' ) { |
|
| 243 | 243 | return '—'; |
| 244 | 244 | } |
| 245 | 245 | return glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 246 | 246 | 'href' => (string)get_the_permalink( $post->ID ), |
| 247 | - ]); |
|
| 247 | + ] ); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | protected function buildColumnReviewer( $postId ) |
| 255 | 255 | { |
| 256 | - return glsr( Database::class )->getReviewMeta( $postId )->author; |
|
| 256 | + return glsr( Database::class )->getReviewMeta( $postId )->author; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | { |
| 265 | 265 | return glsr( Html::class )->buildPartial( 'star-rating', [ |
| 266 | 266 | 'rating' => glsr( Database::class )->getReviewMeta( $postId )->rating, |
| 267 | - ]); |
|
| 267 | + ] ); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -276,10 +276,10 @@ discard block |
||
| 276 | 276 | $pinned = glsr( Database::class )->getReviewMeta( $postId )->pinned |
| 277 | 277 | ? ' pinned' |
| 278 | 278 | : ''; |
| 279 | - return glsr( Builder::class )->i([ |
|
| 279 | + return glsr( Builder::class )->i( [ |
|
| 280 | 280 | 'class' => trim( 'dashicons dashicons-sticky '.$pinned ), |
| 281 | 281 | 'data-id' => $postId, |
| 282 | - ]); |
|
| 282 | + ] ); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | protected function buildColumnType( $postId ) |
| 290 | 290 | { |
| 291 | 291 | $reviewMeta = glsr( Database::class )->getReviewMeta( $postId ); |
| 292 | - return isset( glsr()->reviewTypes[$reviewMeta->review_type] ) |
|
| 292 | + return isset(glsr()->reviewTypes[$reviewMeta->review_type]) |
|
| 293 | 293 | ? glsr()->reviewTypes[$reviewMeta->review_type] |
| 294 | 294 | : $reviewMeta->review_type; |
| 295 | 295 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | 'single' => '', |
| 319 | 319 | 'text' => '', |
| 320 | 320 | ]; |
| 321 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
| 321 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
| 322 | 322 | $translations = get_translations_for_domain( Application::ID ); |
| 323 | 323 | return $args->text |
| 324 | 324 | ? $translations->translate( $args->text ) |
@@ -343,20 +343,20 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | protected function renderFilterRatings( $ratings ) |
| 345 | 345 | { |
| 346 | - if( empty( $ratings ) |
|
| 346 | + if( empty($ratings) |
|
| 347 | 347 | || apply_filters( 'site-reviews/disable/filter/ratings', false ) |
| 348 | 348 | )return; |
| 349 | - $ratings = array_flip( array_reverse( $ratings )); |
|
| 349 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
| 350 | 350 | array_walk( $ratings, function( &$value, $key ) { |
| 351 | 351 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
| 352 | 352 | $value = sprintf( $label, $key ); |
| 353 | 353 | }); |
| 354 | 354 | $ratings = [__( 'All ratings', 'site-reviews' )] + $ratings; |
| 355 | - printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' )); |
|
| 355 | + printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' ) ); |
|
| 356 | 356 | glsr( Html::class )->renderPartial( 'filterby', [ |
| 357 | 357 | 'name' => 'rating', |
| 358 | 358 | 'values' => $ratings, |
| 359 | - ]); |
|
| 359 | + ] ); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -366,18 +366,18 @@ discard block |
||
| 366 | 366 | protected function renderFilterTypes( $types ) |
| 367 | 367 | { |
| 368 | 368 | if( count( $types ) < 1 |
| 369 | - || ( count( $types ) == 1 && $types[0] == 'local' ) |
|
| 369 | + || (count( $types ) == 1 && $types[0] == 'local') |
|
| 370 | 370 | || apply_filters( 'site-reviews/disable/filter/types', false ) |
| 371 | 371 | )return; |
| 372 | 372 | $reviewTypes = [__( 'All types', 'site-reviews' )]; |
| 373 | 373 | foreach( $types as $type ) { |
| 374 | - $reviewTypes[$type] = glsr( Strings::class )->review_types( $type, ucfirst( $type )); |
|
| 374 | + $reviewTypes[$type] = glsr( Strings::class )->review_types( $type, ucfirst( $type ) ); |
|
| 375 | 375 | } |
| 376 | - printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' )); |
|
| 376 | + printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' ) ); |
|
| 377 | 377 | glsr( Html::class )->renderPartial( 'filterby', [ |
| 378 | 378 | 'name' => 'review_type', |
| 379 | 379 | 'values' => $reviewTypes, |
| 380 | - ]); |
|
| 380 | + ] ); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 387 | 387 | { |
| 388 | 388 | foreach( $metaKeys as $key ) { |
| 389 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 389 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
| 390 | 390 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 391 | 391 | $metaQuery[] = [ |
| 392 | 392 | 'key' => $key, |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | { |
| 404 | 404 | $orderby = $query->get( 'orderby' ); |
| 405 | 405 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 406 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
| 407 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
| 406 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
| 407 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
| 408 | 408 | $query->set( 'meta_key', $orderby ); |
| 409 | 409 | $query->set( 'orderby', 'meta_value' ); |
| 410 | 410 | } |
@@ -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 | } |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | global $menu, $typenow; |
| 22 | 22 | foreach( $menu as $key => $value ) { |
| 23 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 23 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 24 | 24 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 25 | 25 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
| 26 | 26 | 'class' => 'pending-count', |
| 27 | - ]); |
|
| 27 | + ] ); |
|
| 28 | 28 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
| 29 | 29 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $menu[$key][0] .= $awaitingModeration; |
| 32 | 32 | if( $typenow === Application::POST_TYPE ) { |
| 33 | 33 | $menu[$key][4] .= ' current'; |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | 'tools' => __( 'Tools', 'site-reviews' ), |
| 49 | 49 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
| 50 | 50 | 'addons' => __( 'Add-Ons', 'site-reviews' ), |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | foreach( $pages as $slug => $title ) { |
| 53 | 53 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
| 54 | 54 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
| 55 | - if( !is_callable( $callback ))continue; |
|
| 55 | + if( !is_callable( $callback ) )continue; |
|
| 56 | 56 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, Application::CAPABILITY, $slug, $callback ); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
| 85 | 85 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
| 86 | 86 | 'functions' => __( 'Functions', 'site-reviews' ), |
| 87 | - ]); |
|
| 87 | + ] ); |
|
| 88 | 88 | $this->renderMenu( 'documentation', $tabs ); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | 'schema' => __( 'Schema', 'site-reviews' ), |
| 104 | 104 | 'translations' => __( 'Translations', 'site-reviews' ), |
| 105 | 105 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
| 106 | - ]); |
|
| 106 | + ] ); |
|
| 107 | 107 | $this->renderMenu( 'settings', $tabs, [ |
| 108 | 108 | 'databaseKey' => OptionManager::databaseKey(), |
| 109 | 109 | 'settings' => glsr()->getDefaults(), |
| 110 | - ]); |
|
| 110 | + ] ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | 'import-export' => __( 'Import/Export', 'site-reviews' ), |
| 123 | 123 | 'logging' => __( 'Logging', 'site-reviews' ), |
| 124 | 124 | 'system-info' => __( 'System Info', 'site-reviews' ), |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | $this->renderMenu( 'tools', $tabs, [ |
| 127 | 127 | 'id' => Application::ID, |
| 128 | 128 | 'logger' => glsr( Logger::class ), |
| 129 | 129 | 'prefix' => Application::PREFIX, |
| 130 | 130 | 'system' => glsr( System::class ), |
| 131 | - ]); |
|
| 131 | + ] ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | protected function getCurrentSection( array $tabs, $tab ) |
| 150 | 150 | { |
| 151 | 151 | $currentSection = filter_input( INPUT_GET, 'section' ); |
| 152 | - if( empty( $tabs[$tab]['sections'][$currentSection] )) { |
|
| 153 | - $currentSection = isset( $tabs[$tab]['sections'] ) |
|
| 152 | + if( empty($tabs[$tab]['sections'][$currentSection]) ) { |
|
| 153 | + $currentSection = isset($tabs[$tab]['sections']) |
|
| 154 | 154 | ? key( $tabs[$tab]['sections'] ) |
| 155 | 155 | : ''; |
| 156 | 156 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | protected function getCurrentTab( array $tabs ) |
| 164 | 164 | { |
| 165 | 165 | $currentTab = filter_input( INPUT_GET, 'tab' ); |
| 166 | - if( !array_key_exists( $currentTab, $tabs )) { |
|
| 166 | + if( !array_key_exists( $currentTab, $tabs ) ) { |
|
| 167 | 167 | $currentTab = key( $tabs ); |
| 168 | 168 | } |
| 169 | 169 | return $currentTab; |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | protected function normalizeTabs( array $tabs ) |
| 176 | 176 | { |
| 177 | 177 | foreach( $tabs as $key => $value ) { |
| 178 | - if( !is_array( $value )) { |
|
| 178 | + if( !is_array( $value ) ) { |
|
| 179 | 179 | $value = ['title' => $value]; |
| 180 | 180 | } |
| 181 | 181 | $tabs[$key] = wp_parse_args( $value, [ |
| 182 | 182 | 'sections' => [], |
| 183 | 183 | 'title' => '', |
| 184 | - ]); |
|
| 184 | + ] ); |
|
| 185 | 185 | $useLicenses = apply_filters( 'site-reviews/addon/licenses', false ); |
| 186 | 186 | if( !$useLicenses ) { |
| 187 | - unset( $tabs['licenses'] ); |
|
| 187 | + unset($tabs['licenses']); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | return $tabs; |
@@ -206,6 +206,6 @@ discard block |
||
| 206 | 206 | 'tabs' => $tabs, |
| 207 | 207 | ]; |
| 208 | 208 | $data = apply_filters( 'site-reviews/addon/page/data', $data, $defaults ); |
| 209 | - glsr()->render( 'pages/index', wp_parse_args( $data, $defaults )); |
|
| 209 | + glsr()->render( 'pages/index', wp_parse_args( $data, $defaults ) ); |
|
| 210 | 210 | } |
| 211 | 211 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | wp_send_json( glsr( Html::class )->renderPartial( 'link', [ |
| 25 | 25 | 'post_id' => $request['ID'], |
| 26 | - ])); |
|
| 26 | + ] ) ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function changeReviewStatus( array $request ) |
| 33 | 33 | { |
| 34 | - wp_send_json( $this->execute( new ChangeStatus( $request ))); |
|
| 34 | + wp_send_json( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | public function clearLog() |
| 41 | 41 | { |
| 42 | 42 | glsr( AdminController::class )->routerClearLog(); |
| 43 | - wp_send_json([ |
|
| 43 | + wp_send_json( [ |
|
| 44 | 44 | 'logger' => glsr( Logger::class )->get(), |
| 45 | 45 | 'notices' => glsr( Notice::class )->get(), |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $shortcode = $request['shortcode']; |
| 55 | 55 | $response = false; |
| 56 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 56 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 57 | 57 | $data = glsr()->mceShortcodes[$shortcode]; |
| 58 | - if( !empty( $data['errors'] )) { |
|
| 58 | + if( !empty($data['errors']) ) { |
|
| 59 | 59 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 60 | 60 | } |
| 61 | 61 | $response = [ |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | public function searchPosts( array $request ) |
| 76 | 76 | { |
| 77 | 77 | $results = glsr_db()->searchPosts( $request['search'] ); |
| 78 | - wp_send_json_success([ |
|
| 78 | + wp_send_json_success( [ |
|
| 79 | 79 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 80 | 80 | 'items' => $results, |
| 81 | - ]); |
|
| 81 | + ] ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function searchTranslations( array $request ) |
| 88 | 88 | { |
| 89 | - if( empty( $request['exclude'] )) { |
|
| 89 | + if( empty($request['exclude']) ) { |
|
| 90 | 90 | $request['exclude'] = []; |
| 91 | 91 | } |
| 92 | 92 | $results = glsr( Translator::class ) |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | ->exclude() |
| 95 | 95 | ->exclude( $request['exclude'] ) |
| 96 | 96 | ->renderResults(); |
| 97 | - wp_send_json_success([ |
|
| 97 | + wp_send_json_success( [ |
|
| 98 | 98 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 99 | 99 | 'items' => $results, |
| 100 | - ]); |
|
| 100 | + ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $response = glsr( PublicController::class )->routerSubmitReview( $request ); |
| 109 | 109 | $session = glsr( Session::class ); |
| 110 | - wp_send_json([ |
|
| 110 | + wp_send_json( [ |
|
| 111 | 111 | 'errors' => $session->get( $request['form_id'].'-errors', false, true ), |
| 112 | 112 | 'message' => $response, |
| 113 | 113 | 'recaptcha' => $session->get( $request['form_id'].'-recaptcha', false, true ), |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function togglePinned( array $request ) |
| 121 | 121 | { |
| 122 | - wp_send_json([ |
|
| 122 | + wp_send_json( [ |
|
| 123 | 123 | 'notices' => glsr( Notice::class )->get(), |
| 124 | - 'pinned' => $this->execute( new TogglePinned( $request )), |
|
| 125 | - ]); |
|
| 124 | + 'pinned' => $this->execute( new TogglePinned( $request ) ), |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function registerPostType() |
| 21 | 21 | { |
| 22 | 22 | if( !glsr()->hasPermission() )return; |
| 23 | - $command = new RegisterPostType([ |
|
| 23 | + $command = new RegisterPostType( [ |
|
| 24 | 24 | 'capabilities'=> ['create_posts' => 'create_'.Application::POST_TYPE], |
| 25 | 25 | 'columns' => [ |
| 26 | 26 | 'title' => '', |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'plural' => __( 'Reviews', 'site-reviews' ), |
| 39 | 39 | 'post_type' => Application::POST_TYPE, |
| 40 | 40 | 'single' => __( 'Review', 'site-reviews' ), |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->execute( $command ); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function registerShortcodes() |
| 50 | 50 | { |
| 51 | - $command = new RegisterShortcodes([ |
|
| 51 | + $command = new RegisterShortcodes( [ |
|
| 52 | 52 | 'site_reviews', |
| 53 | 53 | 'site_reviews_form', |
| 54 | 54 | 'site_reviews_summary', |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | $this->execute( $command ); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function registerTaxonomy() |
| 64 | 64 | { |
| 65 | - $command = new RegisterTaxonomy([ |
|
| 65 | + $command = new RegisterTaxonomy( [ |
|
| 66 | 66 | 'hierarchical' => true, |
| 67 | 67 | 'meta_box_cb' => 'glsr_categories_meta_box', |
| 68 | 68 | 'public' => false, |
| 69 | 69 | 'show_admin_column' => true, |
| 70 | 70 | 'show_ui' => true, |
| 71 | - ]); |
|
| 71 | + ] ); |
|
| 72 | 72 | $this->execute( $command ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function registerWidgets() |
| 80 | 80 | { |
| 81 | - $command = new RegisterWidgets([ |
|
| 81 | + $command = new RegisterWidgets( [ |
|
| 82 | 82 | 'site-reviews' => [ |
| 83 | 83 | 'class' => 'glsr-widget glsr-widget-site-reviews', |
| 84 | 84 | 'description' => __( 'Your site’s most recent reviews.', 'site-reviews' ), |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'description' => __( 'A summary of your site’s reviews.', 'site-reviews' ), |
| 95 | 95 | 'title' => __( 'Summary of Reviews', 'site-reviews' ), |
| 96 | 96 | ], |
| 97 | - ]); |
|
| 97 | + ] ); |
|
| 98 | 98 | $this->execute( $command ); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function load() |
| 39 | 39 | { |
| 40 | - if( empty( static::$instance )) { |
|
| 40 | + if( empty(static::$instance) ) { |
|
| 41 | 41 | static::$instance = new static; |
| 42 | 42 | } |
| 43 | 43 | return static::$instance; |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __get( $property ) |
| 51 | 51 | { |
| 52 | - if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
| 52 | + if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
| 53 | 53 | return $this->$property; |
| 54 | 54 | } |
| 55 | - $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property )); |
|
| 56 | - if( defined( $constant )) { |
|
| 55 | + $constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ) ); |
|
| 56 | + if( defined( $constant ) ) { |
|
| 57 | 57 | return constant( $constant ); |
| 58 | 58 | } |
| 59 | - return isset( $this->storage[$property] ) |
|
| 59 | + return isset($this->storage[$property]) |
|
| 60 | 60 | ? $this->storage[$property] |
| 61 | 61 | : null; |
| 62 | 62 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function __set( $property, $value ) |
| 70 | 70 | { |
| 71 | - if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES )) { |
|
| 71 | + if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) { |
|
| 72 | 72 | $this->storage[$property] = $value; |
| 73 | 73 | } |
| 74 | - else if( !isset( $this->$property )) { |
|
| 74 | + else if( !isset($this->$property) ) { |
|
| 75 | 75 | $this->$property = $value; |
| 76 | 76 | } |
| 77 | 77 | else { |
| 78 | - throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property )); |
|
| 78 | + throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) ); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -97,16 +97,16 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function make( $abstract ) |
| 99 | 99 | { |
| 100 | - if( !isset( $this->services[$abstract] )) { |
|
| 100 | + if( !isset($this->services[$abstract]) ) { |
|
| 101 | 101 | $abstract = $this->addNamespace( $abstract ); |
| 102 | 102 | } |
| 103 | - if( isset( $this->services[$abstract] )) { |
|
| 103 | + if( isset($this->services[$abstract]) ) { |
|
| 104 | 104 | $abstract = $this->services[$abstract]; |
| 105 | 105 | } |
| 106 | - if( is_callable( $abstract )) { |
|
| 106 | + if( is_callable( $abstract ) ) { |
|
| 107 | 107 | return call_user_func_array( $abstract, [$this] ); |
| 108 | 108 | } |
| 109 | - if( is_object( $abstract )) { |
|
| 109 | + if( is_object( $abstract ) ) { |
|
| 110 | 110 | return $abstract; |
| 111 | 111 | } |
| 112 | 112 | return $this->resolve( $abstract ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function singleton( $alias, $binding ) |
| 122 | 122 | { |
| 123 | - $this->bind( $alias, $this->make( $binding )); |
|
| 123 | + $this->bind( $alias, $this->make( $binding ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function addNamespace( $abstract ) |
| 132 | 132 | { |
| 133 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
| 133 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
| 134 | 134 | $abstract = __NAMESPACE__.'\\'.$abstract; |
| 135 | 135 | } |
| 136 | 136 | return $abstract; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | throw new Exception( 'Target ['.$concrete.'] is not instantiable.' ); |
| 153 | 153 | } |
| 154 | 154 | $constructor = $reflector->getConstructor(); |
| 155 | - if( empty( $constructor )) { |
|
| 155 | + if( empty($constructor) ) { |
|
| 156 | 156 | return new $concrete; |
| 157 | 157 | } |
| 158 | 158 | return $reflector->newInstanceArgs( |
@@ -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 | /** |