@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | 'glsr_get_review', 'glsr_get_reviews', |
20 | 20 | 'glsr_log', |
21 | 21 | ); |
22 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
22 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | add_filter( $hook, function() use( $hook, $args ) { |
24 | 26 | array_shift( $args ); // remove the fallback value |
25 | 27 | return call_user_func_array( $hook, $args ); |
@@ -29,7 +31,8 @@ discard block |
||
29 | 31 | /** |
30 | 32 | * @return mixed |
31 | 33 | */ |
32 | -function glsr( $alias = null ) { |
|
34 | +function glsr( $alias = null ) |
|
35 | +{ |
|
33 | 36 | $app = \GeminiLabs\SiteReviews\Application::load(); |
34 | 37 | return !empty( $alias ) |
35 | 38 | ? $app->make( $alias ) |
@@ -41,11 +44,14 @@ discard block |
||
41 | 44 | * @param $column string |
42 | 45 | * @return array |
43 | 46 | */ |
44 | -function glsr_array_column( array $array, $column ) { |
|
47 | +function glsr_array_column( array $array, $column ) |
|
48 | +{ |
|
45 | 49 | $result = array(); |
46 | 50 | foreach( $array as $subarray ) { |
47 | 51 | $subarray = (array)$subarray; |
48 | - if( !isset( $subarray[$column] ))continue; |
|
52 | + if( !isset( $subarray[$column] )) { |
|
53 | + continue; |
|
54 | + } |
|
49 | 55 | $result[] = $subarray[$column]; |
50 | 56 | } |
51 | 57 | return $result; |
@@ -54,7 +60,8 @@ discard block |
||
54 | 60 | /** |
55 | 61 | * @return void |
56 | 62 | */ |
57 | -function glsr_calculate_ratings() { |
|
63 | +function glsr_calculate_ratings() |
|
64 | +{ |
|
58 | 65 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
59 | 66 | glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
60 | 67 | } |
@@ -62,7 +69,8 @@ discard block |
||
62 | 69 | /** |
63 | 70 | * @return \GeminiLabs\SiteReviews\Review|false |
64 | 71 | */ |
65 | -function glsr_create_review( $reviewValues = array() ) { |
|
72 | +function glsr_create_review( $reviewValues = array() ) |
|
73 | +{ |
|
66 | 74 | if( !is_array( $reviewValues )) { |
67 | 75 | $reviewValues = array(); |
68 | 76 | } |
@@ -73,7 +81,8 @@ discard block |
||
73 | 81 | /** |
74 | 82 | * @return \WP_Screen|object |
75 | 83 | */ |
76 | -function glsr_current_screen() { |
|
84 | +function glsr_current_screen() |
|
85 | +{ |
|
77 | 86 | if( function_exists( 'get_current_screen' )) { |
78 | 87 | $screen = get_current_screen(); |
79 | 88 | } |
@@ -86,7 +95,8 @@ discard block |
||
86 | 95 | * @param mixed ...$vars |
87 | 96 | * @return void |
88 | 97 | */ |
89 | -function glsr_debug( ...$vars ) { |
|
98 | +function glsr_debug( ...$vars ) |
|
99 | +{ |
|
90 | 100 | if( count( $vars ) == 1 ) { |
91 | 101 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
92 | 102 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -105,7 +115,8 @@ discard block |
||
105 | 115 | * @param mixed $fallback |
106 | 116 | * @return string|array |
107 | 117 | */ |
108 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
118 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
119 | +{ |
|
109 | 120 | return is_string( $path ) |
110 | 121 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
111 | 122 | : $fallback; |
@@ -114,7 +125,8 @@ discard block |
||
114 | 125 | /** |
115 | 126 | * @return array |
116 | 127 | */ |
117 | -function glsr_get_options() { |
|
128 | +function glsr_get_options() |
|
129 | +{ |
|
118 | 130 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
119 | 131 | } |
120 | 132 | |
@@ -122,7 +134,8 @@ discard block |
||
122 | 134 | * @param int $post_id |
123 | 135 | * @return \GeminiLabs\SiteReviews\Review |
124 | 136 | */ |
125 | -function glsr_get_review( $post_id ) { |
|
137 | +function glsr_get_review( $post_id ) |
|
138 | +{ |
|
126 | 139 | $post = null; |
127 | 140 | if( is_numeric( $post_id )) { |
128 | 141 | $post = get_post( $post_id ); |
@@ -136,7 +149,8 @@ discard block |
||
136 | 149 | /** |
137 | 150 | * @return array |
138 | 151 | */ |
139 | -function glsr_get_reviews( $args = array() ) { |
|
152 | +function glsr_get_reviews( $args = array() ) |
|
153 | +{ |
|
140 | 154 | if( !is_array( $args )) { |
141 | 155 | $args = []; |
142 | 156 | } |
@@ -146,7 +160,8 @@ discard block |
||
146 | 160 | /** |
147 | 161 | * @return \GeminiLabs\SiteReviews\Modules\Console |
148 | 162 | */ |
149 | -function glsr_log() { |
|
163 | +function glsr_log() |
|
164 | +{ |
|
150 | 165 | $args = func_get_args(); |
151 | 166 | $context = isset( $args[1] ) |
152 | 167 | ? $args[1] |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
59 | 59 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
60 | 60 | foreach( $postTypeColumns as $key => &$value ) { |
61 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
61 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
62 | + continue; |
|
63 | + } |
|
62 | 64 | $value = $columns[$key]; |
63 | 65 | } |
64 | 66 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | * @return array |
100 | 102 | * @filter display_post_states |
101 | 103 | */ |
102 | - public function filterPostStates( $postStates, WP_Post $post ) { |
|
104 | + public function filterPostStates( $postStates, WP_Post $post ) |
|
105 | + { |
|
103 | 106 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
104 | 107 | if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
105 | 108 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -147,7 +150,9 @@ discard block |
||
147 | 150 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
148 | 151 | unset( $postTypeColumns['cb'] ); |
149 | 152 | foreach( $postTypeColumns as $key => $value ) { |
150 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
153 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
154 | + continue; |
|
155 | + } |
|
151 | 156 | $columns[$key] = $key; |
152 | 157 | } |
153 | 158 | return $columns; |
@@ -171,7 +176,9 @@ discard block |
||
171 | 176 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
172 | 177 | ]; |
173 | 178 | foreach( $strings as $search => $replace ) { |
174 | - if( strpos( $single, $search ) === false )continue; |
|
179 | + if( strpos( $single, $search ) === false ) { |
|
180 | + continue; |
|
181 | + } |
|
175 | 182 | $translation = $this->getTranslation([ |
176 | 183 | 'number' => $number, |
177 | 184 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -223,7 +230,9 @@ discard block |
||
223 | 230 | */ |
224 | 231 | public function saveBulkEditFields( $postId ) |
225 | 232 | { |
226 | - if( !current_user_can( 'edit_posts' ))return; |
|
233 | + if( !current_user_can( 'edit_posts' )) { |
|
234 | + return; |
|
235 | + } |
|
227 | 236 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
228 | 237 | if( $assignedTo && get_post( $assignedTo )) { |
229 | 238 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -236,7 +245,9 @@ discard block |
||
236 | 245 | */ |
237 | 246 | public function setQueryForColumn( WP_Query $query ) |
238 | 247 | { |
239 | - if( !$this->hasPermission( $query ))return; |
|
248 | + if( !$this->hasPermission( $query )) { |
|
249 | + return; |
|
250 | + } |
|
240 | 251 | $this->setMetaQuery( $query, [ |
241 | 252 | 'rating', 'review_type', |
242 | 253 | ]); |
@@ -308,7 +319,9 @@ discard block |
||
308 | 319 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
309 | 320 | { |
310 | 321 | foreach( $metaKeys as $key ) { |
311 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
322 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
323 | + continue; |
|
324 | + } |
|
312 | 325 | $metaQuery = (array)$query->get( 'meta_query' ); |
313 | 326 | $metaQuery[] = [ |
314 | 327 | 'key' => $key, |