@@ -29,7 +29,9 @@ |
||
29 | 29 | { |
30 | 30 | foreach( $args as $key => $value ) { |
31 | 31 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
32 | - if( !property_exists( $this, $property ))continue; |
|
32 | + if( !property_exists( $this, $property )) { |
|
33 | + continue; |
|
34 | + } |
|
33 | 35 | $this->$property = $value; |
34 | 36 | unset( $args[$key] ); |
35 | 37 | } |
@@ -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( |
79 | 79 | '<span>'.$this->columns['pinned'].'</span>', |
80 | 80 | ['class' => 'pinned-icon'] |
@@ -181,7 +181,9 @@ discard block |
||
181 | 181 | $key = $value; |
182 | 182 | $value = true; |
183 | 183 | } |
184 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
184 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
185 | + continue; |
|
186 | + } |
|
185 | 187 | $this->attributes[$key] = wp_validate_boolean( $value ); |
186 | 188 | } |
187 | 189 | } |
@@ -196,7 +198,9 @@ discard block |
||
196 | 198 | $key = $value; |
197 | 199 | $value = ''; |
198 | 200 | } |
199 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
201 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
202 | + continue; |
|
203 | + } |
|
200 | 204 | if( is_array( $value )) { |
201 | 205 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
202 | 206 | } |
@@ -210,7 +214,9 @@ discard block |
||
210 | 214 | protected function normalizeStringAttributes() |
211 | 215 | { |
212 | 216 | foreach( $this->attributes as $key => $value ) { |
213 | - if( !is_string( $value ))continue; |
|
217 | + if( !is_string( $value )) { |
|
218 | + continue; |
|
219 | + } |
|
214 | 220 | $this->attributes[$key] = trim( $value ); |
215 | 221 | } |
216 | 222 | } |
@@ -221,7 +227,9 @@ discard block |
||
221 | 227 | */ |
222 | 228 | protected function normalizeInputType( $method ) |
223 | 229 | { |
224 | - if( $method != 'input' )return; |
|
230 | + if( $method != 'input' ) { |
|
231 | + return; |
|
232 | + } |
|
225 | 233 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
226 | 234 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
227 | 235 | $this->attributes['type'] = 'text'; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function filterAttributes( array $allowedAttributeKeys ) |
119 | 119 | { |
120 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
120 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
129 | 129 | $wildcards = []; |
130 | 130 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
131 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
131 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
132 | 132 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
133 | 133 | }, ARRAY_FILTER_USE_KEY ); |
134 | 134 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | protected function getPermanentAttributes() |
143 | 143 | { |
144 | 144 | $permanentAttributes = []; |
145 | - if( array_key_exists( 'value', $this->attributes )) { |
|
145 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
146 | 146 | $permanentAttributes['value'] = $this->attributes['value']; |
147 | 147 | } |
148 | 148 | return $permanentAttributes; |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | protected function normalizeBooleanAttributes() |
195 | 195 | { |
196 | 196 | foreach( $this->attributes as $key => $value ) { |
197 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
197 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
198 | 198 | $key = $value; |
199 | 199 | $value = true; |
200 | 200 | } |
201 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
201 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
202 | 202 | $this->attributes[$key] = wp_validate_boolean( $value ); |
203 | 203 | } |
204 | 204 | } |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | protected function normalizeDataAttributes() |
210 | 210 | { |
211 | 211 | foreach( $this->attributes as $key => $value ) { |
212 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
212 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
213 | 213 | $key = $value; |
214 | 214 | $value = ''; |
215 | 215 | } |
216 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
217 | - if( is_array( $value )) { |
|
216 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
217 | + if( is_array( $value ) ) { |
|
218 | 218 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
219 | 219 | } |
220 | 220 | $this->attributes[$key] = $value; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | protected function normalizeStringAttributes() |
228 | 228 | { |
229 | 229 | foreach( $this->attributes as $key => $value ) { |
230 | - if( !is_string( $value ))continue; |
|
230 | + if( !is_string( $value ) )continue; |
|
231 | 231 | $this->attributes[$key] = trim( $value ); |
232 | 232 | } |
233 | 233 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | if( $method != 'input' )return; |
242 | 242 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
243 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
243 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
244 | 244 | $this->attributes['type'] = 'text'; |
245 | 245 | } |
246 | 246 | } |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | $permanentAttributes = $this->getPermanentAttributes(); |
255 | 255 | foreach( $this->attributes as $key => $value ) { |
256 | 256 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
257 | - unset( $attributes[$key] ); |
|
257 | + unset($attributes[$key]); |
|
258 | 258 | } |
259 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
259 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
260 | 260 | $permanentAttributes[$key] = $value; |
261 | - unset( $attributes[$key] ); |
|
261 | + unset($attributes[$key]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -37,7 +37,9 @@ |
||
37 | 37 | $lines = explode( "\n", $blacklist ); |
38 | 38 | foreach( (array) $lines as $line ) { |
39 | 39 | $line = trim( $line ); |
40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
40 | + if( empty( $line ) || 256 < strlen( $line )) { |
|
41 | + continue; |
|
42 | + } |
|
41 | 43 | $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
42 | 44 | if( preg_match( $pattern, $target )) { |
43 | 45 | return true; |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function isBlacklisted( CreateReview $review ) |
14 | 14 | { |
15 | - $target = implode( "\n", array_filter([ |
|
15 | + $target = implode( "\n", array_filter( [ |
|
16 | 16 | $review->author, |
17 | 17 | $review->content, |
18 | 18 | $review->email, |
19 | 19 | $review->ipAddress, |
20 | 20 | $review->title, |
21 | - ])); |
|
22 | - return (bool) apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
21 | + ] ) ); |
|
22 | + return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
23 | 23 | $this->check( $target ), |
24 | 24 | $review |
25 | 25 | ); |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function check( $target ) |
33 | 33 | { |
34 | - $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' )); |
|
35 | - if( empty( $blacklist )) { |
|
34 | + $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) ); |
|
35 | + if( empty($blacklist) ) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | $lines = explode( "\n", $blacklist ); |
39 | - foreach( (array) $lines as $line ) { |
|
39 | + foreach( (array)$lines as $line ) { |
|
40 | 40 | $line = trim( $line ); |
41 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
42 | - $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
|
43 | - if( preg_match( $pattern, $target )) { |
|
41 | + if( empty($line) || 256 < strlen( $line ) )continue; |
|
42 | + $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) ); |
|
43 | + if( preg_match( $pattern, $target ) ) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -15,7 +15,9 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function add( $type, $message, array $args = [] ) |
17 | 17 | { |
18 | - if( empty( array_filter( [$message, $type] )))return; |
|
18 | + if( empty( array_filter( [$message, $type] ))) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | $args['message'] = $message; |
20 | 22 | $args['type'] = $type; |
21 | 23 | add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
@@ -56,7 +58,9 @@ discard block |
||
56 | 58 | $notices = array_map( 'unserialize', |
57 | 59 | array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
58 | 60 | ); |
59 | - if( empty( $notices ))return; |
|
61 | + if( empty( $notices )) { |
|
62 | + return; |
|
63 | + } |
|
60 | 64 | return array_reduce( $notices, function( $carry, $notice ) { |
61 | 65 | return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
62 | 66 | }); |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function add( $type, $message, array $args = [] ) |
17 | 17 | { |
18 | - if( empty( array_filter( [$message, $type] )))return; |
|
18 | + if( empty(array_filter( [$message, $type] )) )return; |
|
19 | 19 | $args['message'] = $message; |
20 | 20 | $args['type'] = $type; |
21 | - add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
|
21 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | public function get() |
55 | 55 | { |
56 | 56 | $notices = array_map( 'unserialize', |
57 | - array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
|
57 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
58 | 58 | ); |
59 | - if( empty( $notices ))return; |
|
59 | + if( empty($notices) )return; |
|
60 | 60 | return array_reduce( $notices, function( $carry, $notice ) { |
61 | - return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
|
61 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
62 | 62 | }); |
63 | 63 | } |
64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | return glsr( Builder::class )->div( $messages, [ |
81 | 81 | 'class' => $class, |
82 | - ]); |
|
82 | + ] ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | 'type' => '', |
95 | 95 | ]; |
96 | 96 | $args = shortcode_atts( $defaults, $args ); |
97 | - if( !in_array( $args['type'], ['error', 'warning', 'success'] )) { |
|
97 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
98 | 98 | $args['type'] = 'success'; |
99 | 99 | } |
100 | 100 | $args['messages'] = is_wp_error( $args['message'] ) |
101 | 101 | ? (array)$args['message']->get_error_message() |
102 | 102 | : (array)$args['message']; |
103 | - unset( $args['message'] ); |
|
103 | + unset($args['message']); |
|
104 | 104 | return $args; |
105 | 105 | } |
106 | 106 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | use PasswordHash; |
6 | 6 | |
7 | 7 | /** |
8 | - * This class is derived from WP Session Manager (1.2.0) |
|
9 | - */ |
|
8 | + * This class is derived from WP Session Manager (1.2.0) |
|
9 | + */ |
|
10 | 10 | class Session |
11 | 11 | { |
12 | 12 | const SESSION_COOKIE = '_glsr_session'; |
@@ -153,7 +153,7 @@ |
||
153 | 153 | $expiredSessions = []; |
154 | 154 | $sessions = $wpdb->get_results( |
155 | 155 | "SELECT option_name AS name, option_value AS expiration " . |
156 | - "FROM {$wpdb->options} " . |
|
156 | + "from {$wpdb->options} " . |
|
157 | 157 | "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " . |
158 | 158 | "ORDER BY option_value ASC " . |
159 | 159 | "LIMIT 0, ".absint( $limit ) |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() |
35 | 35 | { |
36 | - if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE )) { |
|
37 | - $cookie = explode( '||', stripslashes( $cookieId )); |
|
36 | + if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ) ) { |
|
37 | + $cookie = explode( '||', stripslashes( $cookieId ) ); |
|
38 | 38 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
39 | 39 | $this->expiryTimestamp = absint( $cookie[1] ); |
40 | 40 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | 80 | global $wpdb; |
81 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
81 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
82 | 82 | $wpdb->query( |
83 | 83 | "DELETE FROM {$wpdb->options} WHERE option_name IN ('{$expiredSessions}')" |
84 | 84 | ); |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | public function get( $key, $fallback = '', $unset = false ) |
95 | 95 | { |
96 | 96 | $key = sanitize_key( $key ); |
97 | - $value = isset( $this->sessionData[$key] ) |
|
97 | + $value = isset($this->sessionData[$key]) |
|
98 | 98 | ? maybe_unserialize( $this->sessionData[$key] ) |
99 | 99 | : $fallback; |
100 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
101 | - unset( $this->sessionData[$key] ); |
|
100 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
101 | + unset($this->sessionData[$key]); |
|
102 | 102 | $this->updateSession(); |
103 | 103 | } |
104 | 104 | return $value; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | protected function deleteSession() |
133 | 133 | { |
134 | 134 | delete_option( $this->getSessionId() ); |
135 | - delete_option( $this->getSessionId( 'expires' )); |
|
135 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function generateSessionId() |
142 | 142 | { |
143 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
143 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | global $wpdb; |
153 | 153 | $expiredSessions = []; |
154 | 154 | $sessions = $wpdb->get_results( |
155 | - "SELECT option_name AS name, option_value AS expiration " . |
|
156 | - "FROM {$wpdb->options} " . |
|
157 | - "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " . |
|
158 | - "ORDER BY option_value ASC " . |
|
155 | + "SELECT option_name AS name, option_value AS expiration ". |
|
156 | + "FROM {$wpdb->options} ". |
|
157 | + "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' ". |
|
158 | + "ORDER BY option_value ASC ". |
|
159 | 159 | "LIMIT 0, ".absint( $limit ) |
160 | 160 | ); |
161 | - if( !empty( $sessions )) { |
|
161 | + if( !empty($sessions) ) { |
|
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | 164 | if( $now <= $session->expiration )continue; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function getSessionId( $separator = '' ) |
177 | 177 | { |
178 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
178 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | if( headers_sent() )return; |
208 | 208 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
209 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
210 | 210 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
211 | 211 | } |
212 | 212 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function updateSession() |
226 | 226 | { |
227 | - if( false === get_option( $this->getSessionId() )) { |
|
227 | + if( false === get_option( $this->getSessionId() ) ) { |
|
228 | 228 | $this->createSession(); |
229 | 229 | } |
230 | 230 | else { |
@@ -161,7 +161,9 @@ discard block |
||
161 | 161 | if( !empty( $sessions )) { |
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | - if( $now <= $session->expiration )continue; |
|
164 | + if( $now <= $session->expiration ) { |
|
165 | + continue; |
|
166 | + } |
|
165 | 167 | $expiredSessions[] = $session->name; |
166 | 168 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
167 | 169 | } |
@@ -204,7 +206,9 @@ discard block |
||
204 | 206 | */ |
205 | 207 | protected function setCookie() |
206 | 208 | { |
207 | - if( headers_sent() )return; |
|
209 | + if( headers_sent() ) { |
|
210 | + return; |
|
211 | + } |
|
208 | 212 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | 213 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
210 | 214 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 115 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 116 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -181,7 +183,9 @@ discard block |
||
181 | 183 | if( $value != $fallback ) { |
182 | 184 | return $value; |
183 | 185 | } |
184 | - if( !is_single() && !is_page() )return; |
|
186 | + if( !is_single() && !is_page() ) { |
|
187 | + return; |
|
188 | + } |
|
185 | 189 | switch( $option ) { |
186 | 190 | case 'description': |
187 | 191 | return get_the_excerpt(); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
33 | 33 | $reviews[] = $this->buildReview( $review ); |
34 | 34 | } |
35 | - if( !empty( $reviews )) { |
|
35 | + if( !empty($reviews) ) { |
|
36 | 36 | array_walk( $reviews, function( &$review ) { |
37 | - unset( $review['@context'] ); |
|
38 | - unset( $review['itemReviewed'] ); |
|
37 | + unset($review['@context']); |
|
38 | + unset($review['itemReviewed']); |
|
39 | 39 | }); |
40 | 40 | $schema['review'] = $reviews; |
41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | public function buildReview( $review ) |
50 | 50 | { |
51 | 51 | $schema = SchemaOrg::Review() |
52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
53 | 53 | $schema->name( $review->title ); |
54 | 54 | }) |
55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
56 | 56 | $schema->reviewBody( $review->content ); |
57 | 57 | }) |
58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
59 | 59 | ->author( SchemaOrg::Person() |
60 | 60 | ->name( $review->author ) |
61 | 61 | ) |
62 | 62 | ->itemReviewed( $this->getSchemaType() |
63 | 63 | ->name( $this->getThingName() ) |
64 | 64 | ); |
65 | - if( !empty( $review->rating )) { |
|
65 | + if( !empty($review->rating) ) { |
|
66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
67 | 67 | ->ratingValue( $review->rating ) |
68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function buildSummary( $args = null ) |
80 | 80 | { |
81 | - if( is_array( $args )) { |
|
81 | + if( is_array( $args ) ) { |
|
82 | 82 | $this->args = $args; |
83 | 83 | } |
84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ->image( $this->getThingImage() ) |
91 | 91 | ->url( $this->getThingUrl() ); |
92 | 92 | $count = $this->getReviewCount(); |
93 | - if( !empty( $count )) { |
|
93 | + if( !empty($count) ) { |
|
94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
95 | 95 | ->ratingValue( $this->getRatingValue() ) |
96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas ) )return; |
|
112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
115 | - )); |
|
115 | + ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function store( array $schema ) |
122 | 122 | { |
123 | - $schemas = (array) glsr()->schemas; |
|
123 | + $schemas = (array)glsr()->schemas; |
|
124 | 124 | $schemas[] = $schema; |
125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getReviews( $force = false ) |
149 | 149 | { |
150 | - if( !isset( $this->reviews ) || $force ) { |
|
150 | + if( !isset($this->reviews) || $force ) { |
|
151 | 151 | $args = wp_parse_args( ['count' => -1], $this->args ); |
152 | 152 | $this->reviews = glsr( Database::class )->getReviews( $args )->reviews; |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getSchemaOption( $option, $fallback ) |
163 | 163 | { |
164 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
164 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
165 | 165 | return $schemaOption; |
166 | 166 | } |
167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | // 'is_test' => 1, |
31 | 31 | ]; |
32 | 32 | foreach( $_SERVER as $key => $value ) { |
33 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
33 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] )) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $submission[$key] = $value; |
35 | 37 | } |
36 | 38 | return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
@@ -56,12 +58,16 @@ discard block |
||
56 | 58 | { |
57 | 59 | $query = []; |
58 | 60 | foreach( $data as $key => $value ) { |
59 | - if( is_array( $value ) || is_object( $value ))continue; |
|
61 | + if( is_array( $value ) || is_object( $value )) { |
|
62 | + continue; |
|
63 | + } |
|
60 | 64 | if( $value === false ) { |
61 | 65 | $value = '0'; |
62 | 66 | } |
63 | 67 | $value = trim( $value ); |
64 | - if( !strlen( $value ))continue; |
|
68 | + if( !strlen( $value )) { |
|
69 | + continue; |
|
70 | + } |
|
65 | 71 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
66 | 72 | } |
67 | 73 | return implode( '&', $query ); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | // 'is_test' => 1, |
32 | 32 | ]; |
33 | 33 | foreach( $_SERVER as $key => $value ) { |
34 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
34 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ) )continue; |
|
35 | 35 | $submission[$key] = $value; |
36 | 36 | } |
37 | - return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
|
37 | + return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ) ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | { |
58 | 58 | $query = []; |
59 | 59 | foreach( $data as $key => $value ) { |
60 | - if( is_array( $value ) || is_object( $value ))continue; |
|
60 | + if( is_array( $value ) || is_object( $value ) )continue; |
|
61 | 61 | if( $value === false ) { |
62 | 62 | $value = '0'; |
63 | 63 | } |
64 | 64 | $value = trim( $value ); |
65 | - if( !strlen( $value ))continue; |
|
65 | + if( !strlen( $value ) )continue; |
|
66 | 66 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
67 | 67 | } |
68 | 68 | return implode( '&', $query ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | || !is_callable( ['Akismet', 'get_api_key'] ) |
78 | 78 | || !is_callable( ['Akismet', 'http_post'] ) |
79 | 79 | ? false |
80 | - : (bool) AkismetPlugin::get_api_key(); |
|
80 | + : (bool)AkismetPlugin::get_api_key(); |
|
81 | 81 | return apply_filters( 'site-reviews/akismet/is-active', $check ); |
82 | 82 | } |
83 | 83 | } |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $counts = array_fill_keys( [5,4,3,2,1], [] ); |
64 | 64 | array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
65 | 65 | $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
66 | - if( !isset( $review->rating ))return; |
|
66 | + if( !isset( $review->rating )) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | return $review->rating == $key; |
68 | 70 | })); |
69 | 71 | }); |
@@ -83,7 +85,9 @@ discard block |
||
83 | 85 | public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 ) |
84 | 86 | { |
85 | 87 | $numRatings = count( $upDownRatings ); |
86 | - if( !$numRatings )return 0; |
|
88 | + if( !$numRatings ) { |
|
89 | + return 0; |
|
90 | + } |
|
87 | 91 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 92 | return $value > 0; |
89 | 93 | })); |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | $average = count( $reviews ); |
52 | 52 | if( $average > 0 ) { |
53 | - $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy )); |
|
53 | + $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy ) ); |
|
54 | 54 | } |
55 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews )); |
|
55 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews ) ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getCounts( array $reviews ) |
62 | 62 | { |
63 | - $counts = array_fill_keys( [5,4,3,2,1], [] ); |
|
64 | - array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
|
65 | - $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
|
66 | - if( !isset( $review->rating ))return; |
|
63 | + $counts = array_fill_keys( [5, 4, 3, 2, 1], [] ); |
|
64 | + array_walk( $counts, function( &$count, $key ) use($reviews) { |
|
65 | + $count = count( array_filter( $reviews, function( $review ) use($key) { |
|
66 | + if( !isset($review->rating) )return; |
|
67 | 67 | return $review->rating == $key; |
68 | - })); |
|
68 | + }) ); |
|
69 | 69 | }); |
70 | 70 | return $counts; |
71 | 71 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | if( !$numRatings )return 0; |
87 | 87 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 88 | return $value > 0; |
89 | - })); |
|
89 | + }) ); |
|
90 | 90 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
91 | 91 | $phat = 1 * $positiveRatings / $numRatings; |
92 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
92 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | public function getPercentages( array $reviews ) |
109 | 109 | { |
110 | 110 | $counts = $this->getCounts( $reviews ); |
111 | - array_walk( $counts, function( &$count, $rating ) use( $counts ) { |
|
111 | + array_walk( $counts, function( &$count, $rating ) use($counts) { |
|
112 | 112 | $total = array_sum( $counts ); |
113 | - $count = !empty( $total ) && !empty( $counts[$rating] ) |
|
113 | + $count = !empty($total) && !empty($counts[$rating]) |
|
114 | 114 | ? $counts[$rating] / array_sum( $counts ) * 100 |
115 | 115 | : 0; |
116 | 116 | }); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->getRankingUsingImdb( $reviews ), |
128 | 128 | $reviews, |
129 | 129 | $this |
130 | - )); |
|
130 | + ) ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | $bayesMinimal = 10; // confidence |
158 | 158 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
159 | 159 | // This could also be the average score of all items instead of a fixed value. |
160 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
160 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
161 | 161 | $numOfReviews = count( $reviews ); |
162 | 162 | $avgRating = $this->getAverage( $reviews ); |
163 | 163 | return $avgRating > 0 |
164 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
164 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
165 | 165 | : 0; |
166 | 166 | } |
167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
183 | 183 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
184 | 184 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
185 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
185 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | $remainders = array_column( $percentages, 'remainder' ); |
203 | 203 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
204 | 204 | $i = 0; |
205 | - if( array_sum( array_column( $percentages, 'percent' )) > 0 ) { |
|
206 | - while( array_sum( array_column( $percentages, 'percent' )) < $target ) { |
|
205 | + if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) { |
|
206 | + while( array_sum( array_column( $percentages, 'percent' ) ) < $target ) { |
|
207 | 207 | $percentages[$i]['percent']++; |
208 | 208 | $i++; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | array_multisort( $indexes, SORT_DESC, $percentages ); |
212 | - return array_combine( $indexes, array_column( $percentages, 'percent' )); |
|
212 | + return array_combine( $indexes, array_column( $percentages, 'percent' ) ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
221 | 221 | { |
222 | 222 | return array_reduce( array_keys( $ratingCounts ), |
223 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
223 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
224 | 224 | $ratingLevel = $powerOf2 ? pow( $rating, 2 ) : $rating; |
225 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
225 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
226 | 226 | } |
227 | 227 | ); |
228 | 228 | } |
@@ -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, $prefix = __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; |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | protected function buildQueryAssignedTo( $value ) |
92 | 96 | { |
93 | - if( empty( $value ))return; |
|
97 | + if( empty( $value )) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return [ |
95 | 101 | 'compare' => 'IN', |
96 | 102 | 'key' => 'assigned_to', |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildQueryCategory( $value ) |
106 | 112 | { |
107 | - if( empty( $value ))return; |
|
113 | + if( empty( $value )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | return [ |
109 | 117 | 'field' => 'term_id', |
110 | 118 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildQueryRating( $value ) |
120 | 128 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
129 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | return [ |
123 | 133 | 'compare' => '>=', |
124 | 134 | 'key' => 'rating', |
@@ -132,7 +142,9 @@ discard block |
||
132 | 142 | */ |
133 | 143 | protected function buildQueryType( $value ) |
134 | 144 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
145 | + if( in_array( $value, ['','all'] )) { |
|
146 | + return; |
|
147 | + } |
|
136 | 148 | return [ |
137 | 149 | 'key' => 'review_type', |
138 | 150 | 'value' => $value, |
@@ -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, $prefix = __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 = []; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getPaged( $isEnabled = true ) |
80 | 80 | { |
81 | 81 | $paged = $isEnabled |
82 | - ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR )) |
|
82 | + ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR ) ) |
|
83 | 83 | : 1; |
84 | 84 | return max( 1, $paged ); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function buildQueryAssignedTo( $value ) |
92 | 92 | { |
93 | - if( empty( $value ))return; |
|
93 | + if( empty($value) )return; |
|
94 | 94 | return [ |
95 | 95 | 'compare' => 'IN', |
96 | 96 | 'key' => 'assigned_to', |
97 | - 'value' => array_filter( array_map( 'trim', explode( ',', $value )), 'is_numeric' ), |
|
97 | + 'value' => array_filter( array_map( 'trim', explode( ',', $value ) ), 'is_numeric' ), |
|
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildQueryCategory( $value ) |
106 | 106 | { |
107 | - if( empty( $value ))return; |
|
107 | + if( empty($value) )return; |
|
108 | 108 | return [ |
109 | 109 | 'field' => 'term_id', |
110 | 110 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildQueryRating( $value ) |
120 | 120 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
121 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return; |
|
122 | 122 | return [ |
123 | 123 | 'compare' => '>=', |
124 | 124 | 'key' => 'rating', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function buildQueryType( $value ) |
134 | 134 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
135 | + if( in_array( $value, ['', 'all'] ) )return; |
|
136 | 136 | return [ |
137 | 137 | 'key' => 'review_type', |
138 | 138 | 'value' => $value, |