@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | <div id="<?= $tax_name; ?>-all" class="tabs-panel"> |
17 | 17 | <input type="hidden" name="tax_input[<?= $tax_name; ?>][]" value='0' /> |
18 | 18 | <ul id="<?= $tax_name; ?>checklist" data-wp-lists="list:<?= $tax_name; ?>" class="categorychecklist form-no-clear"> |
19 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids )); ?> |
|
19 | + <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?> |
|
20 | 20 | </ul> |
21 | 21 | </div> |
22 | 22 | |
23 | - <?php if( current_user_can( $taxonomy->cap->edit_terms )) : ?> |
|
23 | + <?php if( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
24 | 24 | <div id="<?= $tax_name; ?>-adder" class="wp-hidden-children"> |
25 | 25 | <a id="<?= $tax_name; ?>-add-toggle" href="#<?= $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new"> |
26 | 26 | <?= sprintf( '+ %s', $taxonomy->labels->add_new_item ); ?> |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | <label class="screen-reader-text" for="new<?= $tax_name; ?>"><?= $taxonomy->labels->add_new_item; ?></label> |
30 | 30 | <input type="text" name="new<?= $tax_name; ?>" id="new<?= $tax_name; ?>" class="form-required form-input-tip" value="<?= esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/> |
31 | 31 | <input type="button" id="<?= $tax_name; ?>-add-submit" data-wp-lists="add:<?= $tax_name; ?>checklist:<?= $tax_name; ?>-add" class="button category-add-submit" value="<?= esc_attr( $taxonomy->labels->add_new_item ); ?>" /> |
32 | - <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> |
|
32 | + <?php wp_nonce_field( 'add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false ); ?> |
|
33 | 33 | <span id="<?= $tax_name; ?>-ajax-response"></span> |
34 | 34 | </div> |
35 | 35 | </div> |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php defined( 'WPINC' ) || die; ?> |
2 | 2 | |
3 | 3 | <div id="titlediv"> |
4 | - <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' )); ?>" readonly> |
|
4 | + <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' ) ); ?>" readonly> |
|
5 | 5 | </div> |
6 | 6 | |
7 | 7 | <div id="contentdiv"> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $this->validateBlacklist(); |
60 | 60 | $this->validateAkismet(); |
61 | 61 | $this->validateRecaptcha(); |
62 | - if( !empty( $this->error )) { |
|
62 | + if( !empty($this->error) ) { |
|
63 | 63 | $this->setSessionValues( 'message', $this->error ); |
64 | 64 | } |
65 | 65 | return $this; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function validateRequest( array $request ) |
72 | 72 | { |
73 | - if( !$this->isRequestValid( $request )) { |
|
73 | + if( !$this->isRequestValid( $request ) ) { |
|
74 | 74 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
75 | 75 | return $request; |
76 | 76 | } |
77 | - if( empty( $request['title'] )) { |
|
77 | + if( empty($request['title']) ) { |
|
78 | 78 | $request['title'] = __( 'No Title', 'site-reviews' ); |
79 | 79 | } |
80 | 80 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ), |
100 | 100 | $this->getOption( 'settings.submissions.required', [] ) |
101 | 101 | ); |
102 | - $excluded = isset( $request['excluded'] ) |
|
102 | + $excluded = isset($request['excluded']) |
|
103 | 103 | ? (array)json_decode( $request['excluded'] ) |
104 | 104 | : []; |
105 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
105 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | $recaptchaResponse = glsr( Helper::class )->filterInput( 'g-recaptcha-response' ); // @todo site-reviews[g-recaptcha-response] |
118 | - if( empty( $recaptchaResponse )) { |
|
118 | + if( empty($recaptchaResponse) ) { |
|
119 | 119 | return null; //if response is empty we need to return null |
120 | 120 | } |
121 | 121 | if( $integration == 'custom' ) { |
122 | 122 | return $this->isRecaptchaValid( $recaptchaResponse ); |
123 | 123 | } |
124 | 124 | if( $integration == 'invisible-recaptcha' ) { |
125 | - return boolval( apply_filters( 'google_invre_is_valid_request_filter', true )); |
|
125 | + return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) ); |
|
126 | 126 | } |
127 | 127 | return false; |
128 | 128 | } |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function isRecaptchaValid( $recaptchaResponse ) |
134 | 134 | { |
135 | - $endpoint = add_query_arg([ |
|
135 | + $endpoint = add_query_arg( [ |
|
136 | 136 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
137 | 137 | 'response' => $recaptchaResponse, |
138 | 138 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
139 | 139 | ], 'https://www.google.com/recaptcha/api/siteverify' ); |
140 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
140 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
141 | 141 | glsr_log()->error( $response->get_error_message() ); |
142 | 142 | return false; |
143 | 143 | } |
144 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
145 | - if( !empty( $response->success )) { |
|
144 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
145 | + if( !empty($response->success) ) { |
|
146 | 146 | return boolval( $response->success ); |
147 | 147 | } |
148 | 148 | $errorCodes = [ |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $rules = $this->getValidationRules( $request ); |
167 | 167 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
168 | - if( empty( $errors )) { |
|
168 | + if( empty($errors) ) { |
|
169 | 169 | return true; |
170 | 170 | } |
171 | 171 | $this->setSessionValues( 'errors', $errors ); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
183 | 183 | { |
184 | 184 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
185 | - if( !empty( $loggedMessage )) { |
|
185 | + if( !empty($loggedMessage) ) { |
|
186 | 186 | glsr_log()->warning( $loggedMessage ); |
187 | 187 | glsr_log()->warning( $this->request ); |
188 | 188 | } |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function validateAkismet() |
195 | 195 | { |
196 | - if( !empty( $this->error ))return; |
|
197 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
196 | + if( !empty($this->error) )return; |
|
197 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
198 | 198 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
199 | 199 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
200 | 200 | } |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function validateBlacklist() |
206 | 206 | { |
207 | - if( !empty( $this->error ))return; |
|
208 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
207 | + if( !empty($this->error) )return; |
|
208 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
209 | 209 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
210 | 210 | if( $blacklistAction == 'reject' ) { |
211 | 211 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function validateCustom() |
222 | 222 | { |
223 | - if( !empty( $this->error ))return; |
|
223 | + if( !empty($this->error) )return; |
|
224 | 224 | $validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request ); |
225 | 225 | if( $validated === true )return; |
226 | 226 | $this->setSessionValues( 'errors', [] ); |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function validateHoneyPot() |
237 | 237 | { |
238 | - if( !empty( $this->error ))return; |
|
239 | - if( empty( $this->request['gotcha'] ))return; |
|
238 | + if( !empty($this->error) )return; |
|
239 | + if( empty($this->request['gotcha']) )return; |
|
240 | 240 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
241 | 241 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
242 | 242 | } |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function validateRecaptcha() |
248 | 248 | { |
249 | - if( !empty( $this->error ))return; |
|
249 | + if( !empty($this->error) )return; |
|
250 | 250 | $isValid = $this->isRecaptchaResponseValid(); |
251 | - if( is_null( $isValid )) { |
|
251 | + if( is_null( $isValid ) ) { |
|
252 | 252 | $this->setSessionValues( 'recaptcha', true ); |
253 | 253 | $this->recaptchaIsUnset = true; |
254 | 254 | } |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | { |
17 | 17 | $queries = []; |
18 | 18 | foreach( $keys as $key ) { |
19 | - if( !array_key_exists( $key, $values ))continue; |
|
19 | + if( !array_key_exists( $key, $values ) )continue; |
|
20 | 20 | $methodName = glsr( Helper::class )->buildMethodName( $key, __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
21 | + if( !method_exists( $this, $methodName ) )continue; |
|
22 | 22 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | - if( is_array( $query )) { |
|
23 | + if( is_array( $query ) ) { |
|
24 | 24 | $queries[] = $query; |
25 | 25 | } |
26 | 26 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function buildSqlOr( $values, $sprintfFormat ) |
37 | 37 | { |
38 | - if( !is_array( $values )) { |
|
38 | + if( !is_array( $values ) ) { |
|
39 | 39 | $values = explode( ',', $values ); |
40 | 40 | } |
41 | - $values = array_filter( array_map( 'trim', (array)$values )); |
|
42 | - $values = array_map( function( $value ) use( $sprintfFormat ) { |
|
41 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
42 | + $values = array_map( function( $value ) use($sprintfFormat) { |
|
43 | 43 | return sprintf( $sprintfFormat, $value ); |
44 | 44 | }, $values ); |
45 | 45 | return implode( ' OR ', $values ); |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function filterSearchByTitle( $search, WP_Query $query ) |
56 | 56 | { |
57 | - if( empty( $search ) || empty( $query->get( 'search_terms' ))) { |
|
57 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
58 | 58 | return $search; |
59 | 59 | } |
60 | 60 | global $wpdb; |
61 | - $n = empty( $query->get( 'exact' )) |
|
61 | + $n = empty($query->get( 'exact' )) |
|
62 | 62 | ? '%' |
63 | 63 | : ''; |
64 | 64 | $search = []; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ? Application::PAGED_QUERY_VAR |
83 | 83 | : 'page'; |
84 | 84 | return $isEnabled |
85 | - ? max( 1, intval( get_query_var( $pagedQuery ))) |
|
85 | + ? max( 1, intval( get_query_var( $pagedQuery ) ) ) |
|
86 | 86 | : 1; |
87 | 87 | } |
88 | 88 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function buildQueryAssignedTo( $value ) |
94 | 94 | { |
95 | - if( empty( $value ))return; |
|
95 | + if( empty($value) )return; |
|
96 | 96 | return [ |
97 | 97 | 'compare' => 'IN', |
98 | 98 | 'key' => 'assigned_to', |
99 | - 'value' => array_filter( array_map( 'trim', explode( ',', $value )), 'is_numeric' ), |
|
99 | + 'value' => array_filter( array_map( 'trim', explode( ',', $value ) ), 'is_numeric' ), |
|
100 | 100 | ]; |
101 | 101 | } |
102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function buildQueryCategory( $value ) |
108 | 108 | { |
109 | - if( empty( $value ))return; |
|
109 | + if( empty($value) )return; |
|
110 | 110 | return [ |
111 | 111 | 'field' => 'term_id', |
112 | 112 | 'taxonomy' => Application::TAXONOMY, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function buildQueryRating( $value ) |
122 | 122 | { |
123 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
123 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return; |
|
124 | 124 | return [ |
125 | 125 | 'compare' => '>=', |
126 | 126 | 'key' => 'rating', |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function buildQueryType( $value ) |
136 | 136 | { |
137 | - if( in_array( $value, ['','all'] ))return; |
|
137 | + if( in_array( $value, ['', 'all'] ) )return; |
|
138 | 138 | return [ |
139 | 139 | 'key' => 'review_type', |
140 | 140 | 'value' => $value, |
@@ -16,9 +16,13 @@ discard block |
||
16 | 16 | { |
17 | 17 | $queries = []; |
18 | 18 | foreach( $keys as $key ) { |
19 | - if( !array_key_exists( $key, $values ))continue; |
|
19 | + if( !array_key_exists( $key, $values )) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | $methodName = glsr( Helper::class )->buildMethodName( $key, __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
23 | + if( !method_exists( $this, $methodName )) { |
|
24 | + continue; |
|
25 | + } |
|
22 | 26 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | 27 | if( is_array( $query )) { |
24 | 28 | $queries[] = $query; |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | */ |
93 | 97 | protected function buildQueryAssignedTo( $value ) |
94 | 98 | { |
95 | - if( empty( $value ))return; |
|
99 | + if( empty( $value )) { |
|
100 | + return; |
|
101 | + } |
|
96 | 102 | return [ |
97 | 103 | 'compare' => 'IN', |
98 | 104 | 'key' => 'assigned_to', |
@@ -106,7 +112,9 @@ discard block |
||
106 | 112 | */ |
107 | 113 | protected function buildQueryCategory( $value ) |
108 | 114 | { |
109 | - if( empty( $value ))return; |
|
115 | + if( empty( $value )) { |
|
116 | + return; |
|
117 | + } |
|
110 | 118 | return [ |
111 | 119 | 'field' => 'term_id', |
112 | 120 | 'taxonomy' => Application::TAXONOMY, |
@@ -120,7 +128,9 @@ discard block |
||
120 | 128 | */ |
121 | 129 | protected function buildQueryRating( $value ) |
122 | 130 | { |
123 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
131 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
132 | + return; |
|
133 | + } |
|
124 | 134 | return [ |
125 | 135 | 'compare' => '>=', |
126 | 136 | 'key' => 'rating', |
@@ -134,7 +144,9 @@ discard block |
||
134 | 144 | */ |
135 | 145 | protected function buildQueryType( $value ) |
136 | 146 | { |
137 | - if( in_array( $value, ['','all'] ))return; |
|
147 | + if( in_array( $value, ['','all'] )) { |
|
148 | + return; |
|
149 | + } |
|
138 | 150 | return [ |
139 | 151 | 'key' => 'review_type', |
140 | 152 | 'value' => $value, |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | { |
31 | 31 | foreach( $args as $key => $value ) { |
32 | 32 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
33 | - if( !property_exists( $this, $property ))continue; |
|
33 | + if( !property_exists( $this, $property ) )continue; |
|
34 | 34 | $this->$property = $value; |
35 | - unset( $args[$key] ); |
|
35 | + unset($args[$key]); |
|
36 | 36 | } |
37 | 37 | $this->args = wp_parse_args( $args, [ |
38 | 38 | 'menu_name' => $this->plural, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | 'singular_name' => $this->single, |
60 | 60 | 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
61 | 61 | 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
62 | - ]); |
|
63 | - unset( $this->args['menu_name'] ); |
|
62 | + ] ); |
|
63 | + unset($this->args['menu_name']); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | protected function normalizeColumns() |
70 | 70 | { |
71 | 71 | $this->columns = ['cb' => ''] + $this->columns; |
72 | - if( array_key_exists( 'category', $this->columns )) { |
|
72 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
73 | 73 | $keys = array_keys( $this->columns ); |
74 | 74 | $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
75 | 75 | $this->columns = array_combine( $keys, $this->columns ); |
76 | 76 | } |
77 | - if( array_key_exists( 'pinned', $this->columns )) { |
|
77 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
78 | 78 | $this->columns['pinned'] = glsr( Builder::class )->span( '<span>'.$this->columns['pinned'].'</span>', |
79 | 79 | ['class' => 'pinned-icon'] |
80 | 80 | ); |