@@ -19,8 +19,8 @@ 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; |
|
23 | - add_filter( $hook, function() use( $hook, $args ) { |
|
22 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return; |
|
23 | + add_filter( $hook, function() use($hook, $args) { |
|
24 | 24 | array_shift( $args ); // remove the fallback value |
25 | 25 | return call_user_func_array( $hook, $args ); |
26 | 26 | }); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function glsr( $alias = null ) { |
33 | 33 | $app = \GeminiLabs\SiteReviews\Application::load(); |
34 | - return !empty( $alias ) |
|
34 | + return !empty($alias) |
|
35 | 35 | ? $app->make( $alias ) |
36 | 36 | : $app; |
37 | 37 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $result = array(); |
46 | 46 | foreach( $array as $subarray ) { |
47 | 47 | $subarray = (array)$subarray; |
48 | - if( !isset( $subarray[$column] ))continue; |
|
48 | + if( !isset($subarray[$column]) )continue; |
|
49 | 49 | $result[] = $subarray[$column]; |
50 | 50 | } |
51 | 51 | return $result; |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function glsr_calculate_ratings() { |
58 | 58 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
59 | - glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
59 | + glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return \GeminiLabs\SiteReviews\Review|false |
64 | 64 | */ |
65 | 65 | function glsr_create_review( $reviewValues = array() ) { |
66 | - if( !is_array( $reviewValues )) { |
|
66 | + if( !is_array( $reviewValues ) ) { |
|
67 | 67 | $reviewValues = array(); |
68 | 68 | } |
69 | 69 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues ); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @return \WP_Screen|object |
75 | 75 | */ |
76 | 76 | function glsr_current_screen() { |
77 | - if( function_exists( 'get_current_screen' )) { |
|
77 | + if( function_exists( 'get_current_screen' ) ) { |
|
78 | 78 | $screen = get_current_screen(); |
79 | 79 | } |
80 | - return empty( $screen ) |
|
80 | + return empty($screen) |
|
81 | 81 | ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
82 | 82 | : $screen; |
83 | 83 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function glsr_get_review( $post_id ) { |
126 | 126 | $post = null; |
127 | - if( is_numeric( $post_id )) { |
|
127 | + if( is_numeric( $post_id ) ) { |
|
128 | 128 | $post = get_post( $post_id ); |
129 | 129 | } |
130 | - if( !( $post instanceof WP_Post )) { |
|
130 | + if( !($post instanceof WP_Post) ) { |
|
131 | 131 | $post = new WP_Post( (object)[] ); |
132 | 132 | } |
133 | 133 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | */ |
139 | 139 | function glsr_get_reviews( $args = array() ) { |
140 | - if( !is_array( $args )) { |
|
140 | + if( !is_array( $args ) ) { |
|
141 | 141 | $args = []; |
142 | 142 | } |
143 | 143 | return glsr( 'Database\ReviewManager' )->get( $args ); |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function glsr_log() { |
150 | 150 | $args = func_get_args(); |
151 | - $context = isset( $args[1] ) |
|
151 | + $context = isset($args[1]) |
|
152 | 152 | ? $args[1] |
153 | 153 | : []; |
154 | 154 | $console = glsr( 'Modules\Console' ); |
155 | - return !empty( $args ) |
|
155 | + return !empty($args) |
|
156 | 156 | ? $console->log( 'debug', $args[0], $context ) |
157 | 157 | : $console; |
158 | 158 | } |
@@ -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] |
@@ -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 | } |
@@ -58,11 +58,11 @@ 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) )continue; |
|
62 | 62 | $value = $columns[$key]; |
63 | 63 | } |
64 | - if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
|
65 | - unset( $postTypeColumns['review_type'] ); |
|
64 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
65 | + unset($postTypeColumns['review_type']); |
|
66 | 66 | } |
67 | 67 | return array_filter( $postTypeColumns, 'strlen' ); |
68 | 68 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function filterPostStates( $postStates, WP_Post $post ) { |
103 | 103 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
104 | - if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
|
104 | + if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) { |
|
105 | 105 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
106 | 106 | } |
107 | 107 | return $postStates; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
118 | 118 | return $actions; |
119 | 119 | } |
120 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
120 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
121 | 121 | $rowActions = [ |
122 | 122 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
123 | 123 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | admin_url( 'post.php?post='.$post->ID.'&action='.$key ), |
132 | 132 | $key.'-review_'.$post->ID |
133 | 133 | ), |
134 | - ]); |
|
134 | + ] ); |
|
135 | 135 | } |
136 | 136 | return $newActions + glsr( Helper::class )->consolidateArray( $actions ); |
137 | 137 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | { |
146 | 146 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
147 | 147 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
148 | - unset( $postTypeColumns['cb'] ); |
|
148 | + unset($postTypeColumns['cb']); |
|
149 | 149 | foreach( $postTypeColumns as $key => $value ) { |
150 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
150 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
151 | 151 | $columns[$key] = $key; |
152 | 152 | } |
153 | 153 | return $columns; |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
167 | 167 | { |
168 | - if( $this->canModifyTranslation( $domain )) { |
|
168 | + if( $this->canModifyTranslation( $domain ) ) { |
|
169 | 169 | $strings = [ |
170 | 170 | 'Published' => __( 'Approved', 'site-reviews' ), |
171 | 171 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
172 | 172 | ]; |
173 | 173 | foreach( $strings as $search => $replace ) { |
174 | 174 | if( strpos( $single, $search ) === false )continue; |
175 | - $translation = $this->getTranslation([ |
|
175 | + $translation = $this->getTranslation( [ |
|
176 | 176 | 'number' => $number, |
177 | 177 | 'plural' => str_replace( $search, $replace, $plural ), |
178 | 178 | 'single' => str_replace( $search, $replace, $single ), |
179 | - ]); |
|
179 | + ] ); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | return $translation; |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function saveBulkEditFields( $postId ) |
225 | 225 | { |
226 | - if( !current_user_can( 'edit_posts' ))return; |
|
226 | + if( !current_user_can( 'edit_posts' ) )return; |
|
227 | 227 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
228 | - if( $assignedTo && get_post( $assignedTo )) { |
|
228 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
229 | 229 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
230 | 230 | } |
231 | 231 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function setQueryForColumn( WP_Query $query ) |
238 | 238 | { |
239 | - if( !$this->hasPermission( $query ))return; |
|
239 | + if( !$this->hasPermission( $query ) )return; |
|
240 | 240 | $this->setMetaQuery( $query, [ |
241 | 241 | 'rating', 'review_type', |
242 | - ]); |
|
242 | + ] ); |
|
243 | 243 | $this->setOrderby( $query ); |
244 | 244 | } |
245 | 245 | |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function unapprove() |
251 | 251 | { |
252 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
253 | - wp_update_post([ |
|
252 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
253 | + wp_update_post( [ |
|
254 | 254 | 'ID' => $postId, |
255 | 255 | 'post_status' => 'pending', |
256 | - ]); |
|
256 | + ] ); |
|
257 | 257 | wp_safe_redirect( wp_get_referer() ); |
258 | 258 | exit; |
259 | 259 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | 'single' => '', |
284 | 284 | 'text' => '', |
285 | 285 | ]; |
286 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
286 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
287 | 287 | $translations = get_translations_for_domain( Application::ID ); |
288 | 288 | return $args->text |
289 | 289 | ? $translations->translate( $args->text ) |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
309 | 309 | { |
310 | 310 | foreach( $metaKeys as $key ) { |
311 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
311 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
312 | 312 | $metaQuery = (array)$query->get( 'meta_query' ); |
313 | 313 | $metaQuery[] = [ |
314 | 314 | 'key' => $key, |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | { |
326 | 326 | $orderby = $query->get( 'orderby' ); |
327 | 327 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
328 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
329 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
328 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
329 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
330 | 330 | $query->set( 'meta_key', $orderby ); |
331 | 331 | $query->set( 'orderby', 'meta_value' ); |
332 | 332 | } |
@@ -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, |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function routerChangeStatus( array $request ) |
24 | 24 | { |
25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | public function routerClearConsole() |
32 | 32 | { |
33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
34 | - wp_send_json_success([ |
|
34 | + wp_send_json_success( [ |
|
35 | 35 | 'console' => glsr( Console::class )->get(), |
36 | 36 | 'notices' => glsr( Notice::class )->get(), |
37 | - ]); |
|
37 | + ] ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | public function routerCountReviews() |
44 | 44 | { |
45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
46 | - wp_send_json_success([ |
|
46 | + wp_send_json_success( [ |
|
47 | 47 | 'notices' => glsr( Notice::class )->get(), |
48 | - ]); |
|
48 | + ] ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | $shortcode = $request['shortcode']; |
57 | 57 | $response = false; |
58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
60 | - if( !empty( $data['errors'] )) { |
|
60 | + if( !empty($data['errors']) ) { |
|
61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
62 | 62 | } |
63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | public function routerFetchConsole() |
78 | 78 | { |
79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
80 | - wp_send_json_success([ |
|
80 | + wp_send_json_success( [ |
|
81 | 81 | 'console' => glsr( Console::class )->get(), |
82 | 82 | 'notices' => glsr( Notice::class )->get(), |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | public function routerSearchPosts( array $request ) |
90 | 90 | { |
91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
92 | - wp_send_json_success([ |
|
92 | + wp_send_json_success( [ |
|
93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
94 | 94 | 'items' => $results, |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function routerSearchTranslations( array $request ) |
102 | 102 | { |
103 | - if( empty( $request['exclude'] )) { |
|
103 | + if( empty($request['exclude']) ) { |
|
104 | 104 | $request['exclude'] = []; |
105 | 105 | } |
106 | 106 | $results = glsr( Translation::class ) |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | ->exclude() |
109 | 109 | ->exclude( $request['exclude'] ) |
110 | 110 | ->renderResults(); |
111 | - wp_send_json_success([ |
|
111 | + wp_send_json_success( [ |
|
112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
113 | 113 | 'items' => $results, |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function routerSubmitReview( array $request ) |
121 | 121 | { |
122 | 122 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
123 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
123 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
124 | 124 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
125 | 125 | $data = [ |
126 | 126 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function routerTogglePinned( array $request ) |
142 | 142 | { |
143 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
144 | - wp_send_json_success([ |
|
143 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
144 | + wp_send_json_success( [ |
|
145 | 145 | 'notices' => glsr( Notice::class )->get(), |
146 | 146 | 'pinned' => $isPinned, |
147 | - ]); |
|
147 | + ] ); |
|
148 | 148 | } |
149 | 149 | } |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | public function filterEnqueuedScripts( $tag, $handle ) |
34 | 34 | { |
35 | 35 | $scripts = [Application::ID.'/google-recaptcha']; |
36 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
36 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
37 | 37 | $tag = str_replace( ' src=', ' async src=', $tag ); |
38 | 38 | } |
39 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
39 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
40 | 40 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
41 | 41 | } |
42 | 42 | return $tag; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function filterFieldOrder( array $config ) |
51 | 51 | { |
52 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
52 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
53 | 53 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
54 | 54 | } |
55 | 55 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | $validated = glsr( ValidateReview::class )->validate( $request ); |
102 | 102 | $command = new CreateReview( $validated->request ); |
103 | - if( empty( $validated->error ) && !$validated->recaptchaIsUnset ) { |
|
103 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
104 | 104 | $this->execute( $command ); |
105 | 105 | } |
106 | 106 | return $command; |