@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 24 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
| 26 | 28 | wp_update_post([ |
| 27 | 29 | 'ID' => $postId, |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 62 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 63 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 64 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | $value = $columns[$key]; |
| 64 | 68 | } |
| 65 | 69 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -103,7 +107,8 @@ discard block |
||
| 103 | 107 | * @return array |
| 104 | 108 | * @filter display_post_states |
| 105 | 109 | */ |
| 106 | - public function filterPostStates( $postStates, $post ) { |
|
| 110 | + public function filterPostStates( $postStates, $post ) |
|
| 111 | + { |
|
| 107 | 112 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 108 | 113 | if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
| 109 | 114 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -152,7 +157,9 @@ discard block |
||
| 152 | 157 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 153 | 158 | unset( $postTypeColumns['cb'] ); |
| 154 | 159 | foreach( $postTypeColumns as $key => $value ) { |
| 155 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 160 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 156 | 163 | $columns[$key] = $key; |
| 157 | 164 | } |
| 158 | 165 | return $columns; |
@@ -176,7 +183,9 @@ discard block |
||
| 176 | 183 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 177 | 184 | ]; |
| 178 | 185 | foreach( $strings as $search => $replace ) { |
| 179 | - if( strpos( $single, $search ) === false )continue; |
|
| 186 | + if( strpos( $single, $search ) === false ) { |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 180 | 189 | $translation = $this->getTranslation([ |
| 181 | 190 | 'number' => $number, |
| 182 | 191 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -228,7 +237,9 @@ discard block |
||
| 228 | 237 | */ |
| 229 | 238 | public function saveBulkEditFields( $postId ) |
| 230 | 239 | { |
| 231 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 240 | + if( !current_user_can( 'edit_posts' )) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 232 | 243 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 233 | 244 | if( $assignedTo && get_post( $assignedTo )) { |
| 234 | 245 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -241,7 +252,9 @@ discard block |
||
| 241 | 252 | */ |
| 242 | 253 | public function setQueryForColumn( WP_Query $query ) |
| 243 | 254 | { |
| 244 | - if( !$this->hasPermission( $query ))return; |
|
| 255 | + if( !$this->hasPermission( $query )) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 245 | 258 | $this->setMetaQuery( $query, [ |
| 246 | 259 | 'rating', 'review_type', |
| 247 | 260 | ]); |
@@ -254,7 +267,9 @@ discard block |
||
| 254 | 267 | */ |
| 255 | 268 | public function unapprove() |
| 256 | 269 | { |
| 257 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 270 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 271 | + return; |
|
| 272 | + } |
|
| 258 | 273 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
| 259 | 274 | wp_update_post([ |
| 260 | 275 | 'ID' => $postId, |
@@ -314,7 +329,9 @@ discard block |
||
| 314 | 329 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 315 | 330 | { |
| 316 | 331 | foreach( $metaKeys as $key ) { |
| 317 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 332 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 333 | + continue; |
|
| 334 | + } |
|
| 318 | 335 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 319 | 336 | $metaQuery[] = [ |
| 320 | 337 | 'key' => $key, |
@@ -96,7 +96,9 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 98 | 98 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 99 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 99 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 100 | 102 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 101 | 103 | } |
| 102 | 104 | |
@@ -133,7 +135,9 @@ discard block |
||
| 133 | 135 | */ |
| 134 | 136 | public function renderAssignedToMetabox( $post ) |
| 135 | 137 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 138 | + if( !$this->isReviewPostType( $post )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 137 | 141 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 138 | 142 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 139 | 143 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -149,7 +153,9 @@ discard block |
||
| 149 | 153 | */ |
| 150 | 154 | public function renderDetailsMetaBox( $post ) |
| 151 | 155 | { |
| 152 | - if( !$this->isReviewPostType( $post ))return; |
|
| 156 | + if( !$this->isReviewPostType( $post )) { |
|
| 157 | + return; |
|
| 158 | + } |
|
| 153 | 159 | $review = glsr( ReviewManager::class )->single( $post ); |
| 154 | 160 | glsr()->render( 'partials/editor/metabox-details', [ |
| 155 | 161 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -163,7 +169,9 @@ discard block |
||
| 163 | 169 | */ |
| 164 | 170 | public function renderPinnedInPublishMetaBox() |
| 165 | 171 | { |
| 166 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 172 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 167 | 175 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 168 | 176 | 'context' => [ |
| 169 | 177 | 'no' => __( 'No', 'site-reviews' ), |
@@ -180,7 +188,9 @@ discard block |
||
| 180 | 188 | */ |
| 181 | 189 | public function renderResponseMetaBox( $post ) |
| 182 | 190 | { |
| 183 | - if( !$this->isReviewPostType( $post ))return; |
|
| 191 | + if( !$this->isReviewPostType( $post )) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 184 | 194 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 185 | 195 | glsr()->render( 'partials/editor/metabox-response', [ |
| 186 | 196 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -194,7 +204,9 @@ discard block |
||
| 194 | 204 | */ |
| 195 | 205 | public function renderReviewEditor( $post ) |
| 196 | 206 | { |
| 197 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 207 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 208 | + return; |
|
| 209 | + } |
|
| 198 | 210 | glsr()->render( 'partials/editor/review', [ |
| 199 | 211 | 'post' => $post, |
| 200 | 212 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -208,7 +220,9 @@ discard block |
||
| 208 | 220 | public function renderReviewFields() |
| 209 | 221 | { |
| 210 | 222 | $screen = glsr_current_screen(); |
| 211 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 223 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 212 | 226 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 213 | 227 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 214 | 228 | } |
@@ -220,7 +234,9 @@ discard block |
||
| 220 | 234 | */ |
| 221 | 235 | public function renderReviewNotice( $post ) |
| 222 | 236 | { |
| 223 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 237 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 238 | + return; |
|
| 239 | + } |
|
| 224 | 240 | glsr( Notice::class )->addWarning( sprintf( |
| 225 | 241 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 226 | 242 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -240,7 +256,9 @@ discard block |
||
| 240 | 256 | */ |
| 241 | 257 | public function renderTaxonomyMetabox( $post ) |
| 242 | 258 | { |
| 243 | - if( !$this->isReviewPostType( $post ))return; |
|
| 259 | + if( !$this->isReviewPostType( $post )) { |
|
| 260 | + return; |
|
| 261 | + } |
|
| 244 | 262 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 245 | 263 | 'post' => $post, |
| 246 | 264 | 'tax_name' => Application::TAXONOMY, |
@@ -255,7 +273,9 @@ discard block |
||
| 255 | 273 | */ |
| 256 | 274 | public function revertReview() |
| 257 | 275 | { |
| 258 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 276 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 277 | + return; |
|
| 278 | + } |
|
| 259 | 279 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
| 260 | 280 | glsr( ReviewManager::class )->revert( $postId ); |
| 261 | 281 | $this->redirect( $postId, 52 ); |
@@ -279,7 +299,9 @@ discard block |
||
| 279 | 299 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 280 | 300 | { |
| 281 | 301 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 282 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 302 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 303 | + return; |
|
| 304 | + } |
|
| 283 | 305 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 284 | 306 | 'context' => [ |
| 285 | 307 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -325,7 +347,9 @@ discard block |
||
| 325 | 347 | */ |
| 326 | 348 | protected function getReviewType( $review ) |
| 327 | 349 | { |
| 328 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 350 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 351 | + return; |
|
| 352 | + } |
|
| 329 | 353 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 330 | 354 | ? glsr()->reviewTypes[$review->review_type] |
| 331 | 355 | : __( 'Unknown', 'site-reviews' ); |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | $views = $this->generatePossibleViews( $view ); |
| 57 | 57 | foreach( $views as $possibleView ) { |
| 58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
| 58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
| 59 | + continue; |
|
| 60 | + } |
|
| 59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
| 60 | 62 | } |
| 61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
| 88 | 90 | */ |
| 89 | 91 | public function modifyField( Builder $instance ) |
| 90 | 92 | { |
| 91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
| 93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 92 | 96 | call_user_func_array( [$this, 'customize'], [$instance] ); |
| 93 | 97 | } |
| 94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
| 105 | 109 | */ |
| 106 | 110 | protected function customize( Builder $instance ) |
| 107 | 111 | { |
| 108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
| 112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
| 110 | 116 | $key = $instance->tag.'_'.$args['type']; |
| 111 | 117 | $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | sort( $newTTIds ); |
| 28 | 28 | sort( $oldTTIds ); |
| 29 | - if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ))return; |
|
| 29 | + if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId )) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 30 | 32 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 31 | 33 | $ignoredIds = array_intersect( $oldTTIds, $newTTIds ); |
| 32 | 34 | $decreasedIds = array_diff( $oldTTIds, $ignoredIds ); |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | */ |
| 49 | 51 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
| 50 | 52 | { |
| 51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 53 | + if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 52 | 56 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 53 | 57 | if( $post->post_status == 'publish' ) { |
| 54 | 58 | glsr( CountsManager::class )->increase( $review ); |
@@ -64,7 +68,9 @@ discard block |
||
| 64 | 68 | */ |
| 65 | 69 | public function onAfterCreate( Review $review ) |
| 66 | 70 | { |
| 67 | - if( $review->status !== 'publish' )return; |
|
| 71 | + if( $review->status !== 'publish' ) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 68 | 74 | glsr( CountsManager::class )->increase( $review ); |
| 69 | 75 | } |
| 70 | 76 | |
@@ -75,7 +81,9 @@ discard block |
||
| 75 | 81 | */ |
| 76 | 82 | public function onBeforeDelete( $postId ) |
| 77 | 83 | { |
| 78 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 84 | + if( !$this->isReviewPostId( $postId )) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 79 | 87 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 80 | 88 | glsr( CountsManager::class )->decrease( $review ); |
| 81 | 89 | } |
@@ -92,9 +100,13 @@ discard block |
||
| 92 | 100 | { |
| 93 | 101 | if( !$this->isReviewPostId( $postId ) |
| 94 | 102 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 95 | - )return; |
|
| 103 | + ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 96 | 106 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 97 | - if( $review->$metaKey == $metaValue )return; |
|
| 107 | + if( $review->$metaKey == $metaValue ) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 98 | 110 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 99 | 111 | call_user_func( [$this, $method], $review, $metaValue ); |
| 100 | 112 | } |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 42 | 'class' => 'screen-reader-text', |
| 41 | 43 | 'for' => Application::TAXONOMY, |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | */ |
| 68 | 70 | public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
| 69 | 71 | { |
| 70 | - if( $taxonomy != Application::TAXONOMY || count( $newTTIds ) <= 1 )return; |
|
| 72 | + if( $taxonomy != Application::TAXONOMY || count( $newTTIds ) <= 1 ) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 71 | 75 | $diff = array_diff( $newTTIds, $oldTTIds ); |
| 72 | 76 | if( empty( $newTerm = array_shift( $diff ))) { |
| 73 | 77 | $newTerm = array_shift( $newTTIds ); |
@@ -72,7 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function send() |
| 74 | 74 | { |
| 75 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 76 | 78 | add_action( 'wp_mail_failed', [$this, 'logMailError']); |
| 77 | 79 | $sent = wp_mail( |
| 78 | 80 | $this->to, |
@@ -92,8 +94,12 @@ discard block |
||
| 92 | 94 | */ |
| 93 | 95 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 94 | 96 | { |
| 95 | - if( empty( $this->email ))return; |
|
| 96 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 97 | + if( empty( $this->email )) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 97 | 103 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 98 | 104 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 99 | 105 | } |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function send( Review $review ) |
| 45 | 45 | { |
| 46 | - if( empty( $this->types ))return; |
|
| 46 | + if( empty( $this->types )) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | $this->review = $review; |
| 48 | 50 | $args = [ |
| 49 | 51 | 'link' => $this->getLink(), |
@@ -158,7 +160,9 @@ discard block |
||
| 158 | 160 | */ |
| 159 | 161 | protected function sendToSlack( array $args ) |
| 160 | 162 | { |
| 161 | - if( !$this->slack )return; |
|
| 163 | + if( !$this->slack ) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 162 | 166 | $notification = $this->buildSlackNotification( $args ); |
| 163 | 167 | $result = $notification->send(); |
| 164 | 168 | if( is_wp_error( $result )) { |
@@ -93,7 +93,9 @@ discard block |
||
| 93 | 93 | $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
| 94 | 94 | array_walk( $args, function( &$value, $key ) { |
| 95 | 95 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 96 | - if( !method_exists( $this, $methodName ))return; |
|
| 96 | + if( !method_exists( $this, $methodName )) { |
|
| 97 | + return; |
|
| 98 | + } |
|
| 97 | 99 | $value = $this->$methodName( $value ); |
| 98 | 100 | }); |
| 99 | 101 | return $this->sanitize( $args ); |
@@ -168,7 +170,9 @@ discard block |
||
| 168 | 170 | $defaults = array_pad( $defaults, glsr()->constant( 'MAX_RATING', Rating::class ), '' ); |
| 169 | 171 | $labels = array_map( 'trim', explode( ',', $labels )); |
| 170 | 172 | foreach( $defaults as $i => $label ) { |
| 171 | - if( empty( $labels[$i] ))continue; |
|
| 173 | + if( empty( $labels[$i] )) { |
|
| 174 | + continue; |
|
| 175 | + } |
|
| 172 | 176 | $defaults[$i] = $labels[$i]; |
| 173 | 177 | } |
| 174 | 178 | return array_combine( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), $defaults ); |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->args = $args; |
| 36 | 36 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args ); |
| 37 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 37 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 38 | 40 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 39 | 41 | $this->generateSchema(); |
| 40 | 42 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -56,7 +58,9 @@ discard block |
||
| 56 | 58 | */ |
| 57 | 59 | protected function buildPercentage() |
| 58 | 60 | { |
| 59 | - if( $this->isHidden( 'bars' ))return; |
|
| 61 | + if( $this->isHidden( 'bars' )) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 60 | 64 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
| 61 | 65 | $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use( $percentages ) { |
| 62 | 66 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
@@ -109,7 +113,9 @@ discard block |
||
| 109 | 113 | */ |
| 110 | 114 | protected function buildRating() |
| 111 | 115 | { |
| 112 | - if( $this->isHidden( 'rating' ))return; |
|
| 116 | + if( $this->isHidden( 'rating' )) { |
|
| 117 | + return; |
|
| 118 | + } |
|
| 113 | 119 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 114 | 120 | } |
| 115 | 121 | |
@@ -118,7 +124,9 @@ discard block |
||
| 118 | 124 | */ |
| 119 | 125 | protected function buildStars() |
| 120 | 126 | { |
| 121 | - if( $this->isHidden( 'stars' ))return; |
|
| 127 | + if( $this->isHidden( 'stars' )) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 122 | 130 | $stars = glsr_star_rating( $this->averageRating ); |
| 123 | 131 | return $this->wrap( 'stars', $stars ); |
| 124 | 132 | } |
@@ -128,7 +136,9 @@ discard block |
||
| 128 | 136 | */ |
| 129 | 137 | protected function buildText() |
| 130 | 138 | { |
| 131 | - if( $this->isHidden( 'summary' ))return; |
|
| 139 | + if( $this->isHidden( 'summary' )) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 132 | 142 | $count = intval( array_sum( $this->ratingCounts )); |
| 133 | 143 | if( empty( $this->args['text'] )) { |
| 134 | 144 | // @todo document this change |
@@ -153,7 +163,9 @@ discard block |
||
| 153 | 163 | */ |
| 154 | 164 | protected function generateSchema() |
| 155 | 165 | { |
| 156 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 166 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 157 | 169 | glsr( Schema::class )->store( |
| 158 | 170 | glsr( Schema::class )->buildSummary( $this->args ) |
| 159 | 171 | ); |