@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct( WP_Post $post ) |
38 | 38 | { |
39 | - if( $post->post_type != Application::POST_TYPE )return; |
|
39 | + if( $post->post_type != Application::POST_TYPE ) { |
|
40 | + return; |
|
41 | + } |
|
40 | 42 | $this->content = $post->post_content; |
41 | 43 | $this->date = $post->post_date; |
42 | 44 | $this->ID = intval( $post->ID ); |
@@ -163,7 +165,9 @@ discard block |
||
163 | 165 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
164 | 166 | $this->modified = $this->isModified( $properties ); |
165 | 167 | array_walk( $properties, function( $value, $key ) { |
166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
168 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
169 | + return; |
|
170 | + } |
|
167 | 171 | $this->$key = maybe_unserialize( $value ); |
168 | 172 | }); |
169 | 173 | } |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | protected function setTermIds( WP_Post $post ) |
175 | 179 | { |
176 | 180 | $this->term_ids = []; |
177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
181 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
182 | + return; |
|
183 | + } |
|
178 | 184 | foreach( $terms as $term ) { |
179 | 185 | $this->term_ids[] = $term->term_id; |
180 | 186 | } |
@@ -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 ) { |
@@ -100,7 +104,8 @@ discard block |
||
100 | 104 | * @return array |
101 | 105 | * @filter display_post_states |
102 | 106 | */ |
103 | - public function filterPostStates( $postStates, WP_Post $post ) { |
|
107 | + public function filterPostStates( $postStates, WP_Post $post ) |
|
108 | + { |
|
104 | 109 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
105 | 110 | if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
106 | 111 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -148,7 +153,9 @@ discard block |
||
148 | 153 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
149 | 154 | unset( $postTypeColumns['cb'] ); |
150 | 155 | foreach( $postTypeColumns as $key => $value ) { |
151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
156 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
157 | + continue; |
|
158 | + } |
|
152 | 159 | $columns[$key] = $key; |
153 | 160 | } |
154 | 161 | return $columns; |
@@ -172,7 +179,9 @@ discard block |
||
172 | 179 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
173 | 180 | ]; |
174 | 181 | foreach( $strings as $search => $replace ) { |
175 | - if( strpos( $single, $search ) === false )continue; |
|
182 | + if( strpos( $single, $search ) === false ) { |
|
183 | + continue; |
|
184 | + } |
|
176 | 185 | $translation = $this->getTranslation([ |
177 | 186 | 'number' => $number, |
178 | 187 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -224,7 +233,9 @@ discard block |
||
224 | 233 | */ |
225 | 234 | public function saveBulkEditFields( $postId ) |
226 | 235 | { |
227 | - if( !current_user_can( 'edit_posts' ))return; |
|
236 | + if( !current_user_can( 'edit_posts' )) { |
|
237 | + return; |
|
238 | + } |
|
228 | 239 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
229 | 240 | if( $assignedTo && get_post( $assignedTo )) { |
230 | 241 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -237,7 +248,9 @@ discard block |
||
237 | 248 | */ |
238 | 249 | public function setQueryForColumn( WP_Query $query ) |
239 | 250 | { |
240 | - if( !$this->hasPermission( $query ))return; |
|
251 | + if( !$this->hasPermission( $query )) { |
|
252 | + return; |
|
253 | + } |
|
241 | 254 | $this->setMetaQuery( $query, [ |
242 | 255 | 'rating', 'review_type', |
243 | 256 | ]); |
@@ -250,7 +263,9 @@ discard block |
||
250 | 263 | */ |
251 | 264 | public function unapprove() |
252 | 265 | { |
253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
266 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
267 | + return; |
|
268 | + } |
|
254 | 269 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
255 | 270 | wp_update_post([ |
256 | 271 | 'ID' => $postId, |
@@ -310,7 +325,9 @@ discard block |
||
310 | 325 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
311 | 326 | { |
312 | 327 | foreach( $metaKeys as $key ) { |
313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
328 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
329 | + continue; |
|
330 | + } |
|
314 | 331 | $metaQuery = (array)$query->get( 'meta_query' ); |
315 | 332 | $metaQuery[] = [ |
316 | 333 | 'key' => $key, |
@@ -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' ); |
@@ -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() ); |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
43 | 43 | 'min' => $args['rating'], |
44 | 44 | ]); |
45 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
45 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
47 | 49 | $this->generateSchema(); |
48 | 50 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | */ |
64 | 66 | protected function buildPercentage() |
65 | 67 | { |
66 | - if( $this->isHidden( 'bars' ))return; |
|
68 | + if( $this->isHidden( 'bars' )) { |
|
69 | + return; |
|
70 | + } |
|
67 | 71 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
68 | 72 | $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
69 | 73 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
@@ -116,7 +120,9 @@ discard block |
||
116 | 120 | */ |
117 | 121 | protected function buildRating() |
118 | 122 | { |
119 | - if( $this->isHidden( 'rating' ))return; |
|
123 | + if( $this->isHidden( 'rating' )) { |
|
124 | + return; |
|
125 | + } |
|
120 | 126 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
121 | 127 | } |
122 | 128 | |
@@ -125,7 +131,9 @@ discard block |
||
125 | 131 | */ |
126 | 132 | protected function buildStars() |
127 | 133 | { |
128 | - if( $this->isHidden( 'stars' ))return; |
|
134 | + if( $this->isHidden( 'stars' )) { |
|
135 | + return; |
|
136 | + } |
|
129 | 137 | $stars = glsr_star_rating( $this->averageRating ); |
130 | 138 | return $this->wrap( 'stars', $stars ); |
131 | 139 | } |
@@ -135,7 +143,9 @@ discard block |
||
135 | 143 | */ |
136 | 144 | protected function buildText() |
137 | 145 | { |
138 | - if( $this->isHidden( 'summary' ))return; |
|
146 | + if( $this->isHidden( 'summary' )) { |
|
147 | + return; |
|
148 | + } |
|
139 | 149 | $count = intval( array_sum( $this->ratingCounts )); |
140 | 150 | if( empty( $this->args['text'] )) { |
141 | 151 | // @todo document this change |
@@ -160,7 +170,9 @@ discard block |
||
160 | 170 | */ |
161 | 171 | protected function generateSchema() |
162 | 172 | { |
163 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
173 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
174 | + return; |
|
175 | + } |
|
164 | 176 | glsr( Schema::class )->store( |
165 | 177 | glsr( Schema::class )->buildSummary( $this->args ) |
166 | 178 | ); |
@@ -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 | ]); |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | 'glsr_log', |
21 | 21 | 'glsr_star_rating', |
22 | 22 | ); |
23 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
23 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
24 | + return; |
|
25 | + } |
|
24 | 26 | add_filter( $hook, function() use( $hook, $args ) { |
25 | 27 | array_shift( $args ); // remove the fallback value |
26 | 28 | return call_user_func_array( $hook, $args ); |
@@ -30,7 +32,8 @@ discard block |
||
30 | 32 | /** |
31 | 33 | * @return mixed |
32 | 34 | */ |
33 | -function glsr( $alias = null ) { |
|
35 | +function glsr( $alias = null ) |
|
36 | +{ |
|
34 | 37 | $app = \GeminiLabs\SiteReviews\Application::load(); |
35 | 38 | return !empty( $alias ) |
36 | 39 | ? $app->make( $alias ) |
@@ -42,11 +45,14 @@ discard block |
||
42 | 45 | * @param $column string |
43 | 46 | * @return array |
44 | 47 | */ |
45 | -function glsr_array_column( array $array, $column ) { |
|
48 | +function glsr_array_column( array $array, $column ) |
|
49 | +{ |
|
46 | 50 | $result = array(); |
47 | 51 | foreach( $array as $subarray ) { |
48 | 52 | $subarray = (array)$subarray; |
49 | - if( !isset( $subarray[$column] ))continue; |
|
53 | + if( !isset( $subarray[$column] )) { |
|
54 | + continue; |
|
55 | + } |
|
50 | 56 | $result[] = $subarray[$column]; |
51 | 57 | } |
52 | 58 | return $result; |
@@ -55,7 +61,8 @@ discard block |
||
55 | 61 | /** |
56 | 62 | * @return void |
57 | 63 | */ |
58 | -function glsr_calculate_ratings() { |
|
64 | +function glsr_calculate_ratings() |
|
65 | +{ |
|
59 | 66 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
60 | 67 | glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
61 | 68 | } |
@@ -63,7 +70,8 @@ discard block |
||
63 | 70 | /** |
64 | 71 | * @return \GeminiLabs\SiteReviews\Review|false |
65 | 72 | */ |
66 | -function glsr_create_review( $reviewValues = array() ) { |
|
73 | +function glsr_create_review( $reviewValues = array() ) |
|
74 | +{ |
|
67 | 75 | if( !is_array( $reviewValues )) { |
68 | 76 | $reviewValues = array(); |
69 | 77 | } |
@@ -74,7 +82,8 @@ discard block |
||
74 | 82 | /** |
75 | 83 | * @return \WP_Screen|object |
76 | 84 | */ |
77 | -function glsr_current_screen() { |
|
85 | +function glsr_current_screen() |
|
86 | +{ |
|
78 | 87 | if( function_exists( 'get_current_screen' )) { |
79 | 88 | $screen = get_current_screen(); |
80 | 89 | } |
@@ -87,7 +96,8 @@ discard block |
||
87 | 96 | * @param mixed ...$vars |
88 | 97 | * @return void |
89 | 98 | */ |
90 | -function glsr_debug( ...$vars ) { |
|
99 | +function glsr_debug( ...$vars ) |
|
100 | +{ |
|
91 | 101 | if( count( $vars ) == 1 ) { |
92 | 102 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
93 | 103 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -106,7 +116,8 @@ discard block |
||
106 | 116 | * @param mixed $fallback |
107 | 117 | * @return string|array |
108 | 118 | */ |
109 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
119 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
120 | +{ |
|
110 | 121 | return is_string( $path ) |
111 | 122 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
112 | 123 | : $fallback; |
@@ -115,7 +126,8 @@ discard block |
||
115 | 126 | /** |
116 | 127 | * @return array |
117 | 128 | */ |
118 | -function glsr_get_options() { |
|
129 | +function glsr_get_options() |
|
130 | +{ |
|
119 | 131 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
120 | 132 | } |
121 | 133 | |
@@ -123,7 +135,8 @@ discard block |
||
123 | 135 | * @param int $post_id |
124 | 136 | * @return \GeminiLabs\SiteReviews\Review |
125 | 137 | */ |
126 | -function glsr_get_review( $post_id ) { |
|
138 | +function glsr_get_review( $post_id ) |
|
139 | +{ |
|
127 | 140 | $post = null; |
128 | 141 | if( is_numeric( $post_id )) { |
129 | 142 | $post = get_post( $post_id ); |
@@ -137,7 +150,8 @@ discard block |
||
137 | 150 | /** |
138 | 151 | * @return array |
139 | 152 | */ |
140 | -function glsr_get_reviews( $args = array() ) { |
|
153 | +function glsr_get_reviews( $args = array() ) |
|
154 | +{ |
|
141 | 155 | if( !is_array( $args )) { |
142 | 156 | $args = []; |
143 | 157 | } |
@@ -147,7 +161,8 @@ discard block |
||
147 | 161 | /** |
148 | 162 | * @return \GeminiLabs\SiteReviews\Modules\Console |
149 | 163 | */ |
150 | -function glsr_log() { |
|
164 | +function glsr_log() |
|
165 | +{ |
|
151 | 166 | $args = func_get_args(); |
152 | 167 | $context = isset( $args[1] ) |
153 | 168 | ? $args[1] |
@@ -161,6 +176,7 @@ discard block |
||
161 | 176 | /** |
162 | 177 | * @return string |
163 | 178 | */ |
164 | -function glsr_star_rating( $rating ) { |
|
179 | +function glsr_star_rating( $rating ) |
|
180 | +{ |
|
165 | 181 | return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
166 | 182 | } |
@@ -86,7 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function buildRecaptcha() |
88 | 88 | { |
89 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
89 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
90 | + return; |
|
91 | + } |
|
90 | 92 | return glsr( Builder::class )->div([ |
91 | 93 | 'class' => 'glsr-recaptcha-holder', |
92 | 94 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
@@ -145,7 +147,9 @@ discard block |
||
145 | 147 | }, $hiddenFields ); |
146 | 148 | foreach( $fields as $field ) { |
147 | 149 | $index = array_search( $field->field['path'], $paths ); |
148 | - if( $index === false )continue; |
|
150 | + if( $index === false ) { |
|
151 | + continue; |
|
152 | + } |
|
149 | 153 | unset( $hiddenFields[$index] ); |
150 | 154 | } |
151 | 155 | return array_merge( $hiddenFields, $fields ); |
@@ -168,7 +172,9 @@ discard block |
||
168 | 172 | */ |
169 | 173 | protected function getRegisterText() |
170 | 174 | { |
171 | - if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' ))return; |
|
175 | + if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' )) { |
|
176 | + return; |
|
177 | + } |
|
172 | 178 | $registerLink = glsr( Builder::class )->a([ |
173 | 179 | 'href' => wp_registration_url(), |
174 | 180 | 'text' => __( 'register', 'site-reviews' ), |
@@ -229,7 +235,9 @@ discard block |
||
229 | 235 | */ |
230 | 236 | protected function normalizeFieldId( Field &$field ) |
231 | 237 | { |
232 | - if( empty( $this->args['id'] ) || empty( $field->field['id'] ))return; |
|
238 | + if( empty( $this->args['id'] ) || empty( $field->field['id'] )) { |
|
239 | + return; |
|
240 | + } |
|
233 | 241 | $field->field['id'].= '-'.$this->args['id']; |
234 | 242 | } |
235 | 243 | |
@@ -249,7 +257,9 @@ discard block |
||
249 | 257 | */ |
250 | 258 | protected function normalizeFieldErrors( Field &$field ) |
251 | 259 | { |
252 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
260 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
261 | + return; |
|
262 | + } |
|
253 | 263 | $field->field['errors'] = $this->errors[$field->field['path']]; |
254 | 264 | } |
255 | 265 | |
@@ -258,7 +268,9 @@ discard block |
||
258 | 268 | */ |
259 | 269 | protected function normalizeFieldRequired( Field &$field ) |
260 | 270 | { |
261 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
271 | + if( !in_array( $field->field['path'], $this->required )) { |
|
272 | + return; |
|
273 | + } |
|
262 | 274 | $field->field['required'] = true; |
263 | 275 | } |
264 | 276 | |
@@ -269,7 +281,9 @@ discard block |
||
269 | 281 | { |
270 | 282 | $normalizedFields = []; |
271 | 283 | foreach( $fields as $field ) { |
272 | - if( in_array( $field->field['path'], $this->args['hide'] ))continue; |
|
284 | + if( in_array( $field->field['path'], $this->args['hide'] )) { |
|
285 | + continue; |
|
286 | + } |
|
273 | 287 | $field->field['is_public'] = true; |
274 | 288 | $this->normalizeFieldClass( $field ); |
275 | 289 | $this->normalizeFieldErrors( $field ); |
@@ -286,7 +300,9 @@ discard block |
||
286 | 300 | */ |
287 | 301 | protected function normalizeFieldValue( Field &$field ) |
288 | 302 | { |
289 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
303 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
304 | + return; |
|
305 | + } |
|
290 | 306 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
291 | 307 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
292 | 308 | } |
@@ -163,7 +163,9 @@ |
||
163 | 163 | public function logOnce() |
164 | 164 | { |
165 | 165 | $single = glsr( Session::class )->get( 'glsr_log_once', null, true ); |
166 | - if( !is_array( $single ))return; |
|
166 | + if( !is_array( $single )) { |
|
167 | + return; |
|
168 | + } |
|
167 | 169 | foreach( $single as $message => $debug ) { |
168 | 170 | if( !empty( $debug )) { |
169 | 171 | $message.= PHP_EOL.print_r( $debug, 1 ); |