@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - $postId = wp_update_post([ |
|
15 | + $postId = wp_update_post( [ |
|
16 | 16 | 'ID' => $command->id, |
17 | 17 | 'post_status' => $command->status, |
18 | - ]); |
|
19 | - if( is_wp_error( $postId )) { |
|
18 | + ] ); |
|
19 | + if( is_wp_error( $postId ) ) { |
|
20 | 20 | glsr_log()->error( $postId->get_error_message() ); |
21 | 21 | return []; |
22 | 22 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'href' => get_edit_post_link( $postId ), |
38 | 38 | 'class' => 'row-title', |
39 | 39 | 'title' => __( 'Edit', 'site-reviews' ).' “'.esc_attr( $title ).'”', |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | protected function getPostState( $postId ) |
48 | 48 | { |
49 | 49 | ob_start(); |
50 | - _post_states( get_post( $postId )); |
|
50 | + _post_states( get_post( $postId ) ); |
|
51 | 51 | return ob_get_clean(); |
52 | 52 | } |
53 | 53 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'label' => '['.$tag.']', |
48 | 48 | 'required' => $this->required, |
49 | 49 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | protected function generateFields( array $fields ) |
58 | 58 | { |
59 | 59 | $generatedFields = array_map( function( $field ) { |
60 | - if( empty( $field ))return; |
|
60 | + if( empty($field) )return; |
|
61 | 61 | $field = $this->normalize( $field ); |
62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
62 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
63 | 63 | return $this->$method( $field ); |
64 | 64 | }, $fields ); |
65 | - return array_values( array_filter( $generatedFields )); |
|
65 | + return array_values( array_filter( $generatedFields ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | protected function getFields() |
72 | 72 | { |
73 | 73 | $fields = $this->generateFields( $this->fields() ); |
74 | - if( !empty( $this->errors )) { |
|
74 | + if( !empty($this->errors) ) { |
|
75 | 75 | $errors = []; |
76 | 76 | foreach( $this->required as $name => $alert ) { |
77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
77 | + if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue; |
|
78 | 78 | $errors[] = $this->errors[$name]; |
79 | 79 | } |
80 | 80 | $this->errors = $errors; |
81 | 81 | } |
82 | - return empty( $this->errors ) |
|
82 | + return empty($this->errors) |
|
83 | 83 | ? $fields |
84 | 84 | : $this->errors; |
85 | 85 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return wp_parse_args( $field, [ |
93 | 93 | 'items' => [], |
94 | 94 | 'type' => '', |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'tooltip' => '', |
111 | 111 | 'type' => '', |
112 | 112 | 'value' => '', |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function normalizeContainer( array $field ) |
120 | 120 | { |
121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
121 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
122 | 122 | $field['items'] = $this->generateFields( $field['items'] ); |
123 | 123 | return $field; |
124 | 124 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function normalizeField( array $field, array $defaults ) |
130 | 130 | { |
131 | - if( !$this->validate( $field ))return; |
|
131 | + if( !$this->validate( $field ) )return; |
|
132 | 132 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
133 | 133 | return $value !== ''; |
134 | 134 | }); |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | 'tooltip' => '', |
149 | 149 | 'type' => '', |
150 | 150 | 'value' => '', |
151 | - ]); |
|
152 | - if( !is_array( $listbox ))return; |
|
153 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
151 | + ] ); |
|
152 | + if( !is_array( $listbox ) )return; |
|
153 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
154 | 154 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
155 | 155 | } |
156 | 156 | foreach( $listbox['options'] as $value => $text ) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function normalizePost( array $field ) |
169 | 169 | { |
170 | - if( !is_array( $field['query_args'] )) { |
|
170 | + if( !is_array( $field['query_args'] ) ) { |
|
171 | 171 | $field['query_args'] = []; |
172 | 172 | } |
173 | 173 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | 'orderby' => 'title', |
176 | 176 | 'post_type' => 'post', |
177 | 177 | 'posts_per_page' => 30, |
178 | - ])); |
|
179 | - if( !empty( $posts )) { |
|
178 | + ] ) ); |
|
179 | + if( !empty($posts) ) { |
|
180 | 180 | $options = []; |
181 | 181 | foreach( $posts as $post ) { |
182 | 182 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'tooltip' => '', |
207 | 207 | 'type' => '', |
208 | 208 | 'value' => '', |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function validate( array $field ) |
216 | 216 | { |
217 | - $args = shortcode_atts([ |
|
217 | + $args = shortcode_atts( [ |
|
218 | 218 | 'label' => '', |
219 | 219 | 'name' => false, |
220 | 220 | 'required' => false, |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function validateErrors( array $args ) |
232 | 232 | { |
233 | - if( !isset( $args['required']['error'] )) { |
|
233 | + if( !isset($args['required']['error']) ) { |
|
234 | 234 | return true; |
235 | 235 | } |
236 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
236 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
237 | 237 | 'html' => $args['required']['error'], |
238 | 238 | 'type' => 'container', |
239 | - ]); |
|
239 | + ] ); |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | return true; |
250 | 250 | } |
251 | 251 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
252 | - if( isset( $args['required']['alert'] )) { |
|
252 | + if( isset($args['required']['alert']) ) { |
|
253 | 253 | $alert = $args['required']['alert']; |
254 | 254 | } |
255 | - else if( !empty( $args['label'] )) { |
|
255 | + else if( !empty($args['label']) ) { |
|
256 | 256 | $alert = sprintf( |
257 | 257 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
258 | 258 | str_replace( ':', '', $args['label'] ) |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | foreach( $this->rules as $attribute => $rules ) { |
74 | 74 | foreach( $rules as $rule ) { |
75 | 75 | $this->validateAttribute( $attribute, $rule ); |
76 | - if( $this->shouldStopValidating( $attribute ))break; |
|
76 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | return $this->errors; |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function validateAttribute( $attribute, $rule ) |
90 | 90 | { |
91 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
91 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
92 | 92 | if( $rule == '' )return; |
93 | 93 | $value = $this->getValue( $attribute ); |
94 | 94 | $this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules ); |
95 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
95 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
96 | 96 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
97 | 97 | } |
98 | - if( !$this->$method( $attribute, $value, $parameters )) { |
|
98 | + if( !$this->$method( $attribute, $value, $parameters ) ) { |
|
99 | 99 | $this->addFailure( $attribute, $rule, $parameters ); |
100 | 100 | } |
101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | $message = $this->getMessage( $attribute, $rule, $parameters ); |
112 | 112 | $this->errors[$attribute]['errors'][] = $message; |
113 | - if( !isset( $this->errors[$attribute]['value'] )) { |
|
113 | + if( !isset($this->errors[$attribute]['value']) ) { |
|
114 | 114 | $this->errors[$attribute]['value'] = $this->getValue( $attribute ); |
115 | 115 | } |
116 | 116 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getMessage( $attribute, $rule, array $parameters ) |
149 | 149 | { |
150 | - if( in_array( $rule, $this->sizeRules )) { |
|
150 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
151 | 151 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
152 | 152 | } |
153 | 153 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getRule( $attribute, $rules ) |
164 | 164 | { |
165 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
166 | - $rules = (array) $rules; |
|
165 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
166 | + $rules = (array)$rules; |
|
167 | 167 | foreach( $this->rules[$attribute] as $rule ) { |
168 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
169 | - if( in_array( $rule, $rules )) { |
|
168 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
169 | + if( in_array( $rule, $rules ) ) { |
|
170 | 170 | return [$rule, $parameters]; |
171 | 171 | } |
172 | 172 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if( is_numeric( $value ) && $hasNumeric ) { |
185 | 185 | return $value; |
186 | 186 | } |
187 | - elseif( is_array( $value )) { |
|
187 | + elseif( is_array( $value ) ) { |
|
188 | 188 | return count( $value ); |
189 | 189 | } |
190 | 190 | return mb_strlen( $value ); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | protected function getValue( $attribute ) |
213 | 213 | { |
214 | - if( isset( $this->data[$attribute] )) { |
|
214 | + if( isset($this->data[$attribute]) ) { |
|
215 | 215 | return $this->data[$attribute]; |
216 | 216 | } |
217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function hasRule( $attribute, $rules ) |
226 | 226 | { |
227 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
227 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | $parameters = []; |
265 | 265 | // example: {rule}:{parameters} |
266 | 266 | if( strpos( $rule, ':' ) !== false ) { |
267 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
267 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
268 | 268 | // example: {parameter1,parameter2,...} |
269 | 269 | $parameters = $this->parseParameters( $rule, $parameter ); |
270 | 270 | } |
271 | - $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ))); |
|
271 | + $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) ); |
|
272 | 272 | $rule = str_replace( ' ', '', $rule ); |
273 | 273 | return [$rule, $parameters]; |
274 | 274 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | protected function shouldStopValidating( $attribute ) |
297 | 297 | { |
298 | 298 | return $this->hasRule( $attribute, $this->implicitRules ) |
299 | - && isset( $this->failedRules[$attribute] ) |
|
299 | + && isset($this->failedRules[$attribute]) |
|
300 | 300 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
301 | 301 | } |
302 | 302 | |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | 'regex' => _x( 'The :attribute format is invalid.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ), |
322 | 322 | 'required' => _x( 'The :attribute field is required.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ), |
323 | 323 | ]; |
324 | - $message = isset( $strings[$key] ) |
|
324 | + $message = isset($strings[$key]) |
|
325 | 325 | ? $strings[$key] |
326 | 326 | : false; |
327 | 327 | if( !$message )return; |
328 | 328 | $message = str_replace( ':attribute', $attribute, $message ); |
329 | - if( method_exists( $this, $replacer = 'replace'.$rule )) { |
|
329 | + if( method_exists( $this, $replacer = 'replace'.$rule ) ) { |
|
330 | 330 | $message = $this->$replacer( $message, $parameters ); |
331 | 331 | } |
332 | 332 | return $message; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | 33 | if( $diff > $timePeriod[0] )continue; |
34 | - $unit = intval( floor( $diff / $timePeriod[1] )); |
|
34 | + $unit = intval( floor( $diff / $timePeriod[1] ) ); |
|
35 | 35 | $relativeDates = [ |
36 | 36 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
37 | 37 | _n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ), |
@@ -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 { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function renderFilters( $postType ) |
16 | 16 | { |
17 | 17 | if( $postType !== Application::POST_TYPE )return; |
18 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
18 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
19 | 19 | $status = 'publish'; |
20 | 20 | } |
21 | 21 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | protected function buildColumnAssignedTo( $postId ) |
46 | 46 | { |
47 | 47 | $post = get_post( glsr( Database::class )->getReviewMeta( $postId )->assigned_to ); |
48 | - if( !( $post instanceof WP_Post ) || $post->post_status != 'publish' ) { |
|
48 | + if( !($post instanceof WP_Post) || $post->post_status != 'publish' ) { |
|
49 | 49 | return '—'; |
50 | 50 | } |
51 | 51 | return glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
52 | 52 | 'href' => (string)get_the_permalink( $post->ID ), |
53 | - ]); |
|
53 | + ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | return glsr( Html::class )->buildPartial( 'star-rating', [ |
72 | 72 | 'rating' => glsr( Database::class )->getReviewMeta( $postId )->rating, |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $pinned = glsr( Database::class )->getReviewMeta( $postId )->pinned |
83 | 83 | ? ' pinned' |
84 | 84 | : ''; |
85 | - return glsr( Builder::class )->i([ |
|
85 | + return glsr( Builder::class )->i( [ |
|
86 | 86 | 'class' => trim( 'dashicons dashicons-sticky '.$pinned ), |
87 | 87 | 'data-id' => $postId, |
88 | - ]); |
|
88 | + ] ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | protected function buildColumnType( $postId ) |
96 | 96 | { |
97 | 97 | $reviewMeta = glsr( Database::class )->getReviewMeta( $postId ); |
98 | - return isset( glsr()->reviewTypes[$reviewMeta->review_type] ) |
|
98 | + return isset(glsr()->reviewTypes[$reviewMeta->review_type]) |
|
99 | 99 | ? glsr()->reviewTypes[$reviewMeta->review_type] |
100 | 100 | : $reviewMeta->review_type; |
101 | 101 | } |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function renderFilterRatings( $ratings ) |
108 | 108 | { |
109 | - if( empty( $ratings ) |
|
109 | + if( empty($ratings) |
|
110 | 110 | || apply_filters( 'site-reviews/disable/filter/ratings', false ) |
111 | 111 | )return; |
112 | - $ratings = array_flip( array_reverse( $ratings )); |
|
112 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
113 | 113 | array_walk( $ratings, function( &$value, $key ) { |
114 | 114 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
115 | 115 | $value = sprintf( $label, $key ); |
116 | 116 | }); |
117 | 117 | $ratings = [__( 'All ratings', 'site-reviews' )] + $ratings; |
118 | - printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' )); |
|
118 | + printf( '<label class="screen-reader-text" for="rating">%s</label>', __( 'Filter by rating', 'site-reviews' ) ); |
|
119 | 119 | glsr( Html::class )->renderPartial( 'filterby', [ |
120 | 120 | 'name' => 'rating', |
121 | 121 | 'values' => $ratings, |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | { |
131 | 131 | if( count( glsr()->reviewTypes ) < 2 )return; |
132 | 132 | $reviewTypes = ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes; |
133 | - printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' )); |
|
133 | + printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' ) ); |
|
134 | 134 | glsr( Html::class )->renderPartial( 'filterby', [ |
135 | 135 | 'name' => 'review_type', |
136 | 136 | 'options' => $reviewTypes, |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | } |
139 | 139 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | natsort( $routines ); |
17 | 17 | array_walk( $routines, function( $routine ) { |
18 | 18 | $version = str_replace( strtolower( __CLASS__ ).'_', '', $routine ); |
19 | - if( version_compare( glsr()->version, $version, '>=' ))return; |
|
19 | + if( version_compare( glsr()->version, $version, '>=' ) )return; |
|
20 | 20 | call_user_func( [$this, $routine] ); |
21 | 21 | }); |
22 | 22 | $this->updateVersion(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function updateVersion() |
29 | 29 | { |
30 | 30 | $currentVersion = glsr( OptionManager::class )->get( 'version' ); |
31 | - if( version_compare( $currentVersion, glsr()->version, '<' )) { |
|
31 | + if( version_compare( $currentVersion, glsr()->version, '<' ) ) { |
|
32 | 32 | glsr( OptionManager::class )->set( 'version', glsr()->version ); |
33 | 33 | } |
34 | 34 | if( $currentVersion != glsr()->version ) { |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function approve() |
23 | 23 | { |
24 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
25 | - wp_update_post([ |
|
24 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
25 | + wp_update_post( [ |
|
26 | 26 | 'ID' => $postId, |
27 | 27 | 'post_status' => 'publish', |
28 | - ]); |
|
28 | + ] ); |
|
29 | 29 | wp_safe_redirect( wp_get_referer() ); |
30 | 30 | exit; |
31 | 31 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | { |
55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
57 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
58 | 58 | $value = $columns[$key]; |
59 | 59 | } |
60 | - if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
|
61 | - unset( $postTypeColumns['review_type'] ); |
|
60 | + if( count( glsr( Database::class )->getReviewsMeta( 'type' ) ) < 2 ) { |
|
61 | + unset($postTypeColumns['review_type']); |
|
62 | 62 | } |
63 | 63 | return array_filter( $postTypeColumns, 'strlen' ); |
64 | 64 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
85 | 85 | return $actions; |
86 | 86 | } |
87 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
87 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
88 | 88 | $rowActions = [ |
89 | 89 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
90 | 90 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | admin_url( 'post.php?post='.$post->ID.'&action='.$key ), |
98 | 98 | $key.'-review_'.$post->ID |
99 | 99 | ), |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | } |
102 | 102 | return $actions; |
103 | 103 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | public function filterSortableColumns( array $columns ) |
110 | 110 | { |
111 | 111 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
112 | - unset( $postTypeColumns['cb'] ); |
|
112 | + unset($postTypeColumns['cb']); |
|
113 | 113 | foreach( $postTypeColumns as $key => $value ) { |
114 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
114 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
115 | 115 | $columns[$key] = $key; |
116 | 116 | } |
117 | 117 | return $columns; |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
131 | 131 | { |
132 | - if( $this->canModifyTranslation( $domain )) { |
|
132 | + if( $this->canModifyTranslation( $domain ) ) { |
|
133 | 133 | $strings = [ |
134 | 134 | 'Published' => __( 'Approved', 'site-reviews' ), |
135 | 135 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
136 | 136 | ]; |
137 | 137 | foreach( $strings as $search => $replace ) { |
138 | 138 | if( strpos( $single, $search ) === false )continue; |
139 | - $translation = $this->getTranslation([ |
|
139 | + $translation = $this->getTranslation( [ |
|
140 | 140 | 'number' => $number, |
141 | 141 | 'plural' => str_replace( $search, $replace, $plural ), |
142 | 142 | 'single' => str_replace( $search, $replace, $single ), |
143 | - ]); |
|
143 | + ] ); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | return $translation; |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function saveBulkEditFields( $postId ) |
188 | 188 | { |
189 | - if( !current_user_can( 'edit_posts' ))return; |
|
189 | + if( !current_user_can( 'edit_posts' ) )return; |
|
190 | 190 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
191 | - if( $assignedTo && get_post( $assignedTo )) { |
|
191 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
192 | 192 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
193 | 193 | } |
194 | 194 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function setQueryForColumn( WP_Query $query ) |
201 | 201 | { |
202 | - if( !$this->hasPermission( $query ))return; |
|
202 | + if( !$this->hasPermission( $query ) )return; |
|
203 | 203 | $this->setMetaQuery( $query, [ |
204 | 204 | 'rating', 'review_type', |
205 | - ]); |
|
205 | + ] ); |
|
206 | 206 | $this->setOrderby( $query ); |
207 | 207 | } |
208 | 208 | |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function unapprove() |
214 | 214 | { |
215 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
216 | - wp_update_post([ |
|
215 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
216 | + wp_update_post( [ |
|
217 | 217 | 'ID' => $postId, |
218 | 218 | 'post_status' => 'pending', |
219 | - ]); |
|
219 | + ] ); |
|
220 | 220 | wp_safe_redirect( wp_get_referer() ); |
221 | 221 | exit; |
222 | 222 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'single' => '', |
246 | 246 | 'text' => '', |
247 | 247 | ]; |
248 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
248 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
249 | 249 | $translations = get_translations_for_domain( Application::ID ); |
250 | 250 | return $args->text |
251 | 251 | ? $translations->translate( $args->text ) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
271 | 271 | { |
272 | 272 | foreach( $metaKeys as $key ) { |
273 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
273 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
274 | 274 | $metaQuery = (array)$query->get( 'meta_query' ); |
275 | 275 | $metaQuery[] = [ |
276 | 276 | 'key' => $key, |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | { |
288 | 288 | $orderby = $query->get( 'orderby' ); |
289 | 289 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
290 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
291 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
290 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
291 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
292 | 292 | $query->set( 'meta_key', $orderby ); |
293 | 293 | $query->set( 'orderby', 'meta_value' ); |
294 | 294 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
18 | 18 | 'published' => __( 'Approved', 'site-reviews' ), |
19 | 19 | ]; |
20 | - if( $this->canModifyTranslation() && isset( $wp_scripts->registered['post']->extra['data'] )) { |
|
20 | + if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) { |
|
21 | 21 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
22 | 22 | foreach( $strings as $search => $replace ) { |
23 | 23 | $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', "$1".$replace, $l10n ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function filterPostStatusLabels( $translation, $text, $domain ) |
35 | 35 | { |
36 | - if( $this->canModifyTranslation( $domain )) { |
|
36 | + if( $this->canModifyTranslation( $domain ) ) { |
|
37 | 37 | $replacements = [ |
38 | 38 | 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
39 | 39 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | public function filterUpdateMessages( array $messages ) |
56 | 56 | { |
57 | 57 | $post = get_post(); |
58 | - if( !( $post instanceof WP_Post ))return; |
|
58 | + if( !($post instanceof WP_Post) )return; |
|
59 | 59 | $strings = $this->getReviewLabels(); |
60 | 60 | $restored = filter_input( INPUT_GET, 'revision' ); |
61 | - if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
|
61 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
62 | 62 | $restored = sprintf( $strings['restored'], $revisionTitle ); |
63 | 63 | } |
64 | - $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date )); |
|
65 | - $messages[ Application::POST_TYPE ] = [ |
|
64 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
65 | + $messages[Application::POST_TYPE] = [ |
|
66 | 66 | 1 => $strings['updated'], |
67 | 67 | 4 => $strings['updated'], |
68 | 68 | 5 => $restored, |