@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php defined( 'WPINC' ) || die; |
2 | 2 | |
3 | -include trailingslashit(__DIR__).'header.php'; |
|
4 | -include trailingslashit(__DIR__).'body.php'; |
|
5 | -include trailingslashit(__DIR__).'footer.php'; |
|
3 | +include trailingslashit( __DIR__ ).'header.php'; |
|
4 | +include trailingslashit( __DIR__ ).'body.php'; |
|
5 | +include trailingslashit( __DIR__ ).'footer.php'; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->message = $this->buildHtmlMessage( $email ); |
44 | 44 | $this->subject = $email['subject']; |
45 | 45 | $this->to = $email['to']; |
46 | - add_action( 'phpmailer_init', [ $this, 'buildPlainTextMessage'] ); |
|
46 | + add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] ); |
|
47 | 47 | return $this; |
48 | 48 | } |
49 | 49 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function buildPlainTextMessage( $phpmailer ) |
85 | 85 | { |
86 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
86 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
87 | 87 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
88 | 88 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
89 | 89 | } |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | 'from', |
100 | 100 | 'reply-to', |
101 | 101 | ]; |
102 | - $headers = array_intersect_key( $email, array_flip( $allowed )); |
|
102 | + $headers = array_intersect_key( $email, array_flip( $allowed ) ); |
|
103 | 103 | $headers = array_filter( $headers ); |
104 | 104 | foreach( $headers as $key => $value ) { |
105 | - unset( $headers[ $key ] ); |
|
105 | + unset($headers[$key]); |
|
106 | 106 | $headers[] = "{$key}: {$value}"; |
107 | 107 | } |
108 | 108 | $headers[] = 'Content-Type: text/html'; |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function buildHtmlMessage( $email ) |
116 | 116 | { |
117 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
118 | - if( !empty( $template )) { |
|
117 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
118 | + if( !empty($template) ) { |
|
119 | 119 | $message = glsr( Template::class )->interpolate( $template, $email['template-tags'] ); |
120 | 120 | } |
121 | 121 | else if( $email['template'] ) { |
122 | 122 | $message = glsr( Template::class )->build( 'templates/'.$email['template'], [ |
123 | 123 | 'context' => $email['template-tags'], |
124 | - ]); |
|
124 | + ] ); |
|
125 | 125 | } |
126 | - if( !isset( $message )) { |
|
126 | + if( !isset($message) ) { |
|
127 | 127 | $message = $email['message']; |
128 | 128 | } |
129 | 129 | $message = $email['before'].$message.$email['after']; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $message = str_replace( ']]>', ']]>', $message ); |
135 | 135 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
136 | 136 | 'context' => ['message' => $message], |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
139 | 139 | } |
140 | 140 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'to' => '', |
161 | 161 | ]; |
162 | 162 | $email = shortcode_atts( $defaults, $email ); |
163 | - if( empty( $email['reply-to'] )) { |
|
163 | + if( empty($email['reply-to']) ) { |
|
164 | 164 | $email['reply-to'] = $email['from']; |
165 | 165 | } |
166 | 166 | return apply_filters( 'site-reviews/email/compose', $email, $this ); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | 'post_type' => Application::POST_TYPE, |
36 | 36 | ]; |
37 | 37 | if( $review['review_type'] == 'local' && ( |
38 | - glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted )) { |
|
38 | + glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted ) ) { |
|
39 | 39 | $post['post_status'] = 'pending'; |
40 | 40 | } |
41 | 41 | $postId = wp_insert_post( $post, true ); |
42 | - if( is_wp_error( $postId )) { |
|
42 | + if( is_wp_error( $postId ) ) { |
|
43 | 43 | glsr_log()->error( $postId->get_error_message() ); |
44 | 44 | return false; |
45 | 45 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function deleteReview( $metaReviewId ) |
59 | 59 | { |
60 | - if( $postId = $this->getReviewPostId( $metaReviewId )) { |
|
60 | + if( $postId = $this->getReviewPostId( $metaReviewId ) ) { |
|
61 | 61 | wp_delete_post( $postId, true ); |
62 | 62 | } |
63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getReview( $post ) |
70 | 70 | { |
71 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
71 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
72 | 72 | $review = $this->getReviewMeta( $post->ID ); |
73 | 73 | $modified = $this->isReviewModified( $post, $review ); |
74 | 74 | $review->content = $post->post_content; |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | { |
91 | 91 | $metaKey = $this->normalizeMetaKey( $metaKey ); |
92 | 92 | if( !$metaKey ) { |
93 | - return (array) wp_count_posts( Application::POST_TYPE ); |
|
93 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
94 | 94 | } |
95 | 95 | $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
96 | 96 | if( !$metaValue ) { |
97 | 97 | return $counts; |
98 | 98 | } |
99 | - return isset( $counts[$metaValue] ) |
|
99 | + return isset($counts[$metaValue]) |
|
100 | 100 | ? $counts[$metaValue] |
101 | 101 | : 0; |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | public function getReviewMeta( $postId ) |
118 | 118 | { |
119 | 119 | $meta = get_post_type( $postId ) == Application::POST_TYPE |
120 | - ? array_map( 'array_shift', (array) get_post_meta( $postId )) |
|
120 | + ? array_map( 'array_shift', (array)get_post_meta( $postId ) ) |
|
121 | 121 | : []; |
122 | - return (object) $this->normalizeMeta( array_filter( $meta, 'strlen' )); |
|
122 | + return (object)$this->normalizeMeta( array_filter( $meta, 'strlen' ) ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $paged = glsr( QueryBuilder::class )->getPaged( |
149 | 149 | wp_validate_boolean( $args['pagination'] ) |
150 | 150 | ); |
151 | - $reviews = new WP_Query([ |
|
151 | + $reviews = new WP_Query( [ |
|
152 | 152 | 'meta_key' => 'pinned', |
153 | 153 | 'meta_query' => $metaQuery, |
154 | 154 | 'offset' => $args['offset'], |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | 'post_type' => Application::POST_TYPE, |
162 | 162 | 'posts_per_page' => $args['count'] ? $args['count'] : -1, |
163 | 163 | 'tax_query' => $taxQuery, |
164 | - ]); |
|
165 | - return (object) [ |
|
164 | + ] ); |
|
165 | + return (object)[ |
|
166 | 166 | 'results' => array_map( [$this, 'getReview'], $reviews->posts ), |
167 | 167 | 'max_num_pages' => $reviews->max_num_pages, |
168 | 168 | ]; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | public function getReviewsMeta( $keys, $status = 'publish' ) |
177 | 177 | { |
178 | 178 | $keys = array_map( [$this, 'normalizeMetaKey'], (array)$keys ); |
179 | - if( $status == 'all' || empty( $status )) { |
|
179 | + if( $status == 'all' || empty($status) ) { |
|
180 | 180 | $status = get_post_stati( ['exclude_from_search' => false] ); |
181 | 181 | } |
182 | 182 | return glsr( SqlQueries::class )->getReviewsMeta( $keys, $status ); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | 'fields' => 'id=>name', |
193 | 193 | 'hide_empty' => false, |
194 | 194 | 'taxonomy' => Application::TAXONOMY, |
195 | - ]); |
|
196 | - unset( $args['count'] ); //we don't want a term count |
|
195 | + ] ); |
|
196 | + unset($args['count']); //we don't want a term count |
|
197 | 197 | $terms = get_terms( $args ); |
198 | - if( is_wp_error( $terms )) { |
|
198 | + if( is_wp_error( $terms ) ) { |
|
199 | 199 | glsr_log()->error( $terms->get_error_message() ); |
200 | 200 | return []; |
201 | 201 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function normalizeMeta( array $meta ) |
209 | 209 | { |
210 | - if( empty( $meta )) { |
|
210 | + if( empty($meta) ) { |
|
211 | 211 | return []; |
212 | 212 | } |
213 | 213 | $defaults = wp_parse_args( $meta, [ |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | 'date' => '', |
216 | 216 | 'review_id' => '', |
217 | 217 | 'review_type' => '', |
218 | - ]); |
|
218 | + ] ); |
|
219 | 219 | return glsr( CreateReviewDefaults::class )->merge( $defaults, true ); |
220 | 220 | } |
221 | 221 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | public function normalizeMetaKey( $metaKey ) |
227 | 227 | { |
228 | 228 | $metaKey = strtolower( $metaKey ); |
229 | - if( in_array( $metaKey, ['id', 'type'] )) { |
|
229 | + if( in_array( $metaKey, ['id', 'type'] ) ) { |
|
230 | 230 | $metaKey = 'review_'.$metaKey; |
231 | 231 | } |
232 | 232 | return $metaKey; |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | public function normalizeTerms( $termIds ) |
240 | 240 | { |
241 | 241 | $terms = []; |
242 | - $termIds = array_map( 'trim', explode( ',', $termIds )); |
|
242 | + $termIds = array_map( 'trim', explode( ',', $termIds ) ); |
|
243 | 243 | foreach( $termIds as $termId ) { |
244 | 244 | $term = term_exists( $termId, Application::TAXONOMY ); |
245 | - if( !isset( $term['term_id'] ))continue; |
|
245 | + if( !isset($term['term_id']) )continue; |
|
246 | 246 | $terms[] = intval( $term['term_id'] ); |
247 | 247 | } |
248 | 248 | return $terms; |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | public function revertReview( $postId ) |
256 | 256 | { |
257 | 257 | $post = get_post( $postId ); |
258 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
258 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
259 | 259 | delete_post_meta( $post->ID, '_edit_last' ); |
260 | - $result = wp_update_post([ |
|
260 | + $result = wp_update_post( [ |
|
261 | 261 | 'ID' => $post->ID, |
262 | 262 | 'post_content' => get_post_meta( $post->ID, 'content', true ), |
263 | 263 | 'post_date' => get_post_meta( $post->ID, 'date', true ), |
264 | 264 | 'post_title' => get_post_meta( $post->ID, 'title', true ), |
265 | - ]); |
|
266 | - if( is_wp_error( $result )) { |
|
265 | + ] ); |
|
266 | + if( is_wp_error( $result ) ) { |
|
267 | 267 | glsr_log()->error( $result->get_error_message() ); |
268 | 268 | } |
269 | 269 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | 'post_status' => 'publish', |
279 | 279 | 'post_type' => 'any', |
280 | 280 | ]; |
281 | - if( is_numeric( $searchTerm )) { |
|
281 | + if( is_numeric( $searchTerm ) ) { |
|
282 | 282 | $args['post__in'] = [$searchTerm]; |
283 | 283 | } |
284 | 284 | else { |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | ob_start(); |
298 | 298 | glsr()->render( 'partials/editor/search-result', [ |
299 | 299 | 'ID' => get_the_ID(), |
300 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
300 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
301 | 301 | 'title' => esc_attr( get_the_title() ), |
302 | - ]); |
|
302 | + ] ); |
|
303 | 303 | $results .= ob_get_clean(); |
304 | 304 | } |
305 | 305 | wp_reset_postdata(); |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | public function setReviewMeta( $postId, $termIds ) |
315 | 315 | { |
316 | 316 | $terms = $this->normalizeTerms( $termIds ); |
317 | - if( empty( $terms ))return; |
|
317 | + if( empty($terms) )return; |
|
318 | 318 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
319 | - if( is_wp_error( $result )) { |
|
319 | + if( is_wp_error( $result ) ) { |
|
320 | 320 | glsr_log()->error( $result->get_error_message() ); |
321 | 321 | } |
322 | 322 | } |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function renderAssignedToMetabox( WP_Post $post ) |
149 | 149 | { |
150 | - if( !$this->isReviewPostType( $post ))return; |
|
151 | - $assignedTo = intval( get_post_meta( $post->ID, 'assigned_to', true )); |
|
150 | + if( !$this->isReviewPostType( $post ) )return; |
|
151 | + $assignedTo = intval( get_post_meta( $post->ID, 'assigned_to', true ) ); |
|
152 | 152 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
153 | 153 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
154 | 154 | 'id' => $assignedTo, |
155 | 155 | 'template' => $this->buildAssignedToTemplate( $assignedTo ), |
156 | - ]); |
|
156 | + ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function renderDetailsMetaBox( WP_Post $post ) |
164 | 164 | { |
165 | - if( !$this->isReviewPostType( $post ))return; |
|
165 | + if( !$this->isReviewPostType( $post ) )return; |
|
166 | 166 | $review = glsr( Database::class )->getReview( $post ); |
167 | 167 | glsr()->render( 'partials/editor/metabox-details', [ |
168 | 168 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
169 | 169 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
170 | - ]); |
|
170 | + ] ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function renderPinnedInPublishMetaBox() |
178 | 178 | { |
179 | - if( !$this->isReviewPostType( get_post() ))return; |
|
179 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
180 | 180 | glsr()->render( 'partials/editor/pinned', [ |
181 | - 'pinned' => boolval( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
182 | - ]); |
|
181 | + 'pinned' => boolval( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
182 | + ] ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function renderResponseMetaBox( WP_Post $post ) |
190 | 190 | { |
191 | - if( !$this->isReviewPostType( $post ))return; |
|
191 | + if( !$this->isReviewPostType( $post ) )return; |
|
192 | 192 | wp_nonce_field( 'response', '_nonce-response', false ); |
193 | 193 | glsr()->render( 'partials/editor/metabox-response', [ |
194 | 194 | 'response' => glsr( Database::class )->getReview( $post )->response, |
195 | - ]); |
|
195 | + ] ); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function renderTaxonomyMetabox( WP_Post $post ) |
204 | 204 | { |
205 | - if( !$this->isReviewPostType( $post ))return; |
|
205 | + if( !$this->isReviewPostType( $post ) )return; |
|
206 | 206 | glsr()->render( 'partials/editor/metabox-categories', [ |
207 | 207 | 'post' => $post, |
208 | 208 | 'tax_name' => Application::TAXONOMY, |
209 | 209 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
210 | - ]); |
|
210 | + ] ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function revertReview() |
219 | 219 | { |
220 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
220 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
221 | 221 | glsr( Database::class )->revertReview( $postId ); |
222 | 222 | $this->redirect( $postId, 52 ); |
223 | 223 | } |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | protected function buildAssignedToTemplate( $assignedTo ) |
241 | 241 | { |
242 | 242 | $assignedPost = get_post( $assignedTo ); |
243 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
243 | + if( !($assignedPost instanceof WP_Post) )return; |
|
244 | 244 | return glsr( Html::class )->buildTemplate( 'edit/assigned-post', [ |
245 | 245 | 'context' => [ |
246 | 246 | 'url' => (string)get_permalink( $assignedPost ), |
247 | 247 | 'title' => get_the_title( $assignedPost ), |
248 | 248 | ], |
249 | - ]); |
|
249 | + ] ); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | 'class' => 'button button-large', |
268 | 268 | 'href' => $revertUrl, |
269 | 269 | 'id' => 'revert', |
270 | - ]); |
|
270 | + ] ); |
|
271 | 271 | } |
272 | 272 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
273 | 273 | 'class' => 'button button-large', |
274 | 274 | 'disabled' => true, |
275 | 275 | 'id' => 'revert', |
276 | - ]); |
|
276 | + ] ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | protected function getReviewType( $review ) |
284 | 284 | { |
285 | 285 | $reviewType = $review->review_type; |
286 | - if( !empty( $review->url )) { |
|
286 | + if( !empty($review->url) ) { |
|
287 | 287 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
288 | 288 | 'href' => $review->url, |
289 | 289 | 'target' => '_blank', |
290 | - ]); |
|
290 | + ] ); |
|
291 | 291 | } |
292 | 292 | return in_array( $reviewType, glsr()->reviewTypes ) |
293 | 293 | ? glsr()->reviewTypes[$reviewType] |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function normalizeDetailsMetaBox( $review ) |
311 | 311 | { |
312 | - $reviewer = empty( $review->user_id ) |
|
312 | + $reviewer = empty($review->user_id) |
|
313 | 313 | ? __( 'Unregistered user', 'site-reviews' ) |
314 | 314 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
315 | 315 | 'href' => get_author_posts_url( $review->user_id ), |
316 | - ]); |
|
317 | - $email = empty( $review->email ) |
|
316 | + ] ); |
|
317 | + $email = empty($review->email) |
|
318 | 318 | ? '—' |
319 | 319 | : glsr( Builder::class )->a( $review->email, [ |
320 | 320 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
321 | - ]); |
|
321 | + ] ); |
|
322 | 322 | $metabox = [ |
323 | 323 | __( 'Rating', 'site-reviews' ) => glsr( Html::class )->renderPartial( 'star-rating', ['rating' => $review->rating] ), |
324 | 324 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $redirectUri = $hasReferer |
347 | 347 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
348 | 348 | : get_edit_post_link( $postId ); |
349 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
349 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
350 | 350 | exit; |
351 | 351 | } |
352 | 352 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | defined( 'WP_UNINSTALL_PLUGIN' ) || die; |
4 | 4 | |
5 | 5 | require_once __DIR__.'/site-reviews.php'; |
6 | -if( !GL_Plugin_Check_v1::isValid( array( 'wordpress' => '4.7.0' )))return; |
|
6 | +if( !GL_Plugin_Check_v1::isValid( array( 'wordpress' => '4.7.0' ) ) )return; |
|
7 | 7 | |
8 | 8 | delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey() ); |
9 | 9 | delete_option( 'widget_'.glsr()->id.'_site-reviews' ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | 'is_multi' => false, |
24 | 24 | 'is_valid' => true, |
25 | 25 | 'path' => '', |
26 | - ]); |
|
26 | + ] ); |
|
27 | 27 | $this->normalize(); |
28 | 28 | } |
29 | 29 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | return glsr( Template::class )->build( 'partials/settings/form-table-row', [ |
41 | 41 | 'context' => [ |
42 | 42 | 'class' => $this->getFieldClass(), |
43 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
43 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
44 | 44 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
45 | 45 | ], |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | 'context' => [ |
64 | 64 | 'class' => $this->getFieldClass(), |
65 | 65 | 'depends_on' => $this->getFieldDependsOn(), |
66 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
66 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
67 | 67 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
68 | 68 | 'legend' => $this->field['legend'], |
69 | 69 | ], |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function getFieldDefault() |
87 | 87 | { |
88 | - return isset( $this->field['default'] ) |
|
88 | + return isset($this->field['default']) |
|
89 | 89 | ? $this->field['default'] |
90 | 90 | : ''; |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function getFieldDependsOn() |
97 | 97 | { |
98 | - return !empty( $this->field['depends_on'] ) |
|
98 | + return !empty($this->field['depends_on']) |
|
99 | 99 | ? $this->field['depends_on'] |
100 | 100 | : ''; |
101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $path, |
112 | 112 | glsr( Helper::class )->getPathValue( $path, glsr()->defaults ) |
113 | 113 | ); |
114 | - if( is_array( $expectedValue )) { |
|
114 | + if( is_array( $expectedValue ) ) { |
|
115 | 115 | return !in_array( $optionValue, $expectedValue ); |
116 | 116 | } |
117 | 117 | return $optionValue != $expectedValue; |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | 'label', 'name', 'type', |
129 | 129 | ]; |
130 | 130 | foreach( $requiredValues as $value ) { |
131 | - if( isset( $this->field[$value] ))continue; |
|
131 | + if( isset($this->field[$value]) )continue; |
|
132 | 132 | $missingValues[] = $value; |
133 | 133 | $isValid = $this->field['is_valid'] = false; |
134 | 134 | } |
135 | - if( !empty( $missingValues )) { |
|
135 | + if( !empty($missingValues) ) { |
|
136 | 136 | glsr_log() |
137 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
137 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
138 | 138 | ->info( $this->field ); |
139 | 139 | } |
140 | 140 | return $isValid; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $field = $this->field; |
150 | 150 | foreach( $field as $key => $value ) { |
151 | 151 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
152 | - if( !method_exists( $this, $methodName ))continue; |
|
152 | + if( !method_exists( $this, $methodName ) )continue; |
|
153 | 153 | $this->$methodName(); |
154 | 154 | } |
155 | 155 | $this->normalizeFieldId(); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function normalizeDependsOn() |
164 | 164 | { |
165 | - if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return; |
|
165 | + if( empty($this->field['depends_on']) || !is_array( $this->field['depends_on'] ) )return; |
|
166 | 166 | $path = key( $this->field['depends_on'] ); |
167 | 167 | $value = $this->field['depends_on'][$path]; |
168 | - $this->field['depends_on'] = json_encode([ |
|
168 | + $this->field['depends_on'] = json_encode( [ |
|
169 | 169 | 'name' => glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ), |
170 | 170 | 'value' => $value, |
171 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
171 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
172 | 172 | $this->field['is_hidden'] = $this->isFieldHidden( $path, $value ); |
173 | 173 | } |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function normalizeFieldId() |
179 | 179 | { |
180 | - if( isset( $this->field['id'] ))return; |
|
180 | + if( isset($this->field['id']) )return; |
|
181 | 181 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
182 | 182 | } |
183 | 183 | |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | protected function normalizeFieldType() |
188 | 188 | { |
189 | 189 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], 'Modules\Html\Fields' ); |
190 | - if( class_exists( $className )) { |
|
190 | + if( class_exists( $className ) ) { |
|
191 | 191 | $this->field = array_merge( $this->field, glsr( $className )->defaults() ); |
192 | 192 | } |
193 | - if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES )) { |
|
193 | + if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES ) ) { |
|
194 | 194 | $this->field['is_multi'] = true; |
195 | 195 | } |
196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function normalizeFieldValue() |
202 | 202 | { |
203 | - if( isset( $this->field['value'] ))return; |
|
203 | + if( isset($this->field['value']) )return; |
|
204 | 204 | $this->field['value'] = glsr( OptionManager::class )->get( |
205 | 205 | $this->field['path'], |
206 | 206 | $this->getFieldDefault() |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | protected function normalizeLabel() |
214 | 214 | { |
215 | 215 | $this->field['legend'] = $this->field['label']; |
216 | - unset( $this->field['label'] ); |
|
216 | + unset($this->field['label']); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __call( $method, $args ) |
61 | 61 | { |
62 | - $instance = new static( $this->globals ); |
|
62 | + $instance = new static($this->globals); |
|
63 | 63 | $instance->setTagFromMethod( $method ); |
64 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
64 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
65 | 65 | $tags = array_merge( static::TAGS_FORM, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
66 | 66 | $generatedTag = in_array( $instance->tag, $tags ) |
67 | 67 | ? $instance->buildTag() |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | 'render' => 'is_bool', |
86 | 86 | 'tag' => 'is_string', |
87 | 87 | ]; |
88 | - if( !isset( $properties[$property] ) |
|
89 | - || empty( array_filter( [$value], $properties[$property] )) |
|
88 | + if( !isset($properties[$property]) |
|
89 | + || empty(array_filter( [$value], $properties[$property] )) |
|
90 | 90 | )return; |
91 | 91 | $this->$property = $value; |
92 | 92 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function getOpeningTag() |
106 | 106 | { |
107 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
107 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
108 | 108 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
109 | 109 | } |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function buildCustomField() |
115 | 115 | { |
116 | 116 | $className = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' ); |
117 | - if( !class_exists( $className )) { |
|
117 | + if( !class_exists( $className ) ) { |
|
118 | 118 | glsr_log()->error( 'Field missing: '.$className ); |
119 | 119 | return; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function buildDefaultTag( $text = '' ) |
128 | 128 | { |
129 | - if( empty( $text )) { |
|
129 | + if( empty($text) ) { |
|
130 | 130 | $text = $this->args['text']; |
131 | 131 | } |
132 | 132 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function buildFieldDescription() |
139 | 139 | { |
140 | - if( empty( $this->args['description'] ))return; |
|
141 | - if( !empty( $this->globals['is_widget'] )) { |
|
140 | + if( empty($this->args['description']) )return; |
|
141 | + if( !empty($this->globals['is_widget']) ) { |
|
142 | 142 | return $this->small( $this->args['description'] ); |
143 | 143 | } |
144 | 144 | return $this->p( $this->args['description'], ['class' => 'description'] ); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function buildFormInput() |
151 | 151 | { |
152 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
152 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
153 | 153 | return $this->buildFormLabel().$this->getOpeningTag(); |
154 | 154 | } |
155 | - return empty( $this->args['options'] ) |
|
155 | + return empty($this->args['options']) |
|
156 | 156 | ? $this->buildFormInputChoice() |
157 | 157 | : $this->buildFormInputMultiChoice(); |
158 | 158 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | protected function buildFormInputMultiChoice() |
172 | 172 | { |
173 | 173 | if( $this->args['type'] == 'checkbox' ) { |
174 | - $this->args['name'].= '[]'; |
|
174 | + $this->args['name'] .= '[]'; |
|
175 | 175 | } |
176 | 176 | $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
177 | 177 | return $carry.$this->li( $this->{$this->args['type']}([ |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | 'name' => $this->args['name'], |
180 | 180 | 'text' => $this->args['options'][$key], |
181 | 181 | 'value' => $key, |
182 | - ])); |
|
182 | + ]) ); |
|
183 | 183 | }); |
184 | 184 | return $this->ul( $options, [ |
185 | 185 | 'class' => $this->args['class'], |
186 | 186 | 'id' => $this->args['id'], |
187 | - ]); |
|
187 | + ] ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function buildFormLabel() |
194 | 194 | { |
195 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
196 | - return $this->label([ |
|
195 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
196 | + return $this->label( [ |
|
197 | 197 | 'for' => $this->args['id'], |
198 | 198 | 'text' => $this->args['label'], |
199 | - ]); |
|
199 | + ] ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | protected function buildFormSelectOptions() |
214 | 214 | { |
215 | 215 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
216 | - return $carry.$this->option([ |
|
216 | + return $carry.$this->option( [ |
|
217 | 217 | 'selected' => $this->args['value'] == $key, |
218 | 218 | 'text' => $this->args['options'][$key], |
219 | 219 | 'value' => $key, |
220 | - ]); |
|
220 | + ] ); |
|
221 | 221 | }); |
222 | 222 | } |
223 | 223 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function buildTag() |
236 | 236 | { |
237 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
237 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
238 | 238 | return $this->buildDefaultTag(); |
239 | 239 | } |
240 | 240 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function normalize( ...$params ) |
248 | 248 | { |
249 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
249 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
250 | 250 | $this->setNameOrTextAttributeForTag( $params[0] ); |
251 | 251 | } |
252 | - if( is_array( $params[0] )) { |
|
252 | + if( is_array( $params[0] ) ) { |
|
253 | 253 | $this->args += $params[0]; |
254 | 254 | } |
255 | - else if( is_array( $params[1] )) { |
|
255 | + else if( is_array( $params[1] ) ) { |
|
256 | 256 | $this->args += $params[1]; |
257 | 257 | } |
258 | 258 | $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | protected function setTagFromMethod( $method ) |
278 | 278 | { |
279 | 279 | $this->tag = strtolower( $method ); |
280 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
280 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
281 | 281 | $this->args['type'] = $this->tag; |
282 | 282 | $this->tag = 'input'; |
283 | 283 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $translations = $this->getTranslations(); |
32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
36 | 36 | : ''; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function entries() |
45 | 45 | { |
46 | - if( !isset( $this->entries )) { |
|
46 | + if( !isset($this->entries) ) { |
|
47 | 47 | try { |
48 | 48 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
49 | 49 | $entries = $this->normalize( Parser::parseFile( $potFile )->getEntries() ); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
78 | 78 | { |
79 | - if( !is_array( $entries )) { |
|
79 | + if( !is_array( $entries ) ) { |
|
80 | 80 | $entries = $this->results; |
81 | 81 | } |
82 | - if( !is_array( $filterWith )) { |
|
82 | + if( !is_array( $filterWith ) ) { |
|
83 | 83 | $filterWith = $this->getTranslations(); |
84 | 84 | } |
85 | - $keys = array_flip( array_column( $filterWith, 'id' )); |
|
85 | + $keys = array_flip( array_column( $filterWith, 'id' ) ); |
|
86 | 86 | $this->results = $intersect |
87 | 87 | ? array_intersect_key( $entries, $keys ) |
88 | 88 | : array_diff_key( $entries, $keys ); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | return $this->translate( $translation, $domain, [ |
101 | 101 | 'single' => $text, |
102 | - ]); |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | return $this->translate( $translation, $domain, [ |
115 | 115 | 'context' => $context, |
116 | 116 | 'single' => $text, |
117 | - ]); |
|
117 | + ] ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'number' => $number, |
132 | 132 | 'plural' => $plural, |
133 | 133 | 'single' => $single, |
134 | - ]); |
|
134 | + ] ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'number' => $number, |
151 | 151 | 'plural' => $plural, |
152 | 152 | 'single' => $single, |
153 | - ]); |
|
153 | + ] ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | public function render( $template, array $entry ) |
161 | 161 | { |
162 | 162 | $data = array_combine( |
163 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
163 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
164 | 164 | $entry |
165 | 165 | ); |
166 | 166 | ob_start(); |
167 | 167 | glsr( Html::class )->renderTemplate( 'partials/translations/'.$template, [ |
168 | 168 | 'context' => $data, |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | return ob_get_clean(); |
171 | 171 | } |
172 | 172 | |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
200 | 200 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
201 | 201 | ]; |
202 | - $text = !empty( $data['p1'] ) |
|
202 | + $text = !empty($data['p1']) |
|
203 | 203 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
204 | 204 | : $data['s1']; |
205 | 205 | $rendered .= $this->render( 'result', [ |
206 | 206 | 'entry' => wp_json_encode( $data ), |
207 | 207 | 'text' => wp_strip_all_tags( $text ), |
208 | - ]); |
|
208 | + ] ); |
|
209 | 209 | } |
210 | 210 | if( $resetAfterRender ) { |
211 | 211 | $this->reset(); |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | public function search( $needle = '' ) |
239 | 239 | { |
240 | 240 | $this->reset(); |
241 | - $needle = trim( strtolower( $needle )); |
|
241 | + $needle = trim( strtolower( $needle ) ); |
|
242 | 242 | foreach( $this->entries() as $key => $entry ) { |
243 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
244 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
243 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
244 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
245 | 245 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
246 | - if( in_array( $needle, [$single, $plural] )) { |
|
246 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
247 | 247 | $this->results[$key] = $entry; |
248 | 248 | } |
249 | 249 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | $args = $this->normalizeTranslationArgs( $args ); |
268 | 268 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
269 | - if( empty( $strings )) { |
|
269 | + if( empty($strings) ) { |
|
270 | 270 | return $original; |
271 | 271 | } |
272 | 272 | $string = current( $strings ); |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | */ |
282 | 282 | protected function getEntryString( array $entry, $key ) |
283 | 283 | { |
284 | - return isset( $entry[$key] ) |
|
285 | - ? implode( '', (array) $entry[$key] ) |
|
284 | + return isset($entry[$key]) |
|
285 | + ? implode( '', (array)$entry[$key] ) |
|
286 | 286 | : ''; |
287 | 287 | } |
288 | 288 | |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | protected function getTranslations() |
293 | 293 | { |
294 | 294 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
295 | - return isset( $settings['strings'] ) |
|
296 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
295 | + return isset($settings['strings']) |
|
296 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
297 | 297 | : []; |
298 | 298 | } |
299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | protected function getTranslationStrings( $single, $plural ) |
306 | 306 | { |
307 | - return array_filter( $this->getTranslations(), function( $string ) use( $single, $plural ) { |
|
307 | + return array_filter( $this->getTranslations(), function( $string ) use($single, $plural) { |
|
308 | 308 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
309 | 309 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
310 | 310 | }); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $keys = [ |
319 | 319 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
320 | 320 | ]; |
321 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
321 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
322 | 322 | foreach( $keys as $key ) { |
323 | 323 | $entry = $this->normalizeEntryString( $entry, $key ); |
324 | 324 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | protected function normalizeEntryString( array $entry, $key ) |
334 | 334 | { |
335 | - if( isset( $entry[$key] )) { |
|
335 | + if( isset($entry[$key]) ) { |
|
336 | 336 | $entry[$key] = $this->getEntryString( $entry, $key ); |
337 | 337 | } |
338 | 338 | return $entry; |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
347 | 347 | $strings = array_filter( $strings, 'is_array' ); |
348 | 348 | foreach( $strings as &$string ) { |
349 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
349 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
350 | 350 | $string = wp_parse_args( $string, $defaultString ); |
351 | 351 | } |
352 | 352 | return array_filter( $strings, function( $string ) { |
353 | - return !empty( $string['id'] ); |
|
353 | + return !empty($string['id']); |
|
354 | 354 | }); |
355 | 355 | } |
356 | 356 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | protected function translatePlural( $domain, array $string, array $args ) |
376 | 376 | { |
377 | - if( !empty( $string['p2'] )) { |
|
377 | + if( !empty($string['p2']) ) { |
|
378 | 378 | $args['plural'] = $string['p2']; |
379 | 379 | } |
380 | 380 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | protected function translateSingle( $domain, array $string, array $args ) |
393 | 393 | { |
394 | - if( !empty( $string['s2'] )) { |
|
394 | + if( !empty($string['s2']) ) { |
|
395 | 395 | $args['single'] = $string['s2']; |
396 | 396 | } |
397 | 397 | return get_translations_for_domain( $domain )->translate( |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | return $input; |
22 | 22 | } |
23 | 23 | $triggered = true; |
24 | - if( !is_array( $input )) { |
|
24 | + if( !is_array( $input ) ) { |
|
25 | 25 | $input = ['settings' => []]; |
26 | 26 | } |
27 | 27 | if( key( $input ) == 'settings' ) { |
28 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
28 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
29 | 29 | } |
30 | 30 | $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
31 | 31 | $options = $this->sanitizeSubmissions( $input, $options ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
44 | - ]); |
|
44 | + ] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function sanitizeSubmissions( array $input, array $options ) |
51 | 51 | { |
52 | - if( isset( $input['settings']['submissions'] )) { |
|
52 | + if( isset($input['settings']['submissions']) ) { |
|
53 | 53 | $inputForm = $input['settings']['submissions']; |
54 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
54 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
55 | 55 | ? $inputForm['required'] |
56 | 56 | : []; |
57 | 57 | } |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function sanitizeTranslations( array $input, array $options ) |
65 | 65 | { |
66 | - if( isset( $input['settings']['strings'] )) { |
|
67 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
66 | + if( isset($input['settings']['strings']) ) { |
|
67 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
68 | 68 | array_walk( $options['settings']['strings'], function( &$string ) { |
69 | - if( isset( $string['s2'] )) { |
|
69 | + if( isset($string['s2']) ) { |
|
70 | 70 | $string['s2'] = wp_strip_all_tags( $string['s2'] ); |
71 | 71 | } |
72 | - if( isset( $string['p2'] )) { |
|
72 | + if( isset($string['p2']) ) { |
|
73 | 73 | $string['p2'] = wp_strip_all_tags( $string['p2'] ); |
74 | 74 | } |
75 | 75 | }); |