@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | public function build( array $args = [] ) |
| 35 | 35 | { |
| 36 | 36 | $this->args = $args; |
| 37 | - $counts = glsr( CountsManager::class )->get([ |
|
| 37 | + $counts = glsr( CountsManager::class )->get( [ |
|
| 38 | 38 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
| 39 | 39 | 'term_ids' => glsr( ReviewManager::class )->normalizeTermIds( $args['category'] ), |
| 40 | 40 | 'type' => $args['type'], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
| 43 | 43 | 'min' => $args['rating'], |
| 44 | - ]); |
|
| 45 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 44 | + ] ); |
|
| 45 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return; |
|
| 46 | 46 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 47 | 47 | $this->generateSchema(); |
| 48 | 48 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'stars' => $this->buildStars(), |
| 56 | 56 | 'text' => $this->buildText(), |
| 57 | 57 | ], |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function buildPercentage() |
| 65 | 65 | { |
| 66 | - if( $this->isHidden( 'bars' ))return; |
|
| 67 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
| 68 | - $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
|
| 66 | + if( $this->isHidden( 'bars' ) )return; |
|
| 67 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
| 68 | + $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) { |
|
| 69 | 69 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
| 70 | 70 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
| 71 | 71 | $count = apply_filters( 'site-reviews/summary/counts', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $percent = $this->buildPercentageCount( $count ); |
| 76 | 76 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
| 77 | 77 | 'class' => 'glsr-bar', |
| 78 | - ]); |
|
| 78 | + ] ); |
|
| 79 | 79 | }); |
| 80 | 80 | return $this->wrap( 'percentage', $bars ); |
| 81 | 81 | } |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function buildPercentageBackground( $percent ) |
| 88 | 88 | { |
| 89 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
| 89 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
| 90 | 90 | 'class' => 'glsr-bar-background-percent', |
| 91 | 91 | 'style' => 'width:'.$percent, |
| 92 | - ]); |
|
| 92 | + ] ); |
|
| 93 | 93 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | protected function buildRating() |
| 118 | 118 | { |
| 119 | - if( $this->isHidden( 'rating' ))return; |
|
| 119 | + if( $this->isHidden( 'rating' ) )return; |
|
| 120 | 120 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function buildStars() |
| 127 | 127 | { |
| 128 | - if( $this->isHidden( 'stars' ))return; |
|
| 128 | + if( $this->isHidden( 'stars' ) )return; |
|
| 129 | 129 | $stars = glsr_star_rating( $this->averageRating ); |
| 130 | 130 | return $this->wrap( 'stars', $stars ); |
| 131 | 131 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function buildText() |
| 137 | 137 | { |
| 138 | - if( $this->isHidden( 'summary' ))return; |
|
| 139 | - $count = intval( array_sum( $this->ratingCounts )); |
|
| 140 | - if( empty( $this->args['text'] )) { |
|
| 138 | + if( $this->isHidden( 'summary' ) )return; |
|
| 139 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
| 140 | + if( empty($this->args['text']) ) { |
|
| 141 | 141 | // @todo document this change |
| 142 | 142 | $this->args['text'] = _nx( |
| 143 | 143 | '{rating} out of {max} stars (based on {num} review)', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | $summary = str_replace( |
| 151 | - ['{rating}','{max}', '{num}'], |
|
| 151 | + ['{rating}', '{max}', '{num}'], |
|
| 152 | 152 | [$this->averageRating, Rating::MAX_RATING, $count], |
| 153 | 153 | $this->args['text'] |
| 154 | 154 | ); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function generateSchema() |
| 162 | 162 | { |
| 163 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 163 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 164 | 164 | glsr( Schema::class )->store( |
| 165 | 165 | glsr( Schema::class )->buildSummary( $this->args ) |
| 166 | 166 | ); |
@@ -192,6 +192,6 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | return glsr( Builder::class )->div( $value, [ |
| 194 | 194 | 'class' => 'glsr-summary-'.$key, |
| 195 | - ]); |
|
| 195 | + ] ); |
|
| 196 | 196 | } |
| 197 | 197 | } |
@@ -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 | } |
@@ -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 | } |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | 'glsr_log', |
| 21 | 21 | 'glsr_star_rating', |
| 22 | 22 | ); |
| 23 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
| 24 | - add_filter( $hook, function() use( $hook, $args ) { |
|
| 23 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return; |
|
| 24 | + add_filter( $hook, function() use($hook, $args) { |
|
| 25 | 25 | array_shift( $args ); // remove the fallback value |
| 26 | 26 | return call_user_func_array( $hook, $args ); |
| 27 | 27 | }); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function glsr( $alias = null ) { |
| 34 | 34 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 35 | - return !empty( $alias ) |
|
| 35 | + return !empty($alias) |
|
| 36 | 36 | ? $app->make( $alias ) |
| 37 | 37 | : $app; |
| 38 | 38 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $result = array(); |
| 47 | 47 | foreach( $array as $subarray ) { |
| 48 | 48 | $subarray = (array)$subarray; |
| 49 | - if( !isset( $subarray[$column] ))continue; |
|
| 49 | + if( !isset($subarray[$column]) )continue; |
|
| 50 | 50 | $result[] = $subarray[$column]; |
| 51 | 51 | } |
| 52 | 52 | return $result; |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | function glsr_calculate_ratings() { |
| 59 | 59 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
| 60 | - glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
| 60 | + glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @return \GeminiLabs\SiteReviews\Review|false |
| 65 | 65 | */ |
| 66 | 66 | function glsr_create_review( $reviewValues = array() ) { |
| 67 | - if( !is_array( $reviewValues )) { |
|
| 67 | + if( !is_array( $reviewValues ) ) { |
|
| 68 | 68 | $reviewValues = array(); |
| 69 | 69 | } |
| 70 | 70 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues ); |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | * @return \WP_Screen|object |
| 76 | 76 | */ |
| 77 | 77 | function glsr_current_screen() { |
| 78 | - if( function_exists( 'get_current_screen' )) { |
|
| 78 | + if( function_exists( 'get_current_screen' ) ) { |
|
| 79 | 79 | $screen = get_current_screen(); |
| 80 | 80 | } |
| 81 | - return empty( $screen ) |
|
| 81 | + return empty($screen) |
|
| 82 | 82 | ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
| 83 | 83 | : $screen; |
| 84 | 84 | } |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | function glsr_get_review( $post_id ) { |
| 127 | 127 | $post = null; |
| 128 | - if( is_numeric( $post_id )) { |
|
| 128 | + if( is_numeric( $post_id ) ) { |
|
| 129 | 129 | $post = get_post( $post_id ); |
| 130 | 130 | } |
| 131 | - if( !( $post instanceof WP_Post )) { |
|
| 131 | + if( !($post instanceof WP_Post) ) { |
|
| 132 | 132 | $post = new WP_Post( (object)[] ); |
| 133 | 133 | } |
| 134 | 134 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | 140 | function glsr_get_reviews( $args = array() ) { |
| 141 | - if( !is_array( $args )) { |
|
| 141 | + if( !is_array( $args ) ) { |
|
| 142 | 142 | $args = []; |
| 143 | 143 | } |
| 144 | 144 | return glsr( 'Database\ReviewManager' )->get( $args ); |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | function glsr_log() { |
| 151 | 151 | $args = func_get_args(); |
| 152 | - $context = isset( $args[1] ) |
|
| 152 | + $context = isset($args[1]) |
|
| 153 | 153 | ? $args[1] |
| 154 | 154 | : []; |
| 155 | 155 | $console = glsr( 'Modules\Console' ); |
| 156 | - return !empty( $args ) |
|
| 156 | + return !empty($args) |
|
| 157 | 157 | ? $console->log( 'debug', $args[0], $context ) |
| 158 | 158 | : $console; |
| 159 | 159 | } |
@@ -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' ), |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | 'after_widget' => '</div>', |
| 24 | 24 | 'before_title' => '<h3 class="glsr-'.$type.'-title">', |
| 25 | 25 | 'after_title' => '</h3>', |
| 26 | - ]); |
|
| 26 | + ] ); |
|
| 27 | 27 | $args = apply_filters( 'site-reviews/shortcode/args', $args, $type, $shortcodePartial ); |
| 28 | 28 | $instance = $this->normalize( $instance ); |
| 29 | 29 | $partial = glsr( Partial::class )->build( $shortcodePartial, $instance ); |
| 30 | - if( !empty( $instance['title'] )) { |
|
| 30 | + if( !empty($instance['title']) ) { |
|
| 31 | 31 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
| 32 | 32 | } |
| 33 | 33 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function normalize( $args ) |
| 92 | 92 | { |
| 93 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
| 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 ) )return; |
|
| 97 | 97 | $value = $this->$methodName( $value ); |
| 98 | 98 | }); |
| 99 | 99 | return $this->sanitize( $args ); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | protected function normalizeAssignedTo( $postId ) |
| 112 | 112 | { |
| 113 | 113 | if( $postId == 'parent_id' ) { |
| 114 | - $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ))); |
|
| 114 | + $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) ); |
|
| 115 | 115 | } |
| 116 | 116 | else if( $postId == 'post_id' ) { |
| 117 | 117 | $postId = intval( get_the_ID() ); |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function normalizeHide( $hide ) |
| 136 | 136 | { |
| 137 | - if( is_string( $hide )) { |
|
| 137 | + if( is_string( $hide ) ) { |
|
| 138 | 138 | $hide = explode( ',', $hide ); |
| 139 | 139 | } |
| 140 | 140 | $hideKeys = array_keys( $this->getHideOptions() ); |
| 141 | - return array_filter( array_map( 'trim', $hide ), function( $value ) use( $hideKeys ) { |
|
| 141 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use($hideKeys) { |
|
| 142 | 142 | return in_array( $value, $hideKeys ); |
| 143 | 143 | }); |
| 144 | 144 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | __( 'Terrible', 'site-reviews' ), |
| 167 | 167 | ]; |
| 168 | 168 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
| 169 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
| 169 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
| 170 | 170 | foreach( $defaults as $i => $label ) { |
| 171 | - if( empty( $labels[$i] ))continue; |
|
| 171 | + if( empty($labels[$i]) )continue; |
|
| 172 | 172 | $defaults[$i] = $labels[$i]; |
| 173 | 173 | } |
| 174 | 174 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |
@@ -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; |