@@ -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 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | return []; |
84 | 84 | } |
85 | 85 | $request = glsr( Helper::class )->filterInputArray( 'request' ); |
86 | - if( empty( $request )) { |
|
86 | + if( empty($request) ) { |
|
87 | 87 | $request = glsr( Helper::class )->filterInputArray( Application::ID ); |
88 | 88 | } |
89 | 89 | return $this->normalizeRequest( $request ); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function isValidPostRequest( array $request = [] ) |
96 | 96 | { |
97 | - return !empty( $request['action'] ) && empty( $request['ajax_request'] ); |
|
97 | + return !empty($request['action']) && empty($request['ajax_request']); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function isValidPublicNonce( array $request ) |
104 | 104 | { |
105 | - if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
105 | + if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
106 | 106 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
107 | 107 | return false; |
108 | 108 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | protected function routeRequest( $type, $action, array $request = [] ) |
132 | 132 | { |
133 | 133 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
134 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
134 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
135 | 135 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
136 | 136 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
137 | 137 | do_action( $actionHook, $action, $request ); |
138 | - if( is_callable( [$controller, $method] )) { |
|
138 | + if( is_callable( [$controller, $method] ) ) { |
|
139 | 139 | call_user_func( [$controller, $method], $request ); |
140 | 140 | return; |
141 | 141 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | protected function sendAjaxError( $error, array $request, $statusCode = 400 ) |
153 | 153 | { |
154 | 154 | glsr_log()->error( $error )->info( $request ); |
155 | - wp_send_json_error([ |
|
155 | + wp_send_json_error( [ |
|
156 | 156 | 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
157 | 157 | 'error' => $error, |
158 | 158 | ], $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 | }); |
@@ -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 | /** |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | { |
45 | 45 | $shortcode = $request['shortcode']; |
46 | 46 | $response = false; |
47 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
47 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
48 | 48 | $data = glsr()->mceShortcodes[$shortcode]; |
49 | - if( !empty( $data['errors'] )) { |
|
49 | + if( !empty($data['errors']) ) { |
|
50 | 50 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
51 | 51 | } |
52 | 52 | $response = [ |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | public function routerSearchPosts( array $request ) |
67 | 67 | { |
68 | 68 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
69 | - wp_send_json_success([ |
|
69 | + wp_send_json_success( [ |
|
70 | 70 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
71 | 71 | 'items' => $results, |
72 | - ]); |
|
72 | + ] ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function routerSearchTranslations( array $request ) |
79 | 79 | { |
80 | - if( empty( $request['exclude'] )) { |
|
80 | + if( empty($request['exclude']) ) { |
|
81 | 81 | $request['exclude'] = []; |
82 | 82 | } |
83 | 83 | $results = glsr( Translator::class ) |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | ->exclude() |
86 | 86 | ->exclude( $request['exclude'] ) |
87 | 87 | ->renderResults(); |
88 | - wp_send_json_success([ |
|
88 | + wp_send_json_success( [ |
|
89 | 89 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
90 | 90 | 'items' => $results, |
91 | - ]); |
|
91 | + ] ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'message' => glsr( Session::class )->get( $request['form_id'].'message', '', true ), |
103 | 103 | 'recaptcha' => glsr( Session::class )->get( $request['form_id'].'recaptcha', false, true ), |
104 | 104 | ]; |
105 | - if( !wp_validate_boolean( $data['errors'] )) { |
|
105 | + if( !wp_validate_boolean( $data['errors'] ) ) { |
|
106 | 106 | wp_send_json_success( $data ); |
107 | 107 | } |
108 | 108 | wp_send_json_error( $data ); |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function routerTogglePinned( array $request ) |
115 | 115 | { |
116 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
117 | - wp_send_json_success([ |
|
116 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
117 | + wp_send_json_success( [ |
|
118 | 118 | 'notices' => glsr( Notice::class )->get(), |
119 | 119 | 'pinned' => $isPinned, |
120 | - ]); |
|
120 | + ] ); |
|
121 | 121 | } |
122 | 122 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'navigation' => $navigation, |
57 | 57 | ], |
58 | 58 | 'reviews' => $this->buildReviews(), |
59 | - ]); |
|
59 | + ] ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $reviewValues = []; |
83 | 83 | foreach( $review as $key => $value ) { |
84 | 84 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
85 | - if( !method_exists( $this, $method ))continue; |
|
85 | + if( !method_exists( $this, $method ) )continue; |
|
86 | 86 | $reviewValues[$key] = $this->$method( $key, $value ); |
87 | 87 | } |
88 | 88 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function buildOptionAssignedTo( $key, $value ) |
98 | 98 | { |
99 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
100 | - $post = get_post( intval( $value )); |
|
101 | - if( !( $post instanceof WP_Post ))return; |
|
99 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return; |
|
100 | + $post = get_post( intval( $value ) ); |
|
101 | + if( !($post instanceof WP_Post) )return; |
|
102 | 102 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
103 | 103 | 'href' => get_the_permalink( $post->ID ), |
104 | - ]); |
|
104 | + ] ); |
|
105 | 105 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
106 | 106 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function buildOptionAuthor( $key, $value ) |
115 | 115 | { |
116 | - if( $this->isHidden( $key ))return; |
|
116 | + if( $this->isHidden( $key ) )return; |
|
117 | 117 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
118 | 118 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
119 | 119 | : ''; |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildOptionAvatar( $key, $value ) |
129 | 129 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
130 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return; |
|
131 | 131 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
132 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
132 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
133 | 133 | 'src' => $this->generateAvatar( $value ), |
134 | 134 | 'height' => $size, |
135 | 135 | 'width' => $size, |
136 | - ])); |
|
136 | + ] ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | protected function buildOptionContent( $key, $value ) |
145 | 145 | { |
146 | 146 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
147 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
148 | 148 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 149 | } |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function buildOptionDate( $key, $value ) |
157 | 157 | { |
158 | - if( $this->isHidden( $key ))return; |
|
158 | + if( $this->isHidden( $key ) )return; |
|
159 | 159 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 160 | if( $dateFormat == 'relative' ) { |
161 | 161 | $date = glsr( Date::class )->relative( $value ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $format = $dateFormat == 'custom' |
165 | 165 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
166 | 166 | : (string)get_option( 'date_format' ); |
167 | - $date = date_i18n( $format, strtotime( $value )); |
|
167 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
168 | 168 | } |
169 | 169 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
170 | 170 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function buildOptionRating( $key, $value ) |
178 | 178 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
179 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
180 | 180 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
181 | 181 | 'rating' => $value, |
182 | - ]); |
|
182 | + ] ); |
|
183 | 183 | return $this->wrap( $key, $rating ); |
184 | 184 | } |
185 | 185 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | protected function buildOptionResponse( $key, $value ) |
192 | 192 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
194 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
194 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
195 | 195 | $text = $this->normalizeText( $value ); |
196 | 196 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
197 | 197 | return $this->wrap( $key, |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function buildOptionTitle( $key, $value ) |
209 | 209 | { |
210 | - if( $this->isHidden( $key ))return; |
|
211 | - if( empty( $value )) { |
|
210 | + if( $this->isHidden( $key ) )return; |
|
211 | + if( empty($value) ) { |
|
212 | 212 | $value = __( 'No Title', 'site-reviews' ); |
213 | 213 | } |
214 | 214 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | return $avatarUrl; |
227 | 227 | } |
228 | 228 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
229 | - if( empty( $authorIdOrEmail )) { |
|
229 | + if( empty($authorIdOrEmail) ) { |
|
230 | 230 | $authorIdOrEmail = $review->email; |
231 | 231 | } |
232 | 232 | return (string)get_avatar_url( $authorIdOrEmail ); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function generateSchema() |
239 | 239 | { |
240 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
240 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
241 | 241 | glsr( Schema::class )->store( |
242 | 242 | glsr( Schema::class )->build( $this->args ) |
243 | 243 | ); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | protected function getExcerpt( $text ) |
263 | 263 | { |
264 | - $limit = intval( $this->getOption( 'settings.reviews.excerpt.length', 55 )); |
|
264 | + $limit = intval( $this->getOption( 'settings.reviews.excerpt.length', 55 ) ); |
|
265 | 265 | $text = extension_loaded( 'intl' ) |
266 | 266 | ? $this->buildIntlExcerpt( $text, $limit ) |
267 | 267 | : $this->buildExcerpt( $text, $limit ); |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | if( str_word_count( $text, 0 ) <= $limit ) { |
279 | 279 | return $text; |
280 | 280 | } |
281 | - $words = array_keys( str_word_count( $text, 2 )); |
|
282 | - $excerpt = ltrim( substr( $text, 0, $words[$limit] )); |
|
281 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
282 | + $excerpt = ltrim( substr( $text, 0, $words[$limit] ) ); |
|
283 | 283 | |
284 | - $hiddenText = substr( $text, strlen( $excerpt )); |
|
284 | + $hiddenText = substr( $text, strlen( $excerpt ) ); |
|
285 | 285 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
286 | 286 | 'class' => 'glsr-hidden glsr-hidden-text', |
287 | 287 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
288 | 288 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
289 | - ]); |
|
289 | + ] ); |
|
290 | 290 | return $excerpt.$showMore; |
291 | 291 | } |
292 | 292 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $words->setText( $text ); |
302 | 302 | $count = 0; |
303 | 303 | $break = strlen( $text ); |
304 | - foreach( $words as $offset ){ |
|
304 | + foreach( $words as $offset ) { |
|
305 | 305 | if( \IntlBreakIterator::WORD_NONE === $words->getRuleStatus() )continue; |
306 | 306 | $count++; |
307 | 307 | if( $count == $limit ) { |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | } |
312 | 312 | $excerpt = substr( $text, 0, $break ); |
313 | 313 | $hiddenText = substr( $text, $break ); |
314 | - if( empty( $hiddenText )) { |
|
314 | + if( empty($hiddenText) ) { |
|
315 | 315 | return $excerpt; |
316 | 316 | } |
317 | 317 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
318 | 318 | 'class' => 'glsr-hidden glsr-hidden-text', |
319 | 319 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
320 | 320 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
321 | - ]); |
|
321 | + ] ); |
|
322 | 322 | return $excerpt.$showMore; |
323 | 323 | } |
324 | 324 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | protected function getOption( $path, $fallback = '' ) |
331 | 331 | { |
332 | - if( array_key_exists( $path, $this->options )) { |
|
332 | + if( array_key_exists( $path, $this->options ) ) { |
|
333 | 333 | return $this->options[$path]; |
334 | 334 | } |
335 | 335 | return $fallback; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | */ |
343 | 343 | protected function isHidden( $key, $path = '' ) |
344 | 344 | { |
345 | - $isOptionEnabled = !empty( $path ) |
|
345 | + $isOptionEnabled = !empty($path) |
|
346 | 346 | ? $this->isOptionEnabled( $path ) |
347 | 347 | : true; |
348 | 348 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | protected function isHiddenOrEmpty( $key, $value ) |
357 | 357 | { |
358 | - return $this->isHidden( $key ) || empty( $value ); |
|
358 | + return $this->isHidden( $key ) || empty($value); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | protected function normalizeText( $text ) |
375 | 375 | { |
376 | 376 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
377 | - $text = convert_smilies( wptexturize( strip_shortcodes( $text ))); |
|
377 | + $text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) ); |
|
378 | 378 | $text = str_replace( ']]>', ']]>', $text ); |
379 | 379 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
380 | 380 | return $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) |
@@ -391,6 +391,6 @@ discard block |
||
391 | 391 | { |
392 | 392 | return glsr( Builder::class )->div( $value, [ |
393 | 393 | 'class' => 'glsr-review-'.$key, |
394 | - ]); |
|
394 | + ] ); |
|
395 | 395 | } |
396 | 396 | } |
@@ -82,7 +82,9 @@ discard block |
||
82 | 82 | $reviewValues = []; |
83 | 83 | foreach( $review as $key => $value ) { |
84 | 84 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
85 | - if( !method_exists( $this, $method ))continue; |
|
85 | + if( !method_exists( $this, $method )) { |
|
86 | + continue; |
|
87 | + } |
|
86 | 88 | $reviewValues[$key] = $this->$method( $key, $value ); |
87 | 89 | } |
88 | 90 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -96,9 +98,13 @@ discard block |
||
96 | 98 | */ |
97 | 99 | protected function buildOptionAssignedTo( $key, $value ) |
98 | 100 | { |
99 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
101 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
102 | + return; |
|
103 | + } |
|
100 | 104 | $post = get_post( intval( $value )); |
101 | - if( !( $post instanceof WP_Post ))return; |
|
105 | + if( !( $post instanceof WP_Post )) { |
|
106 | + return; |
|
107 | + } |
|
102 | 108 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
103 | 109 | 'href' => get_the_permalink( $post->ID ), |
104 | 110 | ]); |
@@ -113,7 +119,9 @@ discard block |
||
113 | 119 | */ |
114 | 120 | protected function buildOptionAuthor( $key, $value ) |
115 | 121 | { |
116 | - if( $this->isHidden( $key ))return; |
|
122 | + if( $this->isHidden( $key )) { |
|
123 | + return; |
|
124 | + } |
|
117 | 125 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
118 | 126 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
119 | 127 | : ''; |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | */ |
128 | 136 | protected function buildOptionAvatar( $key, $value ) |
129 | 137 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
138 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
139 | + return; |
|
140 | + } |
|
131 | 141 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
132 | 142 | return $this->wrap( $key, glsr( Builder::class )->img([ |
133 | 143 | 'src' => $this->generateAvatar( $value ), |
@@ -144,7 +154,9 @@ discard block |
||
144 | 154 | protected function buildOptionContent( $key, $value ) |
145 | 155 | { |
146 | 156 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
157 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
158 | + return; |
|
159 | + } |
|
148 | 160 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 161 | } |
150 | 162 | |
@@ -155,7 +167,9 @@ discard block |
||
155 | 167 | */ |
156 | 168 | protected function buildOptionDate( $key, $value ) |
157 | 169 | { |
158 | - if( $this->isHidden( $key ))return; |
|
170 | + if( $this->isHidden( $key )) { |
|
171 | + return; |
|
172 | + } |
|
159 | 173 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 174 | if( $dateFormat == 'relative' ) { |
161 | 175 | $date = glsr( Date::class )->relative( $value ); |
@@ -176,7 +190,9 @@ discard block |
||
176 | 190 | */ |
177 | 191 | protected function buildOptionRating( $key, $value ) |
178 | 192 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
194 | + return; |
|
195 | + } |
|
180 | 196 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
181 | 197 | 'rating' => $value, |
182 | 198 | ]); |
@@ -190,7 +206,9 @@ discard block |
||
190 | 206 | */ |
191 | 207 | protected function buildOptionResponse( $key, $value ) |
192 | 208 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
209 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
210 | + return; |
|
211 | + } |
|
194 | 212 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
195 | 213 | $text = $this->normalizeText( $value ); |
196 | 214 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -207,7 +225,9 @@ discard block |
||
207 | 225 | */ |
208 | 226 | protected function buildOptionTitle( $key, $value ) |
209 | 227 | { |
210 | - if( $this->isHidden( $key ))return; |
|
228 | + if( $this->isHidden( $key )) { |
|
229 | + return; |
|
230 | + } |
|
211 | 231 | if( empty( $value )) { |
212 | 232 | $value = __( 'No Title', 'site-reviews' ); |
213 | 233 | } |
@@ -237,7 +257,9 @@ discard block |
||
237 | 257 | */ |
238 | 258 | protected function generateSchema() |
239 | 259 | { |
240 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
260 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
261 | + return; |
|
262 | + } |
|
241 | 263 | glsr( Schema::class )->store( |
242 | 264 | glsr( Schema::class )->build( $this->args ) |
243 | 265 | ); |
@@ -302,7 +324,9 @@ discard block |
||
302 | 324 | $count = 0; |
303 | 325 | $break = strlen( $text ); |
304 | 326 | foreach( $words as $offset ){ |
305 | - if( \IntlBreakIterator::WORD_NONE === $words->getRuleStatus() )continue; |
|
327 | + if( \IntlBreakIterator::WORD_NONE === $words->getRuleStatus() ) { |
|
328 | + continue; |
|
329 | + } |
|
306 | 330 | $count++; |
307 | 331 | if( $count == $limit ) { |
308 | 332 | $break = $offset; |