@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | defined( 'WPINC' ) || die; |
20 | 20 | |
21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | 24 | if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
@@ -27,6 +27,6 @@ discard block |
||
27 | 27 | |
28 | 28 | $app = new GeminiLabs\SiteReviews\Application; |
29 | 29 | $app->make( 'Provider' )->register( $app ); |
30 | -register_activation_hook( __FILE__, array( $app, 'activate' )); |
|
31 | -register_deactivation_hook( __FILE__, array( $app, 'deactivate' )); |
|
30 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
31 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
32 | 32 | $app->init(); |
@@ -21,7 +21,9 @@ |
||
21 | 21 | if( !class_exists( 'GL_Plugin_Check_v3' )) { |
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | -if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
|
24 | +if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() ) { |
|
25 | + return; |
|
26 | +} |
|
25 | 27 | require_once __DIR__.'/autoload.php'; |
26 | 28 | require_once __DIR__.'/compatibility.php'; |
27 | 29 | require_once __DIR__.'/helpers.php'; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $this->errors = $args['errors']; |
22 | 22 | return glsr( Builder::class )->div( wpautop( $args['message'] ), [ |
23 | 23 | 'class' => $this->getClass(), |
24 | - ]); |
|
24 | + ] ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getClass() |
31 | 31 | { |
32 | - $errorClass = !empty( $this->errors ) |
|
32 | + $errorClass = !empty($this->errors) |
|
33 | 33 | ? 'glsr-has-errors' |
34 | 34 | : ''; |
35 | 35 | return trim( 'glsr-form-messages '.$errorClass ); |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = $this->getRequest(); |
19 | - if( !$this->isValidPostRequest( $request ))return; |
|
19 | + if( !$this->isValidPostRequest( $request )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | check_admin_referer( $request['action'] ); |
21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 24 | } |
@@ -38,10 +40,16 @@ discard block |
||
38 | 40 | */ |
39 | 41 | public function routePublicPostRequest() |
40 | 42 | { |
41 | - if( is_admin() )return; |
|
43 | + if( is_admin() ) { |
|
44 | + return; |
|
45 | + } |
|
42 | 46 | $request = $this->getRequest(); |
43 | - if( !$this->isValidPostRequest( $request ))return; |
|
44 | - if( !$this->isValidPublicNonce( $request ))return; |
|
47 | + if( !$this->isValidPostRequest( $request )) { |
|
48 | + return; |
|
49 | + } |
|
50 | + if( !$this->isValidPublicNonce( $request )) { |
|
51 | + return; |
|
52 | + } |
|
45 | 53 | $this->routeRequest( 'public', $request['action'], $request ); |
46 | 54 | } |
47 | 55 | |
@@ -50,7 +58,9 @@ discard block |
||
50 | 58 | */ |
51 | 59 | protected function checkAjaxNonce( array $request ) |
52 | 60 | { |
53 | - if( !is_user_logged_in() )return; |
|
61 | + if( !is_user_logged_in() ) { |
|
62 | + return; |
|
63 | + } |
|
54 | 64 | if( !isset( $request['nonce'] )) { |
55 | 65 | $this->sendAjaxError( 'The request is missing a nonce', $request ); |
56 | 66 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = $this->getRequest(); |
19 | - if( !$this->isValidPostRequest( $request ))return; |
|
19 | + if( !$this->isValidPostRequest( $request ) )return; |
|
20 | 20 | check_admin_referer( $request['action'] ); |
21 | 21 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 22 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | { |
41 | 41 | if( is_admin() )return; |
42 | 42 | $request = $this->getRequest(); |
43 | - if( !$this->isValidPostRequest( $request ))return; |
|
44 | - if( !$this->isValidPublicNonce( $request ))return; |
|
43 | + if( !$this->isValidPostRequest( $request ) )return; |
|
44 | + if( !$this->isValidPublicNonce( $request ) )return; |
|
45 | 45 | $this->routeRequest( 'public', $request['action'], $request ); |
46 | 46 | } |
47 | 47 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | protected function checkAjaxNonce( array $request ) |
52 | 52 | { |
53 | 53 | if( !is_user_logged_in() )return; |
54 | - if( !isset( $request['nonce'] )) { |
|
54 | + if( !isset($request['nonce']) ) { |
|
55 | 55 | $this->sendAjaxError( 'The request is missing a nonce', $request ); |
56 | 56 | } |
57 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
57 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
58 | 58 | $this->sendAjaxError( 'The request failed the nonce check', $request, 403 ); |
59 | 59 | } |
60 | 60 | } |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected function checkAjaxRequest( array $request ) |
66 | 66 | { |
67 | - if( !isset( $request['action'] )) { |
|
67 | + if( !isset($request['action']) ) { |
|
68 | 68 | $this->sendAjaxError( 'The request must include an action', $request ); |
69 | 69 | } |
70 | - if( empty( $request['ajax_request'] )) { |
|
70 | + if( empty($request['ajax_request']) ) { |
|
71 | 71 | $this->sendAjaxError( 'The request is invalid', $request ); |
72 | 72 | } |
73 | 73 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return glsr( Helper::class )->filterInputArray( Application::ID ); |
85 | 85 | } |
86 | 86 | $request = glsr( Helper::class )->filterInputArray( 'request' ); |
87 | - if( empty( $request )) { |
|
87 | + if( empty($request) ) { |
|
88 | 88 | $request = glsr( Helper::class )->filterInputArray( Application::ID ); |
89 | 89 | } |
90 | 90 | return $this->normalizeRequest( $request ); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function isValidPostRequest( array $request = [] ) |
97 | 97 | { |
98 | - return !empty( $request['action'] ) && empty( $request['ajax_request'] ); |
|
98 | + return !empty($request['action']) && empty($request['ajax_request']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function isValidPublicNonce( array $request ) |
105 | 105 | { |
106 | - if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
106 | + if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
107 | 107 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
108 | 108 | return false; |
109 | 109 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | protected function routeRequest( $type, $action, array $request = [] ) |
133 | 133 | { |
134 | 134 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
135 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
135 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
136 | 136 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
137 | 137 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
138 | 138 | do_action( $actionHook, $action, $request ); |
139 | - if( is_callable( [$controller, $method] )) { |
|
139 | + if( is_callable( [$controller, $method] ) ) { |
|
140 | 140 | call_user_func( [$controller, $method], $request ); |
141 | 141 | return; |
142 | 142 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | protected function sendAjaxError( $error, array $request, $statusCode = 400 ) |
154 | 154 | { |
155 | 155 | glsr_log()->error( $error )->info( $request ); |
156 | - wp_send_json_error([ |
|
156 | + wp_send_json_error( [ |
|
157 | 157 | 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
158 | 158 | 'error' => $error, |
159 | 159 | ], $statusCode ); |
@@ -9,5 +9,5 @@ |
||
9 | 9 | */ |
10 | 10 | add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) { |
11 | 11 | $scriptHandles[] = 'site-reviews/google-recaptcha'; |
12 | - return array_keys( array_flip( $scriptHandles )); |
|
12 | + return array_keys( array_flip( $scriptHandles ) ); |
|
13 | 13 | }); |
@@ -83,7 +83,9 @@ discard block |
||
83 | 83 | $reviewValues = []; |
84 | 84 | foreach( $review as $key => $value ) { |
85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
86 | - if( !method_exists( $this, $method ))continue; |
|
86 | + if( !method_exists( $this, $method )) { |
|
87 | + continue; |
|
88 | + } |
|
87 | 89 | $reviewValues[$key] = $this->$method( $key, $value ); |
88 | 90 | } |
89 | 91 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -97,9 +99,13 @@ discard block |
||
97 | 99 | */ |
98 | 100 | protected function buildOptionAssignedTo( $key, $value ) |
99 | 101 | { |
100 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
102 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
103 | + return; |
|
104 | + } |
|
101 | 105 | $post = get_post( intval( $value )); |
102 | - if( !( $post instanceof WP_Post ))return; |
|
106 | + if( !( $post instanceof WP_Post )) { |
|
107 | + return; |
|
108 | + } |
|
103 | 109 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
104 | 110 | 'href' => get_the_permalink( $post->ID ), |
105 | 111 | ]); |
@@ -114,7 +120,9 @@ discard block |
||
114 | 120 | */ |
115 | 121 | protected function buildOptionAuthor( $key, $value ) |
116 | 122 | { |
117 | - if( $this->isHidden( $key ))return; |
|
123 | + if( $this->isHidden( $key )) { |
|
124 | + return; |
|
125 | + } |
|
118 | 126 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
119 | 127 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
120 | 128 | : ''; |
@@ -128,7 +136,9 @@ discard block |
||
128 | 136 | */ |
129 | 137 | protected function buildOptionAvatar( $key, $value ) |
130 | 138 | { |
131 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
139 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
140 | + return; |
|
141 | + } |
|
132 | 142 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
133 | 143 | return $this->wrap( $key, glsr( Builder::class )->img([ |
134 | 144 | 'src' => $this->generateAvatar( $value ), |
@@ -145,7 +155,9 @@ discard block |
||
145 | 155 | protected function buildOptionContent( $key, $value ) |
146 | 156 | { |
147 | 157 | $text = $this->normalizeText( $value ); |
148 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
158 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
159 | + return; |
|
160 | + } |
|
149 | 161 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
150 | 162 | } |
151 | 163 | |
@@ -156,7 +168,9 @@ discard block |
||
156 | 168 | */ |
157 | 169 | protected function buildOptionDate( $key, $value ) |
158 | 170 | { |
159 | - if( $this->isHidden( $key ))return; |
|
171 | + if( $this->isHidden( $key )) { |
|
172 | + return; |
|
173 | + } |
|
160 | 174 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
161 | 175 | if( $dateFormat == 'relative' ) { |
162 | 176 | $date = glsr( Date::class )->relative( $value ); |
@@ -177,7 +191,9 @@ discard block |
||
177 | 191 | */ |
178 | 192 | protected function buildOptionRating( $key, $value ) |
179 | 193 | { |
180 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
194 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
195 | + return; |
|
196 | + } |
|
181 | 197 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
182 | 198 | 'rating' => $value, |
183 | 199 | ]); |
@@ -191,7 +207,9 @@ discard block |
||
191 | 207 | */ |
192 | 208 | protected function buildOptionResponse( $key, $value ) |
193 | 209 | { |
194 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
210 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
211 | + return; |
|
212 | + } |
|
195 | 213 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
196 | 214 | $text = $this->normalizeText( $value ); |
197 | 215 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -208,7 +226,9 @@ discard block |
||
208 | 226 | */ |
209 | 227 | protected function buildOptionTitle( $key, $value ) |
210 | 228 | { |
211 | - if( $this->isHidden( $key ))return; |
|
229 | + if( $this->isHidden( $key )) { |
|
230 | + return; |
|
231 | + } |
|
212 | 232 | if( empty( $value )) { |
213 | 233 | $value = __( 'No Title', 'site-reviews' ); |
214 | 234 | } |
@@ -238,7 +258,9 @@ discard block |
||
238 | 258 | */ |
239 | 259 | protected function generateSchema() |
240 | 260 | { |
241 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
261 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
262 | + return; |
|
263 | + } |
|
242 | 264 | glsr( Schema::class )->store( |
243 | 265 | glsr( Schema::class )->build( $this->args ) |
244 | 266 | ); |
@@ -289,9 +311,13 @@ discard block |
||
289 | 311 | $words->setText( $text ); |
290 | 312 | $count = 0; |
291 | 313 | foreach( $words as $offset ){ |
292 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
314 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
315 | + continue; |
|
316 | + } |
|
293 | 317 | $count++; |
294 | - if( $count != $limit )continue; |
|
318 | + if( $count != $limit ) { |
|
319 | + continue; |
|
320 | + } |
|
295 | 321 | return $offset; |
296 | 322 | } |
297 | 323 | return strlen( $text ); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'navigation' => $navigation, |
58 | 58 | ], |
59 | 59 | 'reviews' => $this->buildReviews(), |
60 | - ]); |
|
60 | + ] ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $reviewValues = []; |
84 | 84 | foreach( $review as $key => $value ) { |
85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
86 | - if( !method_exists( $this, $method ))continue; |
|
86 | + if( !method_exists( $this, $method ) )continue; |
|
87 | 87 | $reviewValues[$key] = $this->$method( $key, $value ); |
88 | 88 | } |
89 | 89 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function buildOptionAssignedTo( $key, $value ) |
99 | 99 | { |
100 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
101 | - $post = get_post( intval( $value )); |
|
102 | - if( !( $post instanceof WP_Post ))return; |
|
100 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return; |
|
101 | + $post = get_post( intval( $value ) ); |
|
102 | + if( !($post instanceof WP_Post) )return; |
|
103 | 103 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
104 | 104 | 'href' => get_the_permalink( $post->ID ), |
105 | - ]); |
|
105 | + ] ); |
|
106 | 106 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
107 | 107 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function buildOptionAuthor( $key, $value ) |
116 | 116 | { |
117 | - if( $this->isHidden( $key ))return; |
|
117 | + if( $this->isHidden( $key ) )return; |
|
118 | 118 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
119 | 119 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
120 | 120 | : ''; |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function buildOptionAvatar( $key, $value ) |
130 | 130 | { |
131 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
131 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return; |
|
132 | 132 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
133 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
133 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
134 | 134 | 'src' => $this->generateAvatar( $value ), |
135 | 135 | 'height' => $size, |
136 | 136 | 'width' => $size, |
137 | - ])); |
|
137 | + ] ) ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | protected function buildOptionContent( $key, $value ) |
146 | 146 | { |
147 | 147 | $text = $this->normalizeText( $value ); |
148 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
148 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
149 | 149 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
150 | 150 | } |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function buildOptionDate( $key, $value ) |
158 | 158 | { |
159 | - if( $this->isHidden( $key ))return; |
|
159 | + if( $this->isHidden( $key ) )return; |
|
160 | 160 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
161 | 161 | if( $dateFormat == 'relative' ) { |
162 | 162 | $date = glsr( Date::class )->relative( $value ); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $format = $dateFormat == 'custom' |
166 | 166 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
167 | 167 | : (string)get_option( 'date_format' ); |
168 | - $date = date_i18n( $format, strtotime( $value )); |
|
168 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
169 | 169 | } |
170 | 170 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
171 | 171 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function buildOptionRating( $key, $value ) |
179 | 179 | { |
180 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
180 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
181 | 181 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
182 | 182 | 'rating' => $value, |
183 | - ]); |
|
183 | + ] ); |
|
184 | 184 | return $this->wrap( $key, $rating ); |
185 | 185 | } |
186 | 186 | |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected function buildOptionResponse( $key, $value ) |
193 | 193 | { |
194 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
195 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
194 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
195 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
196 | 196 | $text = $this->normalizeText( $value ); |
197 | 197 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
198 | 198 | return $this->wrap( $key, |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function buildOptionTitle( $key, $value ) |
210 | 210 | { |
211 | - if( $this->isHidden( $key ))return; |
|
212 | - if( empty( $value )) { |
|
211 | + if( $this->isHidden( $key ) )return; |
|
212 | + if( empty($value) ) { |
|
213 | 213 | $value = __( 'No Title', 'site-reviews' ); |
214 | 214 | } |
215 | 215 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | return $avatarUrl; |
228 | 228 | } |
229 | 229 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
230 | - if( empty( $authorIdOrEmail )) { |
|
230 | + if( empty($authorIdOrEmail) ) { |
|
231 | 231 | $authorIdOrEmail = $review->email; |
232 | 232 | } |
233 | 233 | return (string)get_avatar_url( $authorIdOrEmail ); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function generateSchema() |
240 | 240 | { |
241 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
241 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
242 | 242 | glsr( Schema::class )->store( |
243 | 243 | glsr( Schema::class )->build( $this->args ) |
244 | 244 | ); |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | */ |
263 | 263 | protected function getExcerpt( $text ) |
264 | 264 | { |
265 | - $limit = intval( $this->getOption( 'settings.reviews.excerpt.length', 55 )); |
|
265 | + $limit = intval( $this->getOption( 'settings.reviews.excerpt.length', 55 ) ); |
|
266 | 266 | $split = extension_loaded( 'intl' ) |
267 | 267 | ? $this->getExcerptIntlSplit( $text, $limit ) |
268 | 268 | : $this->getExcerptSplit( $text, $limit ); |
269 | 269 | $hiddenText = substr( $text, $split ); |
270 | - if( !empty( $hiddenText )) { |
|
270 | + if( !empty($hiddenText) ) { |
|
271 | 271 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
272 | 272 | 'class' => 'glsr-hidden glsr-hidden-text', |
273 | 273 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
274 | 274 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
275 | - ]); |
|
276 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
275 | + ] ); |
|
276 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
277 | 277 | } |
278 | 278 | return nl2br( $text ); |
279 | 279 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
289 | 289 | $words->setText( $text ); |
290 | 290 | $count = 0; |
291 | - foreach( $words as $offset ){ |
|
291 | + foreach( $words as $offset ) { |
|
292 | 292 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
293 | 293 | $count++; |
294 | 294 | if( $count != $limit )continue; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | protected function getExcerptSplit( $text, $limit ) |
306 | 306 | { |
307 | 307 | if( str_word_count( $text, 0 ) > $limit ) { |
308 | - $words = array_keys( str_word_count( $text, 2 )); |
|
308 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
309 | 309 | return $words[$limit]; |
310 | 310 | } |
311 | 311 | return strlen( $text ); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function getOption( $path, $fallback = '' ) |
320 | 320 | { |
321 | - if( array_key_exists( $path, $this->options )) { |
|
321 | + if( array_key_exists( $path, $this->options ) ) { |
|
322 | 322 | return $this->options[$path]; |
323 | 323 | } |
324 | 324 | return $fallback; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function isHidden( $key, $path = '' ) |
333 | 333 | { |
334 | - $isOptionEnabled = !empty( $path ) |
|
334 | + $isOptionEnabled = !empty($path) |
|
335 | 335 | ? $this->isOptionEnabled( $path ) |
336 | 336 | : true; |
337 | 337 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | protected function isHiddenOrEmpty( $key, $value ) |
346 | 346 | { |
347 | - return $this->isHidden( $key ) || empty( $value ); |
|
347 | + return $this->isHidden( $key ) || empty($value); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | protected function normalizeText( $text ) |
364 | 364 | { |
365 | 365 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
366 | - $text = convert_smilies( wptexturize( strip_shortcodes( $text ))); |
|
366 | + $text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) ); |
|
367 | 367 | $text = str_replace( ']]>', ']]>', $text ); |
368 | 368 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
369 | 369 | return $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) |
@@ -380,6 +380,6 @@ discard block |
||
380 | 380 | { |
381 | 381 | return glsr( Builder::class )->div( $value, [ |
382 | 382 | 'class' => 'glsr-review-'.$key, |
383 | - ]); |
|
383 | + ] ); |
|
384 | 384 | } |
385 | 385 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function routerChangeReviewStatus( 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 routerSearchPosts( array $request ) |
78 | 78 | { |
79 | 79 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
80 | - wp_send_json_success([ |
|
80 | + wp_send_json_success( [ |
|
81 | 81 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
82 | 82 | 'items' => $results, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function routerSearchTranslations( array $request ) |
90 | 90 | { |
91 | - if( empty( $request['exclude'] )) { |
|
91 | + if( empty($request['exclude']) ) { |
|
92 | 92 | $request['exclude'] = []; |
93 | 93 | } |
94 | 94 | $results = glsr( Translator::class ) |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | ->exclude() |
97 | 97 | ->exclude( $request['exclude'] ) |
98 | 98 | ->renderResults(); |
99 | - wp_send_json_success([ |
|
99 | + wp_send_json_success( [ |
|
100 | 100 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
101 | 101 | 'items' => $results, |
102 | - ]); |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'message' => glsr( Session::class )->get( $request['form_id'].'message', '', true ), |
114 | 114 | 'recaptcha' => glsr( Session::class )->get( $request['form_id'].'recaptcha', false, true ), |
115 | 115 | ]; |
116 | - if( !wp_validate_boolean( $data['errors'] )) { |
|
116 | + if( !wp_validate_boolean( $data['errors'] ) ) { |
|
117 | 117 | wp_send_json_success( $data ); |
118 | 118 | } |
119 | 119 | wp_send_json_error( $data ); |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function routerTogglePinned( array $request ) |
126 | 126 | { |
127 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
128 | - wp_send_json_success([ |
|
127 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
128 | + wp_send_json_success( [ |
|
129 | 129 | 'notices' => glsr( Notice::class )->get(), |
130 | 130 | 'pinned' => $isPinned, |
131 | - ]); |
|
131 | + ] ); |
|
132 | 132 | } |
133 | 133 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 'post_type' => Application::POST_TYPE, |
34 | 34 | ]; |
35 | 35 | $postId = wp_insert_post( $post, true ); |
36 | - if( is_wp_error( $postId )) { |
|
36 | + if( is_wp_error( $postId ) ) { |
|
37 | 37 | glsr_log()->error( $postId->get_error_message() ); |
38 | 38 | return 0; |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function delete( $metaReviewId ) |
50 | 50 | { |
51 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
51 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
52 | 52 | wp_delete_post( $postId, true ); |
53 | 53 | } |
54 | 54 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $paged = glsr( QueryBuilder::class )->getPaged( |
71 | 71 | wp_validate_boolean( $args['pagination'] ) |
72 | 72 | ); |
73 | - $reviews = new WP_Query([ |
|
73 | + $reviews = new WP_Query( [ |
|
74 | 74 | 'meta_key' => 'pinned', |
75 | 75 | 'meta_query' => $metaQuery, |
76 | 76 | 'offset' => $args['offset'], |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'post_type' => Application::POST_TYPE, |
84 | 84 | 'posts_per_page' => $args['count'], |
85 | 85 | 'tax_query' => $taxQuery, |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | return (object)[ |
88 | 88 | 'results' => array_map( [$this, 'single'], $reviews->posts ), |
89 | 89 | 'max_num_pages' => $reviews->max_num_pages, |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | { |
108 | 108 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
109 | 109 | delete_post_meta( $postId, '_edit_last' ); |
110 | - $result = wp_update_post([ |
|
110 | + $result = wp_update_post( [ |
|
111 | 111 | 'ID' => $postId, |
112 | 112 | 'post_content' => get_post_meta( $postId, 'content', true ), |
113 | 113 | 'post_date' => get_post_meta( $postId, 'date', true ), |
114 | 114 | 'post_title' => get_post_meta( $postId, 'title', true ), |
115 | - ]); |
|
116 | - if( is_wp_error( $result )) { |
|
115 | + ] ); |
|
116 | + if( is_wp_error( $result ) ) { |
|
117 | 117 | glsr_log()->error( $result->get_error_message() ); |
118 | 118 | } |
119 | 119 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
136 | 136 | { |
137 | 137 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
138 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
138 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
139 | 139 | ? 'pending' |
140 | 140 | : 'publish'; |
141 | 141 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | protected function normalizeTerms( $commaSeparatedTermIds ) |
148 | 148 | { |
149 | 149 | $terms = []; |
150 | - $termIds = array_map( 'trim', explode( ',', $commaSeparatedTermIds )); |
|
150 | + $termIds = array_map( 'trim', explode( ',', $commaSeparatedTermIds ) ); |
|
151 | 151 | foreach( $termIds as $termId ) { |
152 | 152 | $term = term_exists( $termId, Application::TAXONOMY ); |
153 | - if( !isset( $term['term_id'] ))continue; |
|
153 | + if( !isset($term['term_id']) )continue; |
|
154 | 154 | $terms[] = intval( $term['term_id'] ); |
155 | 155 | } |
156 | 156 | return $terms; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | protected function setTerms( $postId, $termIds ) |
165 | 165 | { |
166 | 166 | $terms = $this->normalizeTerms( $termIds ); |
167 | - if( empty( $terms ))return; |
|
167 | + if( empty($terms) )return; |
|
168 | 168 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
169 | - if( is_wp_error( $result )) { |
|
169 | + if( is_wp_error( $result ) ) { |
|
170 | 170 | glsr_log()->error( $result->get_error_message() ); |
171 | 171 | } |
172 | 172 | } |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function revert( $postId ) |
107 | 107 | { |
108 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
108 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
109 | + return; |
|
110 | + } |
|
109 | 111 | delete_post_meta( $postId, '_edit_last' ); |
110 | 112 | $result = wp_update_post([ |
111 | 113 | 'ID' => $postId, |
@@ -123,7 +125,9 @@ discard block |
||
123 | 125 | */ |
124 | 126 | public function single( WP_Post $post ) |
125 | 127 | { |
126 | - if( $post->post_type != Application::POST_TYPE )return; |
|
128 | + if( $post->post_type != Application::POST_TYPE ) { |
|
129 | + return; |
|
130 | + } |
|
127 | 131 | $review = new Review( $post ); |
128 | 132 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
129 | 133 | } |
@@ -150,7 +154,9 @@ discard block |
||
150 | 154 | $termIds = array_map( 'trim', explode( ',', $commaSeparatedTermIds )); |
151 | 155 | foreach( $termIds as $termId ) { |
152 | 156 | $term = term_exists( $termId, Application::TAXONOMY ); |
153 | - if( !isset( $term['term_id'] ))continue; |
|
157 | + if( !isset( $term['term_id'] )) { |
|
158 | + continue; |
|
159 | + } |
|
154 | 160 | $terms[] = intval( $term['term_id'] ); |
155 | 161 | } |
156 | 162 | return $terms; |
@@ -164,7 +170,9 @@ discard block |
||
164 | 170 | protected function setTerms( $postId, $termIds ) |
165 | 171 | { |
166 | 172 | $terms = $this->normalizeTerms( $termIds ); |
167 | - if( empty( $terms ))return; |
|
173 | + if( empty( $terms )) { |
|
174 | + return; |
|
175 | + } |
|
168 | 176 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
169 | 177 | if( is_wp_error( $result )) { |
170 | 178 | glsr_log()->error( $result->get_error_message() ); |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
24 | 24 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
25 | 25 | foreach( $types as $type ) { |
26 | - if( isset( $counts[$type] ))continue; |
|
26 | + if( isset( $counts[$type] )) { |
|
27 | + continue; |
|
28 | + } |
|
27 | 29 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
28 | 30 | } |
29 | 31 | foreach( $reviews as $review ) { |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | if( empty( $assignedTo )) { |
61 | 63 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
62 | 64 | } |
63 | - if( empty( $assignedTo ))return; |
|
65 | + if( empty( $assignedTo )) { |
|
66 | + return; |
|
67 | + } |
|
64 | 68 | $assignedPost = get_post( $assignedTo ); |
65 | 69 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
66 | 70 | return $assignedPost; |
@@ -103,7 +107,9 @@ discard block |
||
103 | 107 | array_walk( $counts, function( &$ratings ) use( $args ) { |
104 | 108 | $ratings[0] = 0; |
105 | 109 | foreach( $ratings as $index => &$num ) { |
106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
111 | + continue; |
|
112 | + } |
|
107 | 113 | $num = 0; |
108 | 114 | } |
109 | 115 | }); |
@@ -173,7 +179,9 @@ discard block |
||
173 | 179 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
174 | 180 | $search = new WP_Query( $args ); |
175 | 181 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
176 | - if( !$search->have_posts() )return; |
|
182 | + if( !$search->have_posts() ) { |
|
183 | + return; |
|
184 | + } |
|
177 | 185 | $results = ''; |
178 | 186 | while( $search->have_posts() ) { |
179 | 187 | $search->the_post(); |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | { |
21 | 21 | $counts = []; |
22 | 22 | $greaterThanId = 0; |
23 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
|
24 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
23 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId ) ) { |
|
24 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
25 | 25 | foreach( $types as $type ) { |
26 | - if( isset( $counts[$type] ))continue; |
|
26 | + if( isset($counts[$type]) )continue; |
|
27 | 27 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
28 | 28 | } |
29 | 29 | foreach( $reviews as $review ) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $counts = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
43 | 43 | $greaterThanId = 0; |
44 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId )) { |
|
44 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId ) ) { |
|
45 | 45 | foreach( $reviews as $review ) { |
46 | 46 | $counts[$review->rating]++; |
47 | 47 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getAssignedToPost( $postId, $assignedTo = '' ) |
59 | 59 | { |
60 | - if( empty( $assignedTo )) { |
|
60 | + if( empty($assignedTo) ) { |
|
61 | 61 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
62 | 62 | } |
63 | - if( empty( $assignedTo ))return; |
|
63 | + if( empty($assignedTo) )return; |
|
64 | 64 | $assignedPost = get_post( $assignedTo ); |
65 | 65 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
66 | 66 | return $assignedPost; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if( !$metaValue ) { |
82 | 82 | return $counts; |
83 | 83 | } |
84 | - return isset( $counts[$metaValue] ) |
|
84 | + return isset($counts[$metaValue]) |
|
85 | 85 | ? $counts[$metaValue] |
86 | 86 | : 0; |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | 'max' => Rating::MAX_RATING, |
96 | 96 | 'min' => Rating::MIN_RATING, |
97 | 97 | 'types' => 'local', |
98 | - ]); |
|
98 | + ] ); |
|
99 | 99 | $counts = array_intersect_key( |
100 | 100 | glsr( OptionManager::class )->get( 'counts', [] ), |
101 | - array_flip( array_intersect( array_keys( glsr()->reviewTypes ), (array)$args['types'] )) |
|
101 | + array_flip( array_intersect( array_keys( glsr()->reviewTypes ), (array)$args['types'] ) ) |
|
102 | 102 | ); |
103 | - array_walk( $counts, function( &$ratings ) use( $args ) { |
|
103 | + array_walk( $counts, function( &$ratings ) use($args) { |
|
104 | 104 | $ratings[0] = 0; |
105 | 105 | foreach( $ratings as $index => &$num ) { |
106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
106 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
107 | 107 | $num = 0; |
108 | 108 | } |
109 | 109 | }); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getReviewsMeta( $key, $status = 'publish' ) |
128 | 128 | { |
129 | - if( $status == 'all' || empty( $status )) { |
|
129 | + if( $status == 'all' || empty($status) ) { |
|
130 | 130 | $status = get_post_stati( ['exclude_from_search' => false] ); |
131 | 131 | } |
132 | 132 | return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | 'fields' => 'id=>name', |
142 | 142 | 'hide_empty' => false, |
143 | 143 | 'taxonomy' => Application::TAXONOMY, |
144 | - ]); |
|
145 | - unset( $args['count'] ); // we don't want a term count |
|
144 | + ] ); |
|
145 | + unset($args['count']); // we don't want a term count |
|
146 | 146 | $terms = get_terms( $args ); |
147 | - if( is_wp_error( $terms )) { |
|
147 | + if( is_wp_error( $terms ) ) { |
|
148 | 148 | glsr_log()->error( $terms->get_error_message() ); |
149 | 149 | return []; |
150 | 150 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'post_status' => 'publish', |
162 | 162 | 'post_type' => 'any', |
163 | 163 | ]; |
164 | - if( is_numeric( $searchTerm )) { |
|
164 | + if( is_numeric( $searchTerm ) ) { |
|
165 | 165 | $args['post__in'] = [$searchTerm]; |
166 | 166 | } |
167 | 167 | else { |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | ob_start(); |
181 | 181 | glsr()->render( 'partials/editor/search-result', [ |
182 | 182 | 'ID' => get_the_ID(), |
183 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
183 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
184 | 184 | 'title' => esc_attr( get_the_title() ), |
185 | - ]); |
|
185 | + ] ); |
|
186 | 186 | $results .= ob_get_clean(); |
187 | 187 | } |
188 | 188 | wp_reset_postdata(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->reviews = glsr( ReviewManager::class )->get( $args )->results; |
37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( empty($this->reviews) && $this->isHidden( 'if_empty' ) )return; |
|
38 | 38 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
39 | 39 | $this->generateSchema(); |
40 | 40 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'stars' => $this->buildStars(), |
47 | 47 | 'text' => $this->buildText(), |
48 | 48 | ], |
49 | - ]); |
|
49 | + ] ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function buildPercentage() |
56 | 56 | { |
57 | - if( $this->isHidden( 'bars' ))return; |
|
57 | + if( $this->isHidden( 'bars' ) )return; |
|
58 | 58 | $range = range( Rating::MAX_RATING, 1 ); |
59 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
|
60 | - $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
|
59 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews ) ); |
|
60 | + $bars = array_reduce( $range, function( $carry, $level ) use($percentages) { |
|
61 | 61 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
62 | 62 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
63 | 63 | $percent = $this->buildPercentagePercent( $percentages[$level] ); |
64 | 64 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
65 | 65 | 'class' => 'glsr-bar', |
66 | - ]); |
|
66 | + ] ); |
|
67 | 67 | }); |
68 | 68 | return $this->wrap( 'percentage', $bars ); |
69 | 69 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function buildPercentageBackground( $percent ) |
76 | 76 | { |
77 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
77 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
78 | 78 | 'class' => 'glsr-bar-background-percent', |
79 | 79 | 'style' => 'width:'.$percent, |
80 | - ]); |
|
80 | + ] ); |
|
81 | 81 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
82 | 82 | } |
83 | 83 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildRating() |
106 | 106 | { |
107 | - if( $this->isHidden( 'rating' ))return; |
|
107 | + if( $this->isHidden( 'rating' ) )return; |
|
108 | 108 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
109 | 109 | } |
110 | 110 | |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function buildStars() |
115 | 115 | { |
116 | - if( $this->isHidden( 'stars' ))return; |
|
116 | + if( $this->isHidden( 'stars' ) )return; |
|
117 | 117 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
118 | 118 | 'rating' => $this->rating, |
119 | - ]); |
|
119 | + ] ); |
|
120 | 120 | return $this->wrap( 'stars', $stars ); |
121 | 121 | } |
122 | 122 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function buildText() |
127 | 127 | { |
128 | - if( $this->isHidden( 'summary' ))return; |
|
128 | + if( $this->isHidden( 'summary' ) )return; |
|
129 | 129 | $count = count( $this->reviews ); |
130 | - if( empty( $this->args['text'] )) { |
|
130 | + if( empty($this->args['text']) ) { |
|
131 | 131 | // @todo document this change |
132 | 132 | $this->args['text'] = _nx( |
133 | 133 | '{rating} out of {max} stars (based on {num} review)', |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ); |
139 | 139 | } |
140 | 140 | $summary = str_replace( |
141 | - ['{rating}','{max}', '{num}'], |
|
141 | + ['{rating}', '{max}', '{num}'], |
|
142 | 142 | [$this->rating, Rating::MAX_RATING, $count], |
143 | 143 | $this->args['text'] |
144 | 144 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function generateSchema() |
152 | 152 | { |
153 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
153 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
154 | 154 | glsr( Schema::class )->store( |
155 | 155 | glsr( Schema::class )->buildSummary( $this->args ) |
156 | 156 | ); |
@@ -183,6 +183,6 @@ discard block |
||
183 | 183 | { |
184 | 184 | return glsr( Builder::class )->div( $value, [ |
185 | 185 | 'class' => 'glsr-summary-'.$key, |
186 | - ]); |
|
186 | + ] ); |
|
187 | 187 | } |
188 | 188 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->reviews = glsr( ReviewManager::class )->get( $args )->results; |
37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( empty( $this->reviews ) && $this->isHidden( 'if_empty' )) { |
|
38 | + return; |
|
39 | + } |
|
38 | 40 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
39 | 41 | $this->generateSchema(); |
40 | 42 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -54,7 +56,9 @@ discard block |
||
54 | 56 | */ |
55 | 57 | protected function buildPercentage() |
56 | 58 | { |
57 | - if( $this->isHidden( 'bars' ))return; |
|
59 | + if( $this->isHidden( 'bars' )) { |
|
60 | + return; |
|
61 | + } |
|
58 | 62 | $range = range( Rating::MAX_RATING, 1 ); |
59 | 63 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
60 | 64 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -104,7 +108,9 @@ discard block |
||
104 | 108 | */ |
105 | 109 | protected function buildRating() |
106 | 110 | { |
107 | - if( $this->isHidden( 'rating' ))return; |
|
111 | + if( $this->isHidden( 'rating' )) { |
|
112 | + return; |
|
113 | + } |
|
108 | 114 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
109 | 115 | } |
110 | 116 | |
@@ -113,7 +119,9 @@ discard block |
||
113 | 119 | */ |
114 | 120 | protected function buildStars() |
115 | 121 | { |
116 | - if( $this->isHidden( 'stars' ))return; |
|
122 | + if( $this->isHidden( 'stars' )) { |
|
123 | + return; |
|
124 | + } |
|
117 | 125 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
118 | 126 | 'rating' => $this->rating, |
119 | 127 | ]); |
@@ -125,7 +133,9 @@ discard block |
||
125 | 133 | */ |
126 | 134 | protected function buildText() |
127 | 135 | { |
128 | - if( $this->isHidden( 'summary' ))return; |
|
136 | + if( $this->isHidden( 'summary' )) { |
|
137 | + return; |
|
138 | + } |
|
129 | 139 | $count = count( $this->reviews ); |
130 | 140 | if( empty( $this->args['text'] )) { |
131 | 141 | // @todo document this change |
@@ -150,7 +160,9 @@ discard block |
||
150 | 160 | */ |
151 | 161 | protected function generateSchema() |
152 | 162 | { |
153 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
163 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
164 | + return; |
|
165 | + } |
|
154 | 166 | glsr( Schema::class )->store( |
155 | 167 | glsr( Schema::class )->buildSummary( $this->args ) |
156 | 168 | ); |