@@ -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 | } |
@@ -54,7 +54,9 @@ 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 )) { |
|
58 | + continue; |
|
59 | + } |
|
58 | 60 | $value = $columns[$key]; |
59 | 61 | } |
60 | 62 | if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
112 | 114 | unset( $postTypeColumns['cb'] ); |
113 | 115 | foreach( $postTypeColumns as $key => $value ) { |
114 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
116 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | $columns[$key] = $key; |
116 | 120 | } |
117 | 121 | return $columns; |
@@ -135,7 +139,9 @@ discard block |
||
135 | 139 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
136 | 140 | ]; |
137 | 141 | foreach( $strings as $search => $replace ) { |
138 | - if( strpos( $single, $search ) === false )continue; |
|
142 | + if( strpos( $single, $search ) === false ) { |
|
143 | + continue; |
|
144 | + } |
|
139 | 145 | $translation = $this->getTranslation([ |
140 | 146 | 'number' => $number, |
141 | 147 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -186,7 +192,9 @@ discard block |
||
186 | 192 | */ |
187 | 193 | public function saveBulkEditFields( $postId ) |
188 | 194 | { |
189 | - if( !current_user_can( 'edit_posts' ))return; |
|
195 | + if( !current_user_can( 'edit_posts' )) { |
|
196 | + return; |
|
197 | + } |
|
190 | 198 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
191 | 199 | if( $assignedTo && get_post( $assignedTo )) { |
192 | 200 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -199,7 +207,9 @@ discard block |
||
199 | 207 | */ |
200 | 208 | public function setQueryForColumn( WP_Query $query ) |
201 | 209 | { |
202 | - if( !$this->hasPermission( $query ))return; |
|
210 | + if( !$this->hasPermission( $query )) { |
|
211 | + return; |
|
212 | + } |
|
203 | 213 | $this->setMetaQuery( $query, [ |
204 | 214 | 'rating', 'review_type', |
205 | 215 | ]); |
@@ -270,7 +280,9 @@ discard block |
||
270 | 280 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
271 | 281 | { |
272 | 282 | foreach( $metaKeys as $key ) { |
273 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
283 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
284 | + continue; |
|
285 | + } |
|
274 | 286 | $metaQuery = (array)$query->get( 'meta_query' ); |
275 | 287 | $metaQuery[] = [ |
276 | 288 | 'key' => $key, |