@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | defined( 'WPINC' ) || die; |
20 | 20 | |
21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | 24 | if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $app = new GeminiLabs\SiteReviews\Application; |
31 | 31 | $app->make( 'Provider' )->register( $app ); |
32 | -register_activation_hook( __FILE__, array( $app, 'activate' )); |
|
33 | -register_deactivation_hook( __FILE__, array( $app, 'deactivate' )); |
|
34 | -register_shutdown_function( array( $app, 'catchFatalError' )); |
|
32 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
33 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
34 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
35 | 35 | $app->init(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->validateBlacklist(); |
62 | 62 | $this->validateAkismet(); |
63 | 63 | $this->validateRecaptcha(); |
64 | - if( !empty( $this->error )) { |
|
64 | + if( !empty($this->error) ) { |
|
65 | 65 | $this->setSessionValues( 'message', $this->error ); |
66 | 66 | } |
67 | 67 | return $this; |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | { |
85 | 85 | $rules = array_intersect_key( |
86 | 86 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ), |
87 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
87 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
88 | 88 | ); |
89 | - $excluded = isset( $request['excluded'] ) |
|
89 | + $excluded = isset($request['excluded']) |
|
90 | 90 | ? (array)json_decode( $request['excluded'] ) |
91 | 91 | : []; |
92 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
92 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
101 | 101 | return true; |
102 | 102 | } |
103 | - if( empty( $this->request['recaptcha-token'] )) { |
|
103 | + if( empty($this->request['recaptcha-token']) ) { |
|
104 | 104 | return null; // @see $this->validateRecaptcha() |
105 | 105 | } |
106 | 106 | return $this->isRecaptchaValid( $this->request['recaptcha-token'] ); |
@@ -112,17 +112,17 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function isRecaptchaValid( $recaptchaToken ) |
114 | 114 | { |
115 | - $endpoint = add_query_arg([ |
|
115 | + $endpoint = add_query_arg( [ |
|
116 | 116 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
117 | 117 | 'response' => $recaptchaToken, |
118 | 118 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
119 | 119 | ], static::RECAPTCHA_ENDPOINT ); |
120 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
120 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
121 | 121 | glsr_log()->error( $response->get_error_message() ); |
122 | 122 | return false; |
123 | 123 | } |
124 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
125 | - if( !empty( $response->success )) { |
|
124 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
125 | + if( !empty($response->success) ) { |
|
126 | 126 | return boolval( $response->success ); |
127 | 127 | } |
128 | 128 | foreach( $response->{'error-codes'} as $error ) { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $rules = $this->getValidationRules( $request ); |
140 | 140 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
141 | - if( empty( $errors )) { |
|
141 | + if( empty($errors) ) { |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | $this->setSessionValues( 'errors', $errors ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
156 | 156 | { |
157 | 157 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
158 | - if( !empty( $loggedMessage )) { |
|
158 | + if( !empty($loggedMessage) ) { |
|
159 | 159 | glsr_log()->warning( $loggedMessage ); |
160 | 160 | glsr_log()->warning( $this->request ); |
161 | 161 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function validateAkismet() |
168 | 168 | { |
169 | - if( !empty( $this->error ))return; |
|
170 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
169 | + if( !empty($this->error) )return; |
|
170 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
171 | 171 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
172 | 172 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
173 | 173 | } |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function validateBlacklist() |
179 | 179 | { |
180 | - if( !empty( $this->error ))return; |
|
181 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
180 | + if( !empty($this->error) )return; |
|
181 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
182 | 182 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
183 | 183 | if( $blacklistAction == 'reject' ) { |
184 | 184 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function validateCustom() |
195 | 195 | { |
196 | - if( !empty( $this->error ))return; |
|
196 | + if( !empty($this->error) )return; |
|
197 | 197 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
198 | 198 | if( $validated === true )return; |
199 | 199 | $this->setSessionValues( 'errors', [] ); |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function validateHoneyPot() |
210 | 210 | { |
211 | - if( !empty( $this->error ))return; |
|
212 | - if( empty( $this->request['gotcha'] ))return; |
|
211 | + if( !empty($this->error) )return; |
|
212 | + if( empty($this->request['gotcha']) )return; |
|
213 | 213 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
214 | 214 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
215 | 215 | } |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function validateRecaptcha() |
221 | 221 | { |
222 | - if( !empty( $this->error ))return; |
|
222 | + if( !empty($this->error) )return; |
|
223 | 223 | $isValid = $this->isRecaptchaResponseValid(); |
224 | - if( is_null( $isValid )) { |
|
224 | + if( is_null( $isValid ) ) { |
|
225 | 225 | $this->setSessionValues( 'recaptcha', 'unset' ); |
226 | 226 | $this->recaptchaIsUnset = true; |
227 | 227 | } |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function validateRequest( array $request ) |
239 | 239 | { |
240 | - if( !$this->isRequestValid( $request )) { |
|
240 | + if( !$this->isRequestValid( $request ) ) { |
|
241 | 241 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
242 | 242 | return $request; |
243 | 243 | } |
244 | - if( empty( $request['title'] )) { |
|
244 | + if( empty($request['title']) ) { |
|
245 | 245 | $request['title'] = __( 'No Title', 'site-reviews' ); |
246 | 246 | } |
247 | 247 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function __get( $key ) |
48 | 48 | { |
49 | - if( property_exists( $this, $key )) { |
|
49 | + if( property_exists( $this, $key ) ) { |
|
50 | 50 | return $this->$key; |
51 | 51 | } |
52 | - if( is_array( $this->custom ) && array_key_exists( $key, $this->custom )) { |
|
52 | + if( is_array( $this->custom ) && array_key_exists( $key, $this->custom ) ) { |
|
53 | 53 | return $this->custom[$key]; |
54 | 54 | } |
55 | 55 | return ''; |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | 'review_type' => '', |
78 | 78 | ]; |
79 | 79 | $meta = array_filter( |
80 | - array_map( 'array_shift', (array)get_post_meta( $post->ID )), |
|
80 | + array_map( 'array_shift', (array)get_post_meta( $post->ID ) ), |
|
81 | 81 | 'strlen' |
82 | 82 | ); |
83 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
83 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
84 | 84 | $this->modified = $this->isModified( $properties ); |
85 | 85 | array_walk( $properties, function( $value, $key ) { |
86 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
86 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
87 | 87 | $this->$key = maybe_unserialize( $value ); |
88 | 88 | }); |
89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | protected function setTermIds( WP_Post $post ) |
95 | 95 | { |
96 | 96 | $this->term_ids = []; |
97 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
97 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
98 | 98 | foreach( $terms as $term ) { |
99 | 99 | $this->term_ids[] = $term->term_id; |
100 | 100 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | // Database/ReviewManager.php |
6 | 6 | add_action( 'site-reviews/review/created', function( $review ) { |
7 | - if( has_action( 'site-reviews/local/review/create' )) { |
|
7 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
8 | 8 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/create/review" hook instead.'; |
9 | 9 | do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
10 | 10 | } |
@@ -12,18 +12,18 @@ discard block |
||
12 | 12 | |
13 | 13 | // Handlers/CreateReview.php |
14 | 14 | add_action( 'site-reviews/review/submitted', function( $review ) { |
15 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
15 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
16 | 16 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
17 | 17 | do_action( 'site-reviews/local/review/submitted', null, $review ); |
18 | 18 | } |
19 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
19 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
20 | 20 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
21 | 21 | } |
22 | 22 | }, 9 ); |
23 | 23 | |
24 | 24 | // Database/ReviewManager.php |
25 | 25 | add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
26 | - if( has_filter( 'site-reviews/local/review' )) { |
|
26 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
27 | 27 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
28 | 28 | return apply_filters( 'site-reviews/local/review', $values, $command ); |
29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // Handlers/EnqueuePublicAssets.php |
34 | 34 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
35 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
35 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
36 | 36 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
37 | 37 | return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | // Modules/Rating.php |
43 | 43 | add_filter( 'site-reviews/rating/average', function( $average ) { |
44 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
44 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
45 | 45 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
46 | 46 | } |
47 | 47 | return $average; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | // Modules/Rating.php |
51 | 51 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
52 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
52 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
53 | 53 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
54 | 54 | } |
55 | 55 | return $ranking; |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | |
58 | 58 | // Modules/Html/Partials/SiteReviews.php |
59 | 59 | add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
60 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
60 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
61 | 61 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
62 | 62 | } |
63 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
63 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
64 | 64 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
65 | 65 | } |
66 | 66 | return $renderedFields; |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | |
69 | 69 | // Modules/Html/Partials/SiteReviews.php |
70 | 70 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
71 | - if( has_filter( 'site-reviews/rendered/review' )) { |
|
71 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
72 | 72 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
73 | 73 | } |
74 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
74 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
75 | 75 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
76 | 76 | } |
77 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
77 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
78 | 78 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
79 | 79 | } |
80 | - if( has_filter( 'site-reviews/rendered/review-form/login-register' )) { |
|
80 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
81 | 81 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
82 | 82 | } |
83 | - if( has_filter( 'site-reviews/reviews/navigation_links' )) { |
|
83 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
84 | 84 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
85 | 85 | } |
86 | 86 | return $review; |
87 | 87 | }, 9 ); |
88 | 88 | |
89 | 89 | add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
90 | - if( has_filter( 'site-reviews/validate/review/submission' )) { |
|
90 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
91 | 91 | glsr_log()->notice( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
92 | 92 | return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | }, 9, 2 ); |
96 | 96 | |
97 | 97 | add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
98 | - if( has_filter( 'site-reviews/addon/views/file' )) { |
|
98 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
99 | 99 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
100 | 100 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | }, 9, 3 ); |
104 | 104 | |
105 | 105 | add_action( 'wp_footer', function() { |
106 | - $notices = array_keys( array_flip( glsr()->deprecated )); |
|
106 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
107 | 107 | natsort( $notices ); |
108 | 108 | foreach( $notices as $notice ) { |
109 | 109 | glsr_log()->notice( $notice ); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | <p>{{ data.s1 }}</p> |
8 | 8 | </div> |
9 | 9 | <p class="row-actions"> |
10 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
10 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | 11 | </p> |
12 | 12 | </td> |
13 | 13 | <td class="glsr-string-td2"> |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <p>{{ data.p1 }}</p> |
9 | 9 | </div> |
10 | 10 | <p class="row-actions"> |
11 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
12 | 12 | </p> |
13 | 13 | </td> |
14 | 14 | <td class="glsr-string-td2"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | return $this->translate( $translation, $domain, [ |
20 | 20 | 'single' => $text, |
21 | - ]); |
|
21 | + ] ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | return $this->translate( $translation, $domain, [ |
34 | 34 | 'context' => $context, |
35 | 35 | 'single' => $text, |
36 | - ]); |
|
36 | + ] ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'number' => $number, |
51 | 51 | 'plural' => $plural, |
52 | 52 | 'single' => $single, |
53 | - ]); |
|
53 | + ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'number' => $number, |
70 | 70 | 'plural' => $plural, |
71 | 71 | 'single' => $single, |
72 | - ]); |
|
72 | + ] ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | $args = $this->normalizeTranslationArgs( $args ); |
86 | 86 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
87 | - if( empty( $strings )) { |
|
87 | + if( empty($strings) ) { |
|
88 | 88 | return $original; |
89 | 89 | } |
90 | 90 | $string = current( $strings ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function getTranslationStrings( $single, $plural ) |
102 | 102 | { |
103 | - return array_filter( glsr( Translation::class )->translations(), function( $string ) use( $single, $plural ) { |
|
103 | + return array_filter( glsr( Translation::class )->translations(), function( $string ) use($single, $plural) { |
|
104 | 104 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
105 | 105 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
106 | 106 | }); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function translatePlural( $domain, array $string, array $args ) |
128 | 128 | { |
129 | - if( !empty( $string['s2'] )) { |
|
129 | + if( !empty($string['s2']) ) { |
|
130 | 130 | $args['single'] = $string['s2']; |
131 | 131 | } |
132 | - if( !empty( $string['p2'] )) { |
|
132 | + if( !empty($string['p2']) ) { |
|
133 | 133 | $args['plural'] = $string['p2']; |
134 | 134 | } |
135 | 135 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function translateSingle( $domain, array $string, array $args ) |
148 | 148 | { |
149 | - if( !empty( $string['s2'] )) { |
|
149 | + if( !empty($string['s2']) ) { |
|
150 | 150 | $args['single'] = $string['s2']; |
151 | 151 | } |
152 | 152 | return get_translations_for_domain( $domain )->translate( |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $className = str_replace( '.php', '', $file ); |
29 | 29 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
30 | 30 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
31 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
32 | 32 | glsr( 'Modules\\Upgrader\\'.$className ); |
33 | 33 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
34 | 34 | }); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getFieldDefault( array $field ) |
31 | 31 | { |
32 | - return isset( $field['default'] ) |
|
32 | + return isset($field['default']) |
|
33 | 33 | ? $field['default'] |
34 | 34 | : ''; |
35 | 35 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | protected function getSettingFields( $path ) |
41 | 41 | { |
42 | 42 | $settings = glsr( DefaultsManager::class )->settings(); |
43 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
43 | + return array_filter( $settings, function( $key ) use($path) { |
|
44 | 44 | return glsr( Helper::class )->startsWith( $path, $key ); |
45 | 45 | }, ARRAY_FILTER_USE_KEY ); |
46 | 46 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $field = wp_parse_args( $field, [ |
56 | 56 | 'is_setting' => true, |
57 | 57 | 'name' => $name, |
58 | - ]); |
|
59 | - $rows.= new Field( $this->normalize( $field )); |
|
58 | + ] ); |
|
59 | + $rows .= new Field( $this->normalize( $field ) ); |
|
60 | 60 | } |
61 | 61 | return $rows; |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | protected function getTemplateData( $id ) |
69 | 69 | { |
70 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
70 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
71 | 71 | return [ |
72 | 72 | 'context' => [ |
73 | 73 | 'rows' => $this->getSettingRows( $fields ), |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function getTemplateDataForAddons( $id ) |
83 | 83 | { |
84 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
84 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
85 | 85 | $settings = glsr( Helper::class )->convertDotNotationArray( $fields ); |
86 | 86 | $settingKeys = array_keys( $settings['settings']['addons'] ); |
87 | 87 | $results = []; |
88 | 88 | foreach( $settingKeys as $key ) { |
89 | - $addonFields = array_filter( $fields, function( $path ) use( $key ) { |
|
89 | + $addonFields = array_filter( $fields, function( $path ) use($key) { |
|
90 | 90 | return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path ); |
91 | 91 | }, ARRAY_FILTER_USE_KEY ); |
92 | 92 | $results[$key] = $this->getSettingRows( $addonFields ); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function getTemplateDataForTranslations() |
103 | 103 | { |
104 | 104 | $translations = glsr( Translation::class )->renderAll(); |
105 | - $class = empty( $translations ) |
|
105 | + $class = empty($translations) |
|
106 | 106 | ? 'glsr-hidden' |
107 | 107 | : ''; |
108 | 108 | return [ |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | $path, |
126 | 126 | glsr( Helper::class )->getPathValue( $path, glsr()->defaults ) |
127 | 127 | ); |
128 | - if( is_array( $expectedValue )) { |
|
128 | + if( is_array( $expectedValue ) ) { |
|
129 | 129 | return is_array( $optionValue ) |
130 | - ? count( array_intersect( $optionValue, $expectedValue )) === 0 |
|
130 | + ? count( array_intersect( $optionValue, $expectedValue ) ) === 0 |
|
131 | 131 | : !in_array( $optionValue, $expectedValue ); |
132 | 132 | } |
133 | 133 | return $optionValue != $expectedValue; |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function normalizeDependsOn( array $field ) |
151 | 151 | { |
152 | - if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) { |
|
152 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
153 | 153 | $path = key( $field['depends_on'] ); |
154 | 154 | $expectedValue = $field['depends_on'][$path]; |
155 | 155 | $fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ); |
156 | - if( is_array( $expectedValue )) { |
|
157 | - $fieldName.= '[]'; |
|
156 | + if( is_array( $expectedValue ) ) { |
|
157 | + $fieldName .= '[]'; |
|
158 | 158 | } |
159 | - $field['data-depends'] = json_encode([ |
|
159 | + $field['data-depends'] = json_encode( [ |
|
160 | 160 | 'name' => $fieldName, |
161 | 161 | 'value' => $expectedValue, |
162 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
162 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
163 | 163 | $field['is_hidden'] = $this->isFieldHidden( $path, $expectedValue ); |
164 | 164 | } |
165 | 165 | return $field; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function normalizeLabelAndLegend( array $field ) |
172 | 172 | { |
173 | - if( !empty( $field['label'] )) { |
|
173 | + if( !empty($field['label']) ) { |
|
174 | 174 | $field['legend'] = $field['label']; |
175 | - unset( $field['label'] ); |
|
175 | + unset($field['label']); |
|
176 | 176 | } |
177 | 177 | else { |
178 | 178 | $field['is_valid'] = false; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function normalizeValue( array $field ) |
188 | 188 | { |
189 | - if( !isset( $field['value'] )) { |
|
189 | + if( !isset($field['value']) ) { |
|
190 | 190 | $field['value'] = glsr( OptionManager::class )->get( |
191 | 191 | $field['name'], |
192 | 192 | $this->getFieldDefault( $field ) |