@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | protected function createWebhookNotification( Command $command, array $args ) |
| 64 | 64 | { |
| 65 | 65 | $fields = []; |
| 66 | - $fields[] = ['title' => str_repeat( ':star:', (int) $command->rating )]; |
|
| 66 | + $fields[] = ['title' => str_repeat( ':star:', (int)$command->rating )]; |
|
| 67 | 67 | if( $command->title ) { |
| 68 | 68 | $fields[] = ['title' => $command->title]; |
| 69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | if( $command->author ) { |
| 77 | 77 | $fields[] = ['value' => trim( $command->author.$command->email.' - '.$command->ipAddress )]; |
| 78 | 78 | } |
| 79 | - $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ))]; |
|
| 80 | - return json_encode([ |
|
| 79 | + $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ) )]; |
|
| 80 | + return json_encode( [ |
|
| 81 | 81 | 'icon_url' => glsr()->url.'assets/img/icon.png', |
| 82 | 82 | 'username' => glsr()->name, |
| 83 | 83 | 'attachments' => [[ |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | 'fallback' => $this->createEmailNotification( $command, $args )->read( 'plaintext' ), |
| 87 | 87 | 'fields' => $fields, |
| 88 | 88 | ]], |
| 89 | - ]); |
|
| 89 | + ] ); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | protected function sendNotification( $post_id, Command $command ) |
| 116 | 116 | { |
| 117 | 117 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
| 118 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
| 119 | - $assignedToTitle = get_the_title( (int) $command->assignedTo ); |
|
| 118 | + if( !in_array( $notificationType, ['default', 'custom', 'webhook'] ) )return; |
|
| 119 | + $assignedToTitle = get_the_title( (int)$command->assignedTo ); |
|
| 120 | 120 | $notificationSubject = _nx( |
| 121 | 121 | 'New %s-star review', |
| 122 | 122 | 'New %s-star review of: %s', |
| 123 | - (int) empty( $assignedToTitle ), |
|
| 123 | + (int)empty($assignedToTitle), |
|
| 124 | 124 | 'The text is different depending on whether or not the review has been assigned to a post.', |
| 125 | 125 | 'site-reviews' |
| 126 | 126 | ); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | sprintf( $notificationSubject, $command->rating, $assignedToTitle ) |
| 130 | 130 | ); |
| 131 | 131 | $args = [ |
| 132 | - 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ))), |
|
| 132 | + 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ) ) ), |
|
| 133 | 133 | 'notification_title' => $notificationTitle, |
| 134 | 134 | 'notification_type' => $notificationType, |
| 135 | 135 | ]; |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | $args['recipient'] = $args['notification_type'] === 'default' |
| 148 | 148 | ? get_option( 'admin_email' ) |
| 149 | 149 | : glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
| 150 | - $result = !empty( $args['recipient'] ) |
|
| 150 | + $result = !empty($args['recipient']) |
|
| 151 | 151 | ? $this->createEmailNotification( $command, $args )->send() |
| 152 | 152 | : false; |
| 153 | - if( !is_bool( $result )) { |
|
| 154 | - glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' )); |
|
| 153 | + if( !is_bool( $result ) ) { |
|
| 154 | + glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ) ); |
|
| 155 | 155 | } |
| 156 | 156 | if( $result === false ) { |
| 157 | - glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' )); |
|
| 157 | + glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ) ); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | protected function sendWebhookNotification( Command $command, array $args ) |
| 165 | 165 | { |
| 166 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
| 166 | + if( !($endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )) )return; |
|
| 167 | 167 | $notification = $this->createWebhookNotification( $command, $args ); |
| 168 | 168 | $result = wp_remote_post( $endpoint, [ |
| 169 | 169 | 'method' => 'POST', |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | 'sslverify' => false, |
| 175 | 175 | 'headers' => ['Content-Type' => 'application/json'], |
| 176 | 176 | 'body' => apply_filters( 'site-reviews/webhook/notification', $notification, $command ), |
| 177 | - ]); |
|
| 178 | - if( is_wp_error( $result )) { |
|
| 177 | + ] ); |
|
| 178 | + if( is_wp_error( $result ) ) { |
|
| 179 | 179 | glsr_log()->error( $result->get_error_message() ); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function enqueueAssets() |
| 25 | 25 | { |
| 26 | - if( apply_filters( 'site-reviews/assets/css', true )) { |
|
| 26 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
| 27 | 27 | wp_enqueue_style( |
| 28 | 28 | Application::ID, |
| 29 | 29 | $this->getStylesheet(), |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | glsr()->version |
| 32 | 32 | ); |
| 33 | 33 | } |
| 34 | - if( apply_filters( 'site-reviews/assets/js', true )) { |
|
| 34 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
| 35 | 35 | wp_enqueue_script( |
| 36 | 36 | Application::ID, |
| 37 | 37 | glsr()->url( 'assets/scripts/'.Application::ID.'.js' ), |
| 38 | - [],//glsr( Html::class )->getDependencies(), |
|
| 38 | + [], //glsr( Html::class )->getDependencies(), |
|
| 39 | 39 | glsr()->version, |
| 40 | 40 | true |
| 41 | 41 | ); |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | public function enqueueRecaptchaScript() |
| 49 | 49 | { |
| 50 | 50 | if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
| 51 | - wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
|
| 51 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
| 52 | 52 | 'hl' => apply_filters( 'site-reviews/recaptcha/language', get_locale() ), |
| 53 | 53 | 'onload' => 'glsr_render_recaptcha', |
| 54 | 54 | 'render' => 'explicit', |
| 55 | - ], 'https://www.google.com/recaptcha/api.js' )); |
|
| 56 | - $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' )); |
|
| 55 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
| 56 | + $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' ) ); |
|
| 57 | 57 | wp_add_inline_script( Application::ID.'/google-recaptcha', $inlineScript, 'before' ); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $variables = [ |
| 66 | 66 | 'action' => Application::PREFIX.'action', |
| 67 | 67 | 'ajaxnonce' => wp_create_nonce( Application::ID.'-ajax-nonce' ), |
| 68 | - 'ajaxpagination' => ['#wpadminbar','.site-navigation-fixed'], |
|
| 68 | + 'ajaxpagination' => ['#wpadminbar', '.site-navigation-fixed'], |
|
| 69 | 69 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 70 | 70 | ]; |
| 71 | 71 | $variables = apply_filters( 'site-reviews/enqueue/localize', $variables ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | protected function getStylesheet() |
| 79 | 79 | { |
| 80 | - $currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' )); |
|
| 80 | + $currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' ) ); |
|
| 81 | 81 | return file_exists( glsr()->path.'assets/styles/'.$currentTheme.'.css' ) |
| 82 | 82 | ? glsr()->url( 'assets/styles/'.$currentTheme.'.css' ) |
| 83 | 83 | : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function handle( Command $command ) |
| 14 | 14 | { |
| 15 | - $postId = wp_update_post([ |
|
| 15 | + $postId = wp_update_post( [ |
|
| 16 | 16 | 'ID' => $command->id, |
| 17 | 17 | 'post_status' => $command->status, |
| 18 | - ]); |
|
| 19 | - if( is_wp_error( $postId )) { |
|
| 18 | + ] ); |
|
| 19 | + if( is_wp_error( $postId ) ) { |
|
| 20 | 20 | glsr_log()->error( $postId->get_error_message() ); |
| 21 | 21 | return []; |
| 22 | 22 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | 'href' => get_edit_post_link( $postId ), |
| 38 | 38 | 'class' => 'row-title', |
| 39 | 39 | 'title' => __( 'Edit', 'site-reviews' ).' “'.esc_attr( $title ).'”', |
| 40 | - ]); |
|
| 40 | + ] ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | protected function getPostState( $postId ) |
| 48 | 48 | { |
| 49 | 49 | ob_start(); |
| 50 | - _post_states( get_post( $postId, OBJECT )); |
|
| 50 | + _post_states( get_post( $postId, OBJECT ) ); |
|
| 51 | 51 | return ob_get_clean(); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function get() |
| 110 | 110 | { |
| 111 | - return empty( $this->log ) |
|
| 111 | + return empty($this->log) |
|
| 112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
| 113 | 113 | : $this->log; |
| 114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
| 136 | 136 | $constants = (array)apply_filters( Application::ID.'/log-levels', $constants ); |
| 137 | - if( in_array( $level, $constants, true )) { |
|
| 137 | + if( in_array( $level, $constants, true ) ) { |
|
| 138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
| 139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 140 | 140 | $this->reset(); |
| 141 | 141 | } |
| 142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | protected function getDebugInformation() |
| 187 | 187 | { |
| 188 | 188 | $caller = debug_backtrace( 0, 6 ); |
| 189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
| 189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
| 190 | 190 | if( $index === false |
| 191 | - || !isset( $caller[$index+2]['class'] ) |
|
| 192 | - || !isset( $caller[$index+2]['function'] ) |
|
| 191 | + || !isset($caller[$index + 2]['class']) |
|
| 192 | + || !isset($caller[$index + 2]['function']) |
|
| 193 | 193 | )return; |
| 194 | 194 | return sprintf( '[%s()->%s:%s] ', |
| 195 | - $caller[$index+2]['class'], |
|
| 196 | - $caller[$index+2]['function'], |
|
| 197 | - $caller[$index+1]['line'] |
|
| 195 | + $caller[$index + 2]['class'], |
|
| 196 | + $caller[$index + 2]['function'], |
|
| 197 | + $caller[$index + 1]['line'] |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function interpolate( $message, $context = [] ) |
| 208 | 208 | { |
| 209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 210 | 210 | return print_r( $message, true ); |
| 211 | 211 | } |
| 212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | if( $value instanceof DateTime ) { |
| 235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 236 | 236 | } |
| 237 | - else if( $this->isObjectOrArray( $value )) { |
|
| 237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 238 | 238 | $value = json_encode( $value ); |
| 239 | 239 | } |
| 240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $this->clear(); |
| 251 | 251 | file_put_contents( |
| 252 | 252 | $this->file, |
| 253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
| 253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
| 254 | 254 | ); |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function onCreateReview( $postData, $meta, $postId ) |
| 24 | 24 | { |
| 25 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 25 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
| 26 | 26 | $this->updateAssignedToPost( $review ); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function onDeleteReview( $postId ) |
| 34 | 34 | { |
| 35 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 35 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
| 36 | 36 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 37 | 37 | $this->updateAssignedToPost( $review ); |
| 38 | 38 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function saveAssignedToMetabox( $postId ) |
| 54 | 54 | { |
| 55 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 55 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
| 56 | 56 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
| 57 | 57 | $assignedTo || $assignedTo = ''; |
| 58 | 58 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function saveResponseMetabox( $postId ) |
| 69 | 69 | { |
| 70 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
| 70 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return; |
|
| 71 | 71 | $response = filter_input( INPUT_POST, 'response' ); |
| 72 | 72 | $response || $response = ''; |
| 73 | 73 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 74 | 74 | 'a' => ['href' => [], 'title' => []], |
| 75 | 75 | 'em' => [], |
| 76 | 76 | 'strong' => [], |
| 77 | - ]))); |
|
| 77 | + ] ) ) ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function getAssignedToPostId( $postId ) |
| 85 | 85 | { |
| 86 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
| 87 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 86 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
| 87 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 88 | 88 | return $post->ID; |
| 89 | 89 | } |
| 90 | 90 | return false; |
@@ -120,22 +120,22 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function updateAssignedToPost( WP_Post $review ) |
| 122 | 122 | { |
| 123 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 124 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 125 | - if( empty( $reviewIds ))return; |
|
| 123 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
| 124 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 125 | + if( empty($reviewIds) )return; |
|
| 126 | 126 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 127 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 128 | - if( empty( $updatedReviewIds )) { |
|
| 127 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 128 | + if( empty($updatedReviewIds) ) { |
|
| 129 | 129 | delete_post_meta( $postId, static::META_RANKING ); |
| 130 | 130 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
| 131 | 131 | } |
| 132 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
| 133 | - $reviews = glsr( Database::class )->getReviews([ |
|
| 132 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
| 133 | + $reviews = glsr( Database::class )->getReviews( [ |
|
| 134 | 134 | 'count' => -1, |
| 135 | 135 | 'post__in' => $updatedReviewIds, |
| 136 | - ]); |
|
| 137 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
| 138 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
| 136 | + ] ); |
|
| 137 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
| 138 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if( $review->post_status != 'publish' ) { |
| 149 | 149 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 150 | 150 | } |
| 151 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
| 151 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
| 152 | 152 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
| 33 | 33 | $reviews[] = $this->buildReview( $review ); |
| 34 | 34 | } |
| 35 | - if( !empty( $reviews )) { |
|
| 35 | + if( !empty($reviews) ) { |
|
| 36 | 36 | array_walk( $reviews, function( &$review ) { |
| 37 | - unset( $review['@context'] ); |
|
| 38 | - unset( $review['itemReviewed'] ); |
|
| 37 | + unset($review['@context']); |
|
| 38 | + unset($review['itemReviewed']); |
|
| 39 | 39 | }); |
| 40 | 40 | $schema['review'] = $reviews; |
| 41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | public function buildReview( $review ) |
| 50 | 50 | { |
| 51 | 51 | $schema = SchemaOrg::Review() |
| 52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 53 | 53 | $schema->name( $review->title ); |
| 54 | 54 | }) |
| 55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 56 | 56 | $schema->reviewBody( $review->content ); |
| 57 | 57 | }) |
| 58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
| 58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
| 59 | 59 | ->author( SchemaOrg::Person() |
| 60 | 60 | ->name( $review->author ) |
| 61 | 61 | ) |
| 62 | 62 | ->itemReviewed( $this->getSchemaType() |
| 63 | 63 | ->name( $this->getThingName() ) |
| 64 | 64 | ); |
| 65 | - if( !empty( $review->rating )) { |
|
| 65 | + if( !empty($review->rating) ) { |
|
| 66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
| 67 | 67 | ->ratingValue( $review->rating ) |
| 68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function buildSummary( $args = null ) |
| 80 | 80 | { |
| 81 | - if( is_array( $args )) { |
|
| 81 | + if( is_array( $args ) ) { |
|
| 82 | 82 | $this->args = $args; |
| 83 | 83 | } |
| 84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ->image( $this->getThingImage() ) |
| 91 | 91 | ->url( $this->getThingUrl() ); |
| 92 | 92 | $count = $this->getReviewCount(); |
| 93 | - if( !empty( $count )) { |
|
| 93 | + if( !empty($count) ) { |
|
| 94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
| 95 | 95 | ->ratingValue( $this->getRatingValue() ) |
| 96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function render() |
| 110 | 110 | { |
| 111 | - if( is_null( glsr()->schemas ))return; |
|
| 111 | + if( is_null( glsr()->schemas ) )return; |
|
| 112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 115 | - )); |
|
| 115 | + ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function store( array $schema ) |
| 122 | 122 | { |
| 123 | - $schemas = (array) glsr()->schemas; |
|
| 123 | + $schemas = (array)glsr()->schemas; |
|
| 124 | 124 | $schemas[] = $schema; |
| 125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | protected function getReviews( $force = false ) |
| 149 | 149 | { |
| 150 | - if( !isset( $this->reviews ) || $force ) { |
|
| 150 | + if( !isset($this->reviews) || $force ) { |
|
| 151 | 151 | $args = wp_parse_args( ['count' => -1], $this->args ); |
| 152 | 152 | $this->reviews = glsr( Database::class )->getReviews( $args )->reviews; |
| 153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function getSchemaOption( $option, $fallback ) |
| 163 | 163 | { |
| 164 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
| 164 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
| 165 | 165 | return $schemaOption; |
| 166 | 166 | } |
| 167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function renderAssignedToMetabox( WP_Post $post ) |
| 149 | 149 | { |
| 150 | - if( !$this->isReviewPostType( $post ))return; |
|
| 151 | - $assignedTo = intval( get_post_meta( $post->ID, 'assigned_to', true )); |
|
| 150 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 151 | + $assignedTo = intval( get_post_meta( $post->ID, 'assigned_to', true ) ); |
|
| 152 | 152 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 153 | 153 | glsr()->render( 'edit/metabox-assigned-to', [ |
| 154 | 154 | 'id' => $assignedTo, |
| 155 | 155 | 'template' => $this->buildAssignedToTemplate( $assignedTo ), |
| 156 | - ]); |
|
| 156 | + ] ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function renderDetailsMetaBox( WP_Post $post ) |
| 164 | 164 | { |
| 165 | - if( !$this->isReviewPostType( $post ))return; |
|
| 165 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 166 | 166 | $review = glsr( Database::class )->getReview( $post ); |
| 167 | 167 | glsr()->render( 'edit/metabox-details', [ |
| 168 | 168 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
| 169 | 169 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
| 170 | - ]); |
|
| 170 | + ] ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function renderPinnedInPublishMetaBox() |
| 178 | 178 | { |
| 179 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 179 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
| 180 | 180 | glsr()->render( 'edit/pinned', [ |
| 181 | - 'pinned' => boolval( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
| 182 | - ]); |
|
| 181 | + 'pinned' => boolval( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
| 182 | + ] ); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function renderResponseMetaBox( WP_Post $post ) |
| 190 | 190 | { |
| 191 | - if( !$this->isReviewPostType( $post ))return; |
|
| 191 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 192 | 192 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 193 | 193 | glsr()->render( 'edit/metabox-response', [ |
| 194 | 194 | 'response' => glsr( Database::class )->getReview( $post )->response, |
| 195 | - ]); |
|
| 195 | + ] ); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 204 | 204 | { |
| 205 | - if( !$this->isReviewPostType( $post ))return; |
|
| 205 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 206 | 206 | glsr()->render( 'edit/metabox-categories', [ |
| 207 | 207 | 'post' => $post, |
| 208 | 208 | 'tax_name' => Application::TAXONOMY, |
| 209 | 209 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
| 210 | - ]); |
|
| 210 | + ] ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function revertReview() |
| 219 | 219 | { |
| 220 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
| 220 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
| 221 | 221 | glsr( Database::class )->revertReview( $postId ); |
| 222 | 222 | $this->redirect( $postId, 52 ); |
| 223 | 223 | } |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | protected function buildAssignedToTemplate( $assignedTo ) |
| 241 | 241 | { |
| 242 | 242 | $assignedPost = get_post( $assignedTo ); |
| 243 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 243 | + if( !($assignedPost instanceof WP_Post) )return; |
|
| 244 | 244 | return glsr( Html::class )->buildTemplate( 'edit/assigned-post', [ |
| 245 | 245 | 'context' => [ |
| 246 | 246 | 'url' => (string)get_permalink( $assignedPost ), |
| 247 | 247 | 'title' => get_the_title( $assignedPost ), |
| 248 | 248 | ], |
| 249 | - ]); |
|
| 249 | + ] ); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -267,13 +267,13 @@ discard block |
||
| 267 | 267 | 'class' => 'button button-large', |
| 268 | 268 | 'href' => $revertUrl, |
| 269 | 269 | 'id' => 'revert', |
| 270 | - ]); |
|
| 270 | + ] ); |
|
| 271 | 271 | } |
| 272 | 272 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
| 273 | 273 | 'class' => 'button button-large', |
| 274 | 274 | 'disabled' => true, |
| 275 | 275 | 'id' => 'revert', |
| 276 | - ]); |
|
| 276 | + ] ); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | protected function getReviewType( $review ) |
| 284 | 284 | { |
| 285 | 285 | $reviewType = $review->review_type; |
| 286 | - if( !empty( $review->url )) { |
|
| 286 | + if( !empty($review->url) ) { |
|
| 287 | 287 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
| 288 | 288 | 'href' => $review->url, |
| 289 | 289 | 'target' => '_blank', |
| 290 | - ]); |
|
| 290 | + ] ); |
|
| 291 | 291 | } |
| 292 | 292 | return in_array( $reviewType, glsr()->reviewTypes ) |
| 293 | 293 | ? glsr()->reviewTypes[$reviewType] |
@@ -309,16 +309,16 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | protected function normalizeDetailsMetaBox( $review ) |
| 311 | 311 | { |
| 312 | - $reviewer = empty( $review->user_id ) |
|
| 312 | + $reviewer = empty($review->user_id) |
|
| 313 | 313 | ? __( 'Unregistered user', 'site-reviews' ) |
| 314 | 314 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
| 315 | 315 | 'href' => get_author_posts_url( $review->user_id ), |
| 316 | - ]); |
|
| 317 | - $email = empty( $review->email ) |
|
| 316 | + ] ); |
|
| 317 | + $email = empty($review->email) |
|
| 318 | 318 | ? '—' |
| 319 | 319 | : glsr( Builder::class )->a( $review->email, [ |
| 320 | 320 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
| 321 | - ]); |
|
| 321 | + ] ); |
|
| 322 | 322 | $metabox = [ |
| 323 | 323 | __( 'Rating', 'site-reviews' ) => glsr( Html::class )->renderPartial( 'star-rating', ['rating' => $review->rating] ), |
| 324 | 324 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $redirectUri = $hasReferer |
| 347 | 347 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
| 348 | 348 | : get_edit_post_link( $postId ); |
| 349 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
| 349 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
| 350 | 350 | exit; |
| 351 | 351 | } |
| 352 | 352 | } |