@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 99 | 99 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 100 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 100 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 101 | 103 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 102 | 104 | } |
| 103 | 105 | |
@@ -133,7 +135,9 @@ discard block |
||
| 133 | 135 | */ |
| 134 | 136 | public function renderAssignedToMetabox( WP_Post $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', [ |
@@ -148,7 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | public function renderDetailsMetaBox( WP_Post $post ) |
| 150 | 154 | { |
| 151 | - if( !$this->isReviewPostType( $post ))return; |
|
| 155 | + if( !$this->isReviewPostType( $post )) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 152 | 158 | $review = glsr( ReviewManager::class )->single( $post ); |
| 153 | 159 | glsr()->render( 'partials/editor/metabox-details', [ |
| 154 | 160 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -162,7 +168,9 @@ discard block |
||
| 162 | 168 | */ |
| 163 | 169 | public function renderPinnedInPublishMetaBox() |
| 164 | 170 | { |
| 165 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 171 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 166 | 174 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 167 | 175 | 'context' => [ |
| 168 | 176 | 'no' => __( 'No', 'site-reviews' ), |
@@ -178,7 +186,9 @@ discard block |
||
| 178 | 186 | */ |
| 179 | 187 | public function renderResponseMetaBox( WP_Post $post ) |
| 180 | 188 | { |
| 181 | - if( !$this->isReviewPostType( $post ))return; |
|
| 189 | + if( !$this->isReviewPostType( $post )) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 182 | 192 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 183 | 193 | glsr()->render( 'partials/editor/metabox-response', [ |
| 184 | 194 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -191,7 +201,9 @@ discard block |
||
| 191 | 201 | */ |
| 192 | 202 | public function renderReviewEditor( WP_Post $post ) |
| 193 | 203 | { |
| 194 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 204 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 195 | 207 | glsr()->render( 'partials/editor/review', [ |
| 196 | 208 | 'post' => $post, |
| 197 | 209 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -205,7 +217,9 @@ discard block |
||
| 205 | 217 | public function renderReviewFields() |
| 206 | 218 | { |
| 207 | 219 | $screen = glsr_current_screen(); |
| 208 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 220 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 209 | 223 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 210 | 224 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 211 | 225 | } |
@@ -216,7 +230,9 @@ discard block |
||
| 216 | 230 | */ |
| 217 | 231 | public function renderReviewNotice( WP_Post $post ) |
| 218 | 232 | { |
| 219 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 233 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 234 | + return; |
|
| 235 | + } |
|
| 220 | 236 | glsr( Notice::class )->addWarning( sprintf( |
| 221 | 237 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 222 | 238 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -235,7 +251,9 @@ discard block |
||
| 235 | 251 | */ |
| 236 | 252 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 237 | 253 | { |
| 238 | - if( !$this->isReviewPostType( $post ))return; |
|
| 254 | + if( !$this->isReviewPostType( $post )) { |
|
| 255 | + return; |
|
| 256 | + } |
|
| 239 | 257 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 240 | 258 | 'post' => $post, |
| 241 | 259 | 'tax_name' => Application::TAXONOMY, |
@@ -250,7 +268,9 @@ discard block |
||
| 250 | 268 | */ |
| 251 | 269 | public function revertReview() |
| 252 | 270 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 271 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 254 | 274 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
| 255 | 275 | glsr( ReviewManager::class )->revert( $postId ); |
| 256 | 276 | $this->redirect( $postId, 52 ); |
@@ -274,7 +294,9 @@ discard block |
||
| 274 | 294 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 275 | 295 | { |
| 276 | 296 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 277 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 297 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 298 | + return; |
|
| 299 | + } |
|
| 278 | 300 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 279 | 301 | 'context' => [ |
| 280 | 302 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -320,7 +342,9 @@ discard block |
||
| 320 | 342 | */ |
| 321 | 343 | protected function getReviewType( $review ) |
| 322 | 344 | { |
| 323 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 345 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 346 | + return; |
|
| 347 | + } |
|
| 324 | 348 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 325 | 349 | ? glsr()->reviewTypes[$review->review_type] |
| 326 | 350 | : __( 'Unknown', 'site-reviews' ); |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function renderAssignedToMetabox( WP_Post $post ) |
| 134 | 134 | { |
| 135 | - if( !$this->isReviewPostType( $post ))return; |
|
| 135 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 136 | 136 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 137 | 137 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 138 | 138 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
| 139 | 139 | 'id' => $assignedTo, |
| 140 | 140 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
| 141 | - ]); |
|
| 141 | + ] ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function renderDetailsMetaBox( WP_Post $post ) |
| 149 | 149 | { |
| 150 | - if( !$this->isReviewPostType( $post ))return; |
|
| 150 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 151 | 151 | $review = glsr( ReviewManager::class )->single( $post ); |
| 152 | 152 | glsr()->render( 'partials/editor/metabox-details', [ |
| 153 | 153 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
| 154 | 154 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
| 155 | - ]); |
|
| 155 | + ] ); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -161,14 +161,14 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function renderPinnedInPublishMetaBox() |
| 163 | 163 | { |
| 164 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 164 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
| 165 | 165 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 166 | 166 | 'context' => [ |
| 167 | 167 | 'no' => __( 'No', 'site-reviews' ), |
| 168 | 168 | 'yes' => __( 'Yes', 'site-reviews' ), |
| 169 | 169 | ], |
| 170 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
| 171 | - ]); |
|
| 170 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
| 171 | + ] ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function renderResponseMetaBox( WP_Post $post ) |
| 179 | 179 | { |
| 180 | - if( !$this->isReviewPostType( $post ))return; |
|
| 180 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 181 | 181 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 182 | 182 | glsr()->render( 'partials/editor/metabox-response', [ |
| 183 | 183 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 184 | - ]); |
|
| 184 | + ] ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function renderReviewEditor( WP_Post $post ) |
| 192 | 192 | { |
| 193 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 193 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 194 | 194 | glsr()->render( 'partials/editor/review', [ |
| 195 | 195 | 'post' => $post, |
| 196 | 196 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 197 | - ]); |
|
| 197 | + ] ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $screen = glsr_current_screen(); |
| 207 | 207 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
| 208 | 208 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 209 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 209 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function renderReviewNotice( WP_Post $post ) |
| 217 | 217 | { |
| 218 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 218 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 219 | 219 | glsr( Notice::class )->addWarning( sprintf( |
| 220 | 220 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 221 | 221 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
| 222 | - )); |
|
| 222 | + ) ); |
|
| 223 | 223 | glsr( Template::class )->render( 'partials/editor/notice', [ |
| 224 | 224 | 'context' => [ |
| 225 | 225 | 'notices' => glsr( Notice::class )->get(), |
| 226 | 226 | ], |
| 227 | - ]); |
|
| 227 | + ] ); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 236 | 236 | { |
| 237 | - if( !$this->isReviewPostType( $post ))return; |
|
| 237 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 238 | 238 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 239 | 239 | 'post' => $post, |
| 240 | 240 | 'tax_name' => Application::TAXONOMY, |
| 241 | 241 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
| 242 | - ]); |
|
| 242 | + ] ); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | public function revertReview() |
| 251 | 251 | { |
| 252 | 252 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 253 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
| 253 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
| 254 | 254 | glsr( ReviewManager::class )->revert( $postId ); |
| 255 | 255 | $this->redirect( $postId, 52 ); |
| 256 | 256 | } |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 274 | 274 | { |
| 275 | 275 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 276 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 276 | + if( !($assignedPost instanceof WP_Post) )return; |
|
| 277 | 277 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 278 | 278 | 'context' => [ |
| 279 | 279 | 'data.url' => (string)get_permalink( $assignedPost ), |
| 280 | 280 | 'data.title' => get_the_title( $assignedPost ), |
| 281 | 281 | ], |
| 282 | - ]); |
|
| 282 | + ] ); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | 'class' => 'button button-large', |
| 305 | 305 | 'href' => $revertUrl, |
| 306 | 306 | 'id' => 'revert', |
| 307 | - ]); |
|
| 307 | + ] ); |
|
| 308 | 308 | } |
| 309 | 309 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
| 310 | 310 | 'class' => 'button button-large', |
| 311 | 311 | 'disabled' => true, |
| 312 | 312 | 'id' => 'revert', |
| 313 | - ]); |
|
| 313 | + ] ); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 324 | 324 | ? glsr()->reviewTypes[$review->review_type] |
| 325 | 325 | : __( 'Unknown', 'site-reviews' ); |
| 326 | - if( !empty( $review->url )) { |
|
| 326 | + if( !empty($review->url) ) { |
|
| 327 | 327 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
| 328 | 328 | 'href' => $review->url, |
| 329 | 329 | 'target' => '_blank', |
| 330 | - ]); |
|
| 330 | + ] ); |
|
| 331 | 331 | } |
| 332 | 332 | return $reviewType; |
| 333 | 333 | } |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | protected function normalizeDetailsMetaBox( Review $review ) |
| 358 | 358 | { |
| 359 | - $user = empty( $review->user_id ) |
|
| 359 | + $user = empty($review->user_id) |
|
| 360 | 360 | ? __( 'Unregistered user', 'site-reviews' ) |
| 361 | 361 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
| 362 | 362 | 'href' => get_author_posts_url( $review->user_id ), |
| 363 | - ]); |
|
| 364 | - $email = empty( $review->email ) |
|
| 363 | + ] ); |
|
| 364 | + $email = empty($review->email) |
|
| 365 | 365 | ? '—' |
| 366 | 366 | : glsr( Builder::class )->a( $review->email, [ |
| 367 | 367 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
| 368 | - ]); |
|
| 368 | + ] ); |
|
| 369 | 369 | $metabox = [ |
| 370 | 370 | __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
| 371 | 371 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
| 377 | 377 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
| 378 | 378 | ]; |
| 379 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
| 379 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | $redirectUri = $hasReferer |
| 394 | 394 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
| 395 | 395 | : get_edit_post_link( $postId ); |
| 396 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
| 396 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
| 397 | 397 | exit; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -125,7 +125,9 @@ discard block |
||
| 125 | 125 | $termId = intval( $termId ); |
| 126 | 126 | } |
| 127 | 127 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 128 | - if( !isset( $term['term_id'] ))continue; |
|
| 128 | + if( !isset( $term['term_id'] )) { |
|
| 129 | + continue; |
|
| 130 | + } |
|
| 129 | 131 | $terms[] = $term; |
| 130 | 132 | } |
| 131 | 133 | return $terms; |
@@ -137,7 +139,9 @@ discard block |
||
| 137 | 139 | */ |
| 138 | 140 | public function revert( $postId ) |
| 139 | 141 | { |
| 140 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 142 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 143 | + return; |
|
| 144 | + } |
|
| 141 | 145 | delete_post_meta( $postId, '_edit_last' ); |
| 142 | 146 | $result = wp_update_post([ |
| 143 | 147 | 'ID' => $postId, |
@@ -182,7 +186,9 @@ discard block |
||
| 182 | 186 | protected function setTerms( $postId, $termIds ) |
| 183 | 187 | { |
| 184 | 188 | $termIds = $this->normalizeTermIds( $termIds ); |
| 185 | - if( empty( $termIds ))return; |
|
| 189 | + if( empty( $termIds )) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 186 | 192 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
| 187 | 193 | if( is_wp_error( $termTaxonomyIds )) { |
| 188 | 194 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | 'post_type' => Application::POST_TYPE, |
| 40 | 40 | ]; |
| 41 | 41 | $postId = wp_insert_post( $postValues, true ); |
| 42 | - if( is_wp_error( $postId )) { |
|
| 42 | + if( is_wp_error( $postId ) ) { |
|
| 43 | 43 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | $this->setTerms( $postId, $command->category ); |
| 47 | - $review = $this->single( get_post( $postId )); |
|
| 47 | + $review = $this->single( get_post( $postId ) ); |
|
| 48 | 48 | do_action( 'site-reviews/review/created', $review, $command ); |
| 49 | 49 | return $review; |
| 50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function delete( $metaReviewId ) |
| 57 | 57 | { |
| 58 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
| 58 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
| 59 | 59 | wp_delete_post( $postId, true ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $paged = glsr( QueryBuilder::class )->getPaged( |
| 78 | 78 | wp_validate_boolean( $args['pagination'] ) |
| 79 | 79 | ); |
| 80 | - $query = new WP_Query([ |
|
| 80 | + $query = new WP_Query( [ |
|
| 81 | 81 | 'meta_key' => 'pinned', |
| 82 | 82 | 'meta_query' => $metaQuery, |
| 83 | 83 | 'offset' => $args['offset'], |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'post_type' => Application::POST_TYPE, |
| 91 | 91 | 'posts_per_page' => $args['count'], |
| 92 | 92 | 'tax_query' => $taxQuery, |
| 93 | - ]); |
|
| 93 | + ] ); |
|
| 94 | 94 | $results = array_map( [$this, 'single'], $query->posts ); |
| 95 | 95 | $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
| 96 | 96 | return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | public function getRatingCounts( array $args = [] ) |
| 112 | 112 | { |
| 113 | 113 | $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args ); |
| 114 | - $counts = glsr( CountsManager::class )->get([ |
|
| 114 | + $counts = glsr( CountsManager::class )->get( [ |
|
| 115 | 115 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
| 116 | 116 | 'term_ids' => $this->normalizeTermIds( $args['category'] ), |
| 117 | 117 | 'type' => $args['type'], |
| 118 | - ]); |
|
| 118 | + ] ); |
|
| 119 | 119 | return glsr( CountsManager::class )->flatten( $counts, [ |
| 120 | 120 | 'min' => $args['rating'], |
| 121 | - ]); |
|
| 121 | + ] ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | public function normalizeTermIds( $commaSeparatedTermIds ) |
| 129 | 129 | { |
| 130 | 130 | $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
| 131 | - return array_unique( array_map( 'intval', $termIds )); |
|
| 131 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -140,11 +140,11 @@ discard block |
||
| 140 | 140 | $terms = []; |
| 141 | 141 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
| 142 | 142 | foreach( $termIds as $termId ) { |
| 143 | - if( is_numeric( $termId )) { |
|
| 143 | + if( is_numeric( $termId ) ) { |
|
| 144 | 144 | $termId = intval( $termId ); |
| 145 | 145 | } |
| 146 | 146 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 147 | - if( !isset( $term['term_id'] ))continue; |
|
| 147 | + if( !isset($term['term_id']) )continue; |
|
| 148 | 148 | $terms[] = $term; |
| 149 | 149 | } |
| 150 | 150 | return $terms; |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
| 160 | 160 | delete_post_meta( $postId, '_edit_last' ); |
| 161 | - $result = wp_update_post([ |
|
| 161 | + $result = wp_update_post( [ |
|
| 162 | 162 | 'ID' => $postId, |
| 163 | 163 | 'post_content' => get_post_meta( $postId, 'content', true ), |
| 164 | 164 | 'post_date' => get_post_meta( $postId, 'date', true ), |
| 165 | 165 | 'post_title' => get_post_meta( $postId, 'title', true ), |
| 166 | - ]); |
|
| 167 | - if( is_wp_error( $result )) { |
|
| 166 | + ] ); |
|
| 167 | + if( is_wp_error( $result ) ) { |
|
| 168 | 168 | glsr_log()->error( $result->get_error_message() ); |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
| 189 | 189 | { |
| 190 | 190 | $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' ); |
| 191 | - return $review['review_type'] == 'local' && ( $requireApproval || $isBlacklisted ) |
|
| 191 | + return $review['review_type'] == 'local' && ($requireApproval || $isBlacklisted) |
|
| 192 | 192 | ? 'pending' |
| 193 | 193 | : 'publish'; |
| 194 | 194 | } |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | protected function setTerms( $postId, $termIds ) |
| 202 | 202 | { |
| 203 | 203 | $termIds = $this->normalizeTermIds( $termIds ); |
| 204 | - if( empty( $termIds ))return; |
|
| 204 | + if( empty($termIds) )return; |
|
| 205 | 205 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
| 206 | - if( is_wp_error( $termTaxonomyIds )) { |
|
| 206 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
| 207 | 207 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -67,7 +67,9 @@ discard block |
||
| 67 | 67 | $field = method_exists( $this, $method ) |
| 68 | 68 | ? $this->$method( $key, $value ) |
| 69 | 69 | : apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review ); |
| 70 | - if( $field === false )continue; |
|
| 70 | + if( $field === false ) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 71 | 73 | $renderedFields[$key] = $field; |
| 72 | 74 | } |
| 73 | 75 | $this->wrap( $renderedFields, $review ); |
@@ -95,7 +97,9 @@ discard block |
||
| 95 | 97 | */ |
| 96 | 98 | public function generateSchema() |
| 97 | 99 | { |
| 98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 100 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 99 | 103 | glsr( Schema::class )->store( |
| 100 | 104 | glsr( Schema::class )->build( $this->args ) |
| 101 | 105 | ); |
@@ -121,9 +125,13 @@ discard block |
||
| 121 | 125 | */ |
| 122 | 126 | protected function buildOptionAssignedTo( $key, $value ) |
| 123 | 127 | { |
| 124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 128 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 125 | 131 | $post = glsr( Polylang::class )->getPost( $value ); |
| 126 | - if( !( $post instanceof WP_Post ))return; |
|
| 132 | + if( !( $post instanceof WP_Post )) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 127 | 135 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 128 | 136 | 'href' => get_the_permalink( $post->ID ), |
| 129 | 137 | ]); |
@@ -138,7 +146,9 @@ discard block |
||
| 138 | 146 | */ |
| 139 | 147 | protected function buildOptionAuthor( $key, $value ) |
| 140 | 148 | { |
| 141 | - if( $this->isHidden( $key ))return; |
|
| 149 | + if( $this->isHidden( $key )) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 142 | 152 | return '<span>'.$value.'</span>'; |
| 143 | 153 | } |
| 144 | 154 | |
@@ -149,7 +159,9 @@ discard block |
||
| 149 | 159 | */ |
| 150 | 160 | protected function buildOptionAvatar( $key, $value ) |
| 151 | 161 | { |
| 152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 162 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 153 | 165 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 154 | 166 | return glsr( Builder::class )->img([ |
| 155 | 167 | 'height' => $size, |
@@ -167,7 +179,9 @@ discard block |
||
| 167 | 179 | protected function buildOptionContent( $key, $value ) |
| 168 | 180 | { |
| 169 | 181 | $text = $this->normalizeText( $value ); |
| 170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 182 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 171 | 185 | return '<p>'.$text.'</p>'; |
| 172 | 186 | } |
| 173 | 187 | |
@@ -178,7 +192,9 @@ discard block |
||
| 178 | 192 | */ |
| 179 | 193 | protected function buildOptionDate( $key, $value ) |
| 180 | 194 | { |
| 181 | - if( $this->isHidden( $key ))return; |
|
| 195 | + if( $this->isHidden( $key )) { |
|
| 196 | + return; |
|
| 197 | + } |
|
| 182 | 198 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 183 | 199 | if( $dateFormat == 'relative' ) { |
| 184 | 200 | $date = glsr( Date::class )->relative( $value ); |
@@ -199,7 +215,9 @@ discard block |
||
| 199 | 215 | */ |
| 200 | 216 | protected function buildOptionRating( $key, $value ) |
| 201 | 217 | { |
| 202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 218 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 219 | + return; |
|
| 220 | + } |
|
| 203 | 221 | return glsr_star_rating( $value ); |
| 204 | 222 | } |
| 205 | 223 | |
@@ -210,7 +228,9 @@ discard block |
||
| 210 | 228 | */ |
| 211 | 229 | protected function buildOptionResponse( $key, $value ) |
| 212 | 230 | { |
| 213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 231 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 232 | + return; |
|
| 233 | + } |
|
| 214 | 234 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 215 | 235 | $text = $this->normalizeText( $value ); |
| 216 | 236 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -226,7 +246,9 @@ discard block |
||
| 226 | 246 | */ |
| 227 | 247 | protected function buildOptionTitle( $key, $value ) |
| 228 | 248 | { |
| 229 | - if( $this->isHidden( $key ))return; |
|
| 249 | + if( $this->isHidden( $key )) { |
|
| 250 | + return; |
|
| 251 | + } |
|
| 230 | 252 | if( empty( $value )) { |
| 231 | 253 | $value = __( 'No Title', 'site-reviews' ); |
| 232 | 254 | } |
@@ -285,9 +307,13 @@ discard block |
||
| 285 | 307 | $words->setText( $text ); |
| 286 | 308 | $count = 0; |
| 287 | 309 | foreach( $words as $offset ){ |
| 288 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
| 310 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
| 311 | + continue; |
|
| 312 | + } |
|
| 289 | 313 | $count++; |
| 290 | - if( $count != $limit )continue; |
|
| 314 | + if( $count != $limit ) { |
|
| 315 | + continue; |
|
| 316 | + } |
|
| 291 | 317 | return $offset; |
| 292 | 318 | } |
| 293 | 319 | return strlen( $text ); |
@@ -363,7 +389,9 @@ discard block |
||
| 363 | 389 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
| 364 | 390 | array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
| 365 | 391 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
| 366 | - if( empty( $value ))return; |
|
| 392 | + if( empty( $value )) { |
|
| 393 | + return; |
|
| 394 | + } |
|
| 367 | 395 | $value = glsr( Builder::class )->div( $value, [ |
| 368 | 396 | 'class' => 'glsr-review-'.$key, |
| 369 | 397 | ]); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | foreach( $this->reviews as $index => $review ) { |
| 86 | 86 | $renderedReviews[] = glsr( Template::class )->build( 'templates/review', [ |
| 87 | 87 | 'context' => $this->buildReview( $review )->values, |
| 88 | - ]); |
|
| 88 | + ] ); |
|
| 89 | 89 | } |
| 90 | 90 | return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args ); |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function generateSchema() |
| 97 | 97 | { |
| 98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 98 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 99 | 99 | glsr( Schema::class )->store( |
| 100 | 100 | glsr( Schema::class )->build( $this->args ) |
| 101 | 101 | ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function isHidden( $key, $path = '' ) |
| 110 | 110 | { |
| 111 | - $isOptionEnabled = !empty( $path ) |
|
| 111 | + $isOptionEnabled = !empty($path) |
|
| 112 | 112 | ? $this->isOptionEnabled( $path ) |
| 113 | 113 | : true; |
| 114 | 114 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildOptionAssignedTo( $key, $value ) |
| 123 | 123 | { |
| 124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 124 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
| 125 | 125 | $post = glsr( Polylang::class )->getPost( $value ); |
| 126 | - if( !( $post instanceof WP_Post ))return; |
|
| 126 | + if( !($post instanceof WP_Post) )return; |
|
| 127 | 127 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 128 | 128 | 'href' => get_the_permalink( $post->ID ), |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 131 | 131 | return '<span>'.$assignedTo.'</span>'; |
| 132 | 132 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | protected function buildOptionAuthor( $key, $value ) |
| 140 | 140 | { |
| 141 | - if( $this->isHidden( $key ))return; |
|
| 141 | + if( $this->isHidden( $key ) )return; |
|
| 142 | 142 | return '<span>'.$value.'</span>'; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function buildOptionAvatar( $key, $value ) |
| 151 | 151 | { |
| 152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 152 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
| 153 | 153 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 154 | - return glsr( Builder::class )->img([ |
|
| 154 | + return glsr( Builder::class )->img( [ |
|
| 155 | 155 | 'height' => $size, |
| 156 | 156 | 'src' => $this->generateAvatar( $value ), |
| 157 | 157 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
| 158 | 158 | 'width' => $size, |
| 159 | - ]); |
|
| 159 | + ] ); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | protected function buildOptionContent( $key, $value ) |
| 168 | 168 | { |
| 169 | 169 | $text = $this->normalizeText( $value ); |
| 170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 170 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 171 | 171 | return '<p>'.$text.'</p>'; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function buildOptionDate( $key, $value ) |
| 180 | 180 | { |
| 181 | - if( $this->isHidden( $key ))return; |
|
| 181 | + if( $this->isHidden( $key ) )return; |
|
| 182 | 182 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 183 | 183 | if( $dateFormat == 'relative' ) { |
| 184 | 184 | $date = glsr( Date::class )->relative( $value ); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $format = $dateFormat == 'custom' |
| 188 | 188 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 189 | 189 | : (string)get_option( 'date_format' ); |
| 190 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 190 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 191 | 191 | } |
| 192 | 192 | return '<span>'.$date.'</span>'; |
| 193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function buildOptionRating( $key, $value ) |
| 201 | 201 | { |
| 202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 202 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 203 | 203 | return glsr_star_rating( $value ); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function buildOptionResponse( $key, $value ) |
| 212 | 212 | { |
| 213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 214 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 213 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 214 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 215 | 215 | $text = $this->normalizeText( $value ); |
| 216 | 216 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
| 217 | 217 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function buildOptionTitle( $key, $value ) |
| 228 | 228 | { |
| 229 | - if( $this->isHidden( $key ))return; |
|
| 230 | - if( empty( $value )) { |
|
| 229 | + if( $this->isHidden( $key ) )return; |
|
| 230 | + if( empty($value) ) { |
|
| 231 | 231 | $value = __( 'No Title', 'site-reviews' ); |
| 232 | 232 | } |
| 233 | 233 | return '<h3>'.$value.'</h3>'; |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | return $avatarUrl; |
| 244 | 244 | } |
| 245 | 245 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
| 246 | - if( empty( $authorIdOrEmail )) { |
|
| 246 | + if( empty($authorIdOrEmail) ) { |
|
| 247 | 247 | $authorIdOrEmail = $this->current->email; |
| 248 | 248 | } |
| 249 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
| 249 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
| 250 | 250 | return $newAvatar; |
| 251 | 251 | } |
| 252 | 252 | return $avatarUrl; |
@@ -258,18 +258,18 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function getExcerpt( $text ) |
| 260 | 260 | { |
| 261 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
| 261 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
| 262 | 262 | $split = extension_loaded( 'intl' ) |
| 263 | 263 | ? $this->getExcerptIntlSplit( $text, $limit ) |
| 264 | 264 | : $this->getExcerptSplit( $text, $limit ); |
| 265 | 265 | $hiddenText = substr( $text, $split ); |
| 266 | - if( !empty( $hiddenText )) { |
|
| 266 | + if( !empty($hiddenText) ) { |
|
| 267 | 267 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 268 | 268 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 269 | 269 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 270 | 270 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 271 | - ]); |
|
| 272 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
| 271 | + ] ); |
|
| 272 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
| 273 | 273 | } |
| 274 | 274 | return $text; |
| 275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
| 285 | 285 | $words->setText( $text ); |
| 286 | 286 | $count = 0; |
| 287 | - foreach( $words as $offset ){ |
|
| 287 | + foreach( $words as $offset ) { |
|
| 288 | 288 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
| 289 | 289 | $count++; |
| 290 | 290 | if( $count != $limit )continue; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | protected function getExcerptSplit( $text, $limit ) |
| 302 | 302 | { |
| 303 | 303 | if( str_word_count( $text, 0 ) > $limit ) { |
| 304 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 304 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 305 | 305 | return $words[$limit]; |
| 306 | 306 | } |
| 307 | 307 | return strlen( $text ); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | protected function getOption( $path, $fallback = '' ) |
| 316 | 316 | { |
| 317 | - if( array_key_exists( $path, $this->options )) { |
|
| 317 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 318 | 318 | return $this->options[$path]; |
| 319 | 319 | } |
| 320 | 320 | return $fallback; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | protected function isHiddenOrEmpty( $key, $value ) |
| 329 | 329 | { |
| 330 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 330 | + return $this->isHidden( $key ) || empty($value); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -346,13 +346,13 @@ discard block |
||
| 346 | 346 | protected function normalizeText( $text ) |
| 347 | 347 | { |
| 348 | 348 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 349 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
| 349 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
| 350 | 350 | $text = str_replace( ']]>', ']]>', $text ); |
| 351 | 351 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
| 352 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
| 352 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
| 353 | 353 | $text = $this->getExcerpt( $text ); |
| 354 | 354 | } |
| 355 | - return wptexturize( nl2br( $text )); |
|
| 355 | + return wptexturize( nl2br( $text ) ); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | protected function wrap( array &$renderedFields, Review $review ) |
| 362 | 362 | { |
| 363 | 363 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
| 364 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
| 364 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
| 365 | 365 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
| 366 | - if( empty( $value ))return; |
|
| 366 | + if( empty($value) )return; |
|
| 367 | 367 | $value = glsr( Builder::class )->div( $value, [ |
| 368 | 368 | 'class' => 'glsr-review-'.$key, |
| 369 | - ]); |
|
| 369 | + ] ); |
|
| 370 | 370 | }); |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if( $assignedPost instanceof WP_Post && $assignedPost->post_status == 'publish' ) { |
| 22 | 22 | $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
| 23 | 23 | 'href' => (string)get_the_permalink( $assignedPost->ID ), |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | } |
| 26 | 26 | return $column; |
| 27 | 27 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | $pinned = get_post_meta( $postId, 'pinned', true ) |
| 36 | 36 | ? 'pinned ' |
| 37 | 37 | : ''; |
| 38 | - return glsr( Builder::class )->i([ |
|
| 38 | + return glsr( Builder::class )->i( [ |
|
| 39 | 39 | 'class' => $pinned.'dashicons dashicons-sticky', |
| 40 | 40 | 'data-id' => $postId, |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function buildColumnReviewer( $postId ) |
| 49 | 49 | { |
| 50 | - return strval( get_post_meta( $postId, 'author', true )); |
|
| 50 | + return strval( get_post_meta( $postId, 'author', true ) ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function buildColumnRating( $postId ) |
| 59 | 59 | { |
| 60 | - return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ))); |
|
| 60 | + return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ) ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function renderFilters( $postType ) |
| 80 | 80 | { |
| 81 | 81 | if( $postType !== Application::POST_TYPE )return; |
| 82 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
| 82 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
| 83 | 83 | $status = 'publish'; |
| 84 | 84 | } |
| 85 | 85 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function renderFilterRatings( $ratings ) |
| 110 | 110 | { |
| 111 | - if( empty( $ratings ))return; |
|
| 112 | - $ratings = array_flip( array_reverse( $ratings )); |
|
| 111 | + if( empty($ratings) )return; |
|
| 112 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
| 113 | 113 | array_walk( $ratings, function( &$value, $key ) { |
| 114 | 114 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
| 115 | 115 | $value = sprintf( $label, $key ); |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
| 118 | 118 | 'class' => 'screen-reader-text', |
| 119 | 119 | 'for' => 'rating', |
| 120 | - ]); |
|
| 121 | - echo glsr( Builder::class )->select([ |
|
| 120 | + ] ); |
|
| 121 | + echo glsr( Builder::class )->select( [ |
|
| 122 | 122 | 'name' => 'rating', |
| 123 | 123 | 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
| 124 | 124 | 'value' => filter_input( INPUT_GET, 'rating' ), |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 136 | 136 | 'class' => 'screen-reader-text', |
| 137 | 137 | 'for' => 'review_type', |
| 138 | - ]); |
|
| 139 | - echo glsr( Builder::class )->select([ |
|
| 138 | + ] ); |
|
| 139 | + echo glsr( Builder::class )->select( [ |
|
| 140 | 140 | 'name' => 'review_type', |
| 141 | 141 | 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
| 142 | 142 | 'value' => filter_input( INPUT_GET, 'review_type' ), |
| 143 | - ]); |
|
| 143 | + ] ); |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -78,7 +78,9 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function renderFilters( $postType ) |
| 80 | 80 | { |
| 81 | - if( $postType !== Application::POST_TYPE )return; |
|
| 81 | + if( $postType !== Application::POST_TYPE ) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 82 | 84 | if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
| 83 | 85 | $status = 'publish'; |
| 84 | 86 | } |
@@ -107,7 +109,9 @@ discard block |
||
| 107 | 109 | */ |
| 108 | 110 | protected function renderFilterRatings( $ratings ) |
| 109 | 111 | { |
| 110 | - if( empty( $ratings ))return; |
|
| 112 | + if( empty( $ratings )) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 111 | 115 | $ratings = array_flip( array_reverse( $ratings )); |
| 112 | 116 | array_walk( $ratings, function( &$value, $key ) { |
| 113 | 117 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
@@ -130,7 +134,9 @@ discard block |
||
| 130 | 134 | */ |
| 131 | 135 | protected function renderFilterTypes( $types ) |
| 132 | 136 | { |
| 133 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 137 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 138 | + return; |
|
| 139 | + } |
|
| 134 | 140 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 135 | 141 | 'class' => 'screen-reader-text', |
| 136 | 142 | 'for' => 'review_type', |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | public function fields() |
| 14 | 14 | { |
| 15 | 15 | return [[ |
| 16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 17 | 17 | 'minWidth' => 320, |
| 18 | 18 | 'type' => 'container', |
| 19 | - ],[ |
|
| 19 | + ], [ |
|
| 20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 21 | 21 | 'name' => 'title', |
| 22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 23 | 23 | 'type' => 'textbox', |
| 24 | - ],[ |
|
| 24 | + ], [ |
|
| 25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
| 26 | 26 | 'maxLength' => 5, |
| 27 | 27 | 'name' => 'count', |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | 'text' => '10', |
| 30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
| 31 | 31 | 'type' => 'textbox', |
| 32 | - ],[ |
|
| 32 | + ], [ |
|
| 33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
| 34 | 34 | 'name' => 'rating', |
| 35 | 35 | 'options' => [ |
| 36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
| 37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
| 38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
| 39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
| 40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
| 41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
| 36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
| 37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
| 38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
| 39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
| 40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
| 41 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
| 42 | 42 | ], |
| 43 | 43 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
| 44 | 44 | 'type' => 'listbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
| 47 | 47 | 'name' => 'pagination', |
| 48 | 48 | 'options' => [ |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | 'tooltip' => __( 'When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews' ), |
| 54 | 54 | 'type' => 'listbox', |
| 55 | 55 | ], |
| 56 | - $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' )), |
|
| 57 | - $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' )), |
|
| 56 | + $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' ) ), |
|
| 57 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
| 58 | 58 | [ |
| 59 | 59 | 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 60 | 60 | 'name' => 'assigned_to', |
| 61 | 61 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page, or "parent_id" to use the ID of the parent page.', 'site-reviews' ), |
| 62 | 62 | 'type' => 'textbox', |
| 63 | - ],[ |
|
| 63 | + ], [ |
|
| 64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 65 | 65 | 'name' => 'schema', |
| 66 | 66 | 'options' => [ |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | ], |
| 70 | 70 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 71 | 71 | 'type' => 'listbox', |
| 72 | - ],[ |
|
| 72 | + ], [ |
|
| 73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 74 | 74 | 'name' => 'class', |
| 75 | 75 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 76 | 76 | 'type' => 'textbox', |
| 77 | - ],[ |
|
| 77 | + ], [ |
|
| 78 | 78 | 'columns' => 2, |
| 79 | 79 | 'items' => $this->getHideOptions(), |
| 80 | 80 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 81 | 81 | 'layout' => 'grid', |
| 82 | 82 | 'spacing' => 5, |
| 83 | 83 | 'type' => 'container', |
| 84 | - ],[ |
|
| 84 | + ], [ |
|
| 85 | 85 | 'hidden' => true, |
| 86 | 86 | 'name' => 'id', |
| 87 | 87 | 'type' => 'textbox', |
@@ -12,23 +12,23 @@ discard block |
||
| 12 | 12 | public function fields() |
| 13 | 13 | { |
| 14 | 14 | return [[ |
| 15 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 15 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 16 | 16 | 'minWidth' => 320, |
| 17 | 17 | 'type' => 'container', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 22 | 22 | 'type' => 'textbox', |
| 23 | 23 | ], |
| 24 | - $this->getTypes( __( 'Which type of review would you like to use?', 'site-reviews' )), |
|
| 25 | - $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' )), |
|
| 24 | + $this->getTypes( __( 'Which type of review would you like to use?', 'site-reviews' ) ), |
|
| 25 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
| 26 | 26 | [ |
| 27 | 27 | 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 28 | 28 | 'name' => 'assigned_to', |
| 29 | 29 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page, or "parent_id" to use the ID of the parent page.', 'site-reviews' ), |
| 30 | 30 | 'type' => 'textbox', |
| 31 | - ],[ |
|
| 31 | + ], [ |
|
| 32 | 32 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 33 | 33 | 'name' => 'schema', |
| 34 | 34 | 'options' => [ |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | ], |
| 38 | 38 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 39 | 39 | 'type' => 'listbox', |
| 40 | - ],[ |
|
| 40 | + ], [ |
|
| 41 | 41 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 42 | 42 | 'name' => 'class', |
| 43 | 43 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 44 | 44 | 'type' => 'textbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'columns' => 2, |
| 47 | 47 | 'items' => $this->getHideOptions(), |
| 48 | 48 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | $this->filterShortcodeClass(); |
| 74 | 74 | $this->filterShowMoreLinks( 'content' ); |
| 75 | 75 | $this->filterShowMoreLinks( 'response' ); |
| 76 | - if( !$this->hasVisibleFields( $shortcode, $attributes )) { |
|
| 76 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
| 77 | 77 | $this->filterInterpolation(); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $this->filterRatingField(); |
| 49 | 49 | $this->filterShortcodeClass(); |
| 50 | 50 | $this->filterSubmitButton(); |
| 51 | - if( !$this->hasVisibleFields( $shortcode, $attributes )) { |
|
| 51 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
| 52 | 52 | $this->filterInterpolation(); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) { |
| 92 | 92 | if( $args['path'] == 'rating' ) { |
| 93 | 93 | $stars = '<span class="glsr-stars">'; |
| 94 | - $stars.= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', 5 ); |
|
| 95 | - $stars.= '</span>'; |
|
| 94 | + $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', 5 ); |
|
| 95 | + $stars .= '</span>'; |
|
| 96 | 96 | $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html ); |
| 97 | 97 | } |
| 98 | 98 | return $html; |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | if( filter_input( INPUT_GET, 'context' ) == 'edit' ) { |
| 59 | 59 | $attributes = $this->normalize( $attributes ); |
| 60 | 60 | $this->filterShortcodeClass(); |
| 61 | - if( !$this->hasVisibleFields( $shortcode, $attributes )) { |
|
| 61 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
| 62 | 62 | $this->filterInterpolation(); |
| 63 | 63 | } |
| 64 | 64 | } |