@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function compose( Review $review, array $notification ) |
37 | 37 | { |
38 | - if( empty( $this->endpoint )) { |
|
38 | + if( empty($this->endpoint) ) { |
|
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function send() |
62 | 62 | { |
63 | - if( empty( $this->endpoint )) { |
|
63 | + if( empty($this->endpoint) ) { |
|
64 | 64 | return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
65 | 65 | } |
66 | 66 | return wp_remote_post( $this->endpoint, [ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'redirection' => 5, |
73 | 73 | 'sslverify' => false, |
74 | 74 | 'timeout' => 45, |
75 | - ]); |
|
75 | + ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function buildAuthorField() |
94 | 94 | { |
95 | - $email = !empty( $this->review->email ) |
|
95 | + $email = !empty($this->review->email) |
|
96 | 96 | ? '<'.$this->review->email.'>' |
97 | 97 | : ''; |
98 | 98 | $author = trim( rtrim( $this->review->author ).' '.$email ); |
99 | - return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))]; |
|
99 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildContentField() |
106 | 106 | { |
107 | - return !empty( $this->review->content ) |
|
107 | + return !empty($this->review->content) |
|
108 | 108 | ? ['value' => $this->review->content] |
109 | 109 | : []; |
110 | 110 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function buildStarsField() |
130 | 130 | { |
131 | 131 | $solidStars = str_repeat( '★', $this->review->rating ); |
132 | - $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating )); |
|
132 | + $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ) ); |
|
133 | 133 | $stars = $solidStars.$emptyStars; |
134 | 134 | $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, Rating::MAX_RATING ); |
135 | 135 | return ['title' => $stars]; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function buildTitleField() |
142 | 142 | { |
143 | - return !empty( $this->review->title ) |
|
143 | + return !empty($this->review->title) |
|
144 | 144 | ? ['title' => $this->review->title] |
145 | 145 | : []; |
146 | 146 | } |
@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | if( !empty( $sessions )) { |
151 | 151 | $now = time(); |
152 | 152 | foreach( $sessions as $session ) { |
153 | - if( $now <= $session->expiration )continue; |
|
153 | + if( $now <= $session->expiration ) { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $expiredSessions[] = $session->name; |
155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
193 | 195 | */ |
194 | 196 | protected function setCookie() |
195 | 197 | { |
196 | - if( headers_sent() )return; |
|
198 | + if( headers_sent() ) { |
|
199 | + return; |
|
200 | + } |
|
197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
82 | 82 | } |
83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
92 | 92 | { |
93 | 93 | $key = sanitize_key( $key ); |
94 | - $value = isset( $this->sessionData[$key] ) |
|
94 | + $value = isset($this->sessionData[$key]) |
|
95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
96 | 96 | : $fallback; |
97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
98 | - unset( $this->sessionData[$key] ); |
|
97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
98 | + unset($this->sessionData[$key]); |
|
99 | 99 | $this->updateSession(); |
100 | 100 | } |
101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function deleteSession() |
130 | 130 | { |
131 | 131 | delete_option( $this->getSessionId() ); |
132 | - delete_option( $this->getSessionId( 'expires' )); |
|
132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function generateSessionId() |
139 | 139 | { |
140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | protected function getExpiredSessions( $limit ) |
148 | 148 | { |
149 | 149 | $expiredSessions = []; |
150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
151 | - if( !empty( $sessions )) { |
|
150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
151 | + if( !empty($sessions) ) { |
|
152 | 152 | $now = time(); |
153 | 153 | foreach( $sessions as $session ) { |
154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function getSessionId( $separator = '' ) |
167 | 167 | { |
168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | if( headers_sent() )return; |
198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
201 | 201 | } |
202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function updateSession() |
216 | 216 | { |
217 | - if( false === get_option( $this->getSessionId() )) { |
|
217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
218 | 218 | return $this->createSession(); |
219 | 219 | } |
220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] ); |
36 | - $this->email = count( array_intersect( ['admin', 'custom'], $types )) > 0; |
|
36 | + $this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0; |
|
37 | 37 | $this->slack = in_array( 'slack', $types ); |
38 | 38 | $this->types = $types; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty($this->types) )return; |
|
47 | 47 | $this->review = $review; |
48 | 48 | $args = [ |
49 | 49 | 'link' => $this->getLink(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function buildEmail( array $args ) |
60 | 60 | { |
61 | - return glsr( Email::class )->compose([ |
|
61 | + return glsr( Email::class )->compose( [ |
|
62 | 62 | 'to' => $this->getEmailAddresses(), |
63 | 63 | 'subject' => $args['title'], |
64 | 64 | 'template' => 'email-notification', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'review_rating' => $this->review->rating, |
72 | 72 | 'review_title' => $this->review->title, |
73 | 73 | ], |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'button_url' => $args['link'], |
84 | 84 | 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
85 | 85 | 'pretext' => $args['title'], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | protected function getEmailAddresses() |
93 | 93 | { |
94 | 94 | $emails = []; |
95 | - if( in_array( 'admin', $this->types )) { |
|
95 | + if( in_array( 'admin', $this->types ) ) { |
|
96 | 96 | $emails[] = get_option( 'admin_email' ); |
97 | 97 | } |
98 | - if( in_array( 'author', $this->types )) { |
|
99 | - $assignedPost = get_post( intval( $this->review->assigned_to )); |
|
98 | + if( in_array( 'author', $this->types ) ) { |
|
99 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
100 | 100 | if( $assignedPost instanceof WP_Post ) { |
101 | 101 | $this->email = true; |
102 | - $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author )); |
|
102 | + $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) ); |
|
103 | 103 | } |
104 | 104 | } |
105 | - if( in_array( 'custom', $this->types )) { |
|
105 | + if( in_array( 'custom', $this->types ) ) { |
|
106 | 106 | $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
107 | 107 | $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails ); |
108 | 108 | $customEmails = explode( ',', $customEmails ); |
109 | 109 | $emails = array_merge( $emails, $customEmails ); |
110 | 110 | } |
111 | - $emails = array_filter( array_keys( array_flip( $emails ))); |
|
111 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
112 | 112 | return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
113 | 113 | } |
114 | 114 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getTitle() |
127 | 127 | { |
128 | - $assignedTitle = get_the_title( intval( $this->review->assigned_to )); |
|
128 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
129 | 129 | $title = _nx( |
130 | 130 | 'New %s-star review', |
131 | 131 | 'New %s-star review of: %s', |
132 | - intval( empty( $assignedTitle )), |
|
132 | + intval( empty($assignedTitle) ), |
|
133 | 133 | 'This string differs depending on whether or not the review has been assigned to a post.', |
134 | 134 | 'site-reviews' |
135 | 135 | ); |
136 | 136 | $title = sprintf( '[%s] %s', |
137 | - wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ), |
|
137 | + wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ), |
|
138 | 138 | sprintf( $title, $this->review->rating, $assignedTitle ) |
139 | 139 | ); |
140 | 140 | return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $email = $this->buildEmail( $args ); |
149 | 149 | if( !$this->email )return; |
150 | - if( empty( $email->to )) { |
|
150 | + if( empty($email->to) ) { |
|
151 | 151 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 152 | return; |
153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | if( !$this->slack )return; |
165 | 165 | $notification = $this->buildSlackNotification( $args ); |
166 | 166 | $result = $notification->send(); |
167 | - if( is_wp_error( $result )) { |
|
167 | + if( is_wp_error( $result ) ) { |
|
168 | 168 | $notification->review = null; |
169 | 169 | glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
170 | 170 | } |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty( $this->types )) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | $this->review = $review; |
48 | 50 | $args = [ |
49 | 51 | 'link' => $this->getLink(), |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | protected function sendToEmail( array $args ) |
147 | 149 | { |
148 | 150 | $email = $this->buildEmail( $args ); |
149 | - if( !$this->email )return; |
|
151 | + if( !$this->email ) { |
|
152 | + return; |
|
153 | + } |
|
150 | 154 | if( empty( $email->to )) { |
151 | 155 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
161 | 165 | */ |
162 | 166 | protected function sendToSlack( array $args ) |
163 | 167 | { |
164 | - if( !$this->slack )return; |
|
168 | + if( !$this->slack ) { |
|
169 | + return; |
|
170 | + } |
|
165 | 171 | $notification = $this->buildSlackNotification( $args ); |
166 | 172 | $result = $notification->send(); |
167 | 173 | if( is_wp_error( $result )) { |
@@ -175,8 +175,12 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty( $this->error )) { |
|
179 | + return; |
|
180 | + } |
|
181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
182 | + return; |
|
183 | + } |
|
180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function validateBlacklist() |
188 | 192 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
193 | + if( !empty( $this->error )) { |
|
194 | + return; |
|
195 | + } |
|
196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 200 | if( $blacklistAction == 'reject' ) { |
193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
202 | 210 | */ |
203 | 211 | protected function validateCustom() |
204 | 212 | { |
205 | - if( !empty( $this->error ))return; |
|
213 | + if( !empty( $this->error )) { |
|
214 | + return; |
|
215 | + } |
|
206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | - if( $validated === true )return; |
|
217 | + if( $validated === true ) { |
|
218 | + return; |
|
219 | + } |
|
208 | 220 | $this->setSessionValues( 'errors', [] ); |
209 | 221 | $this->setSessionValues( 'values', $this->request ); |
210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
217 | 229 | */ |
218 | 230 | protected function validateHoneyPot() |
219 | 231 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
232 | + if( !empty( $this->error )) { |
|
233 | + return; |
|
234 | + } |
|
235 | + if( empty( $this->request['gotcha'] )) { |
|
236 | + return; |
|
237 | + } |
|
222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
228 | 244 | */ |
229 | 245 | protected function validateRecaptcha() |
230 | 246 | { |
231 | - if( !empty( $this->error ))return; |
|
247 | + if( !empty( $this->error )) { |
|
248 | + return; |
|
249 | + } |
|
232 | 250 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
252 | + return; |
|
253 | + } |
|
234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 256 | $this->recaptchaIsUnset = true; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->validateBlacklist(); |
68 | 68 | $this->validateAkismet(); |
69 | 69 | $this->validateRecaptcha(); |
70 | - if( !empty( $this->error )) { |
|
70 | + if( !empty($this->error) ) { |
|
71 | 71 | $this->setSessionValues( 'message', $this->error ); |
72 | 72 | } |
73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
92 | 92 | return static::RECAPTCHA_DISABLED; |
93 | 93 | } |
94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
96 | 96 | ? static::RECAPTCHA_EMPTY |
97 | 97 | : static::RECAPTCHA_FAILED; |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function getRecaptchaTokenStatus() |
106 | 106 | { |
107 | - $endpoint = add_query_arg([ |
|
107 | + $endpoint = add_query_arg( [ |
|
108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
109 | 109 | 'response' => $this->request['_recaptcha-token'], |
110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
113 | 113 | glsr_log()->error( $response->get_error_message() ); |
114 | 114 | return static::RECAPTCHA_FAILED; |
115 | 115 | } |
116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
117 | - if( !empty( $response->success )) { |
|
116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
117 | + if( !empty($response->success) ) { |
|
118 | 118 | return boolval( $response->success ) |
119 | 119 | ? static::RECAPTCHA_VALID |
120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | { |
133 | 133 | $rules = array_intersect_key( |
134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
136 | 136 | ); |
137 | - $excluded = explode( ',', glsr_get( $request, 'excluded' )); |
|
138 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
137 | + $excluded = explode( ',', glsr_get( $request, 'excluded' ) ); |
|
138 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | $rules = $this->getValidationRules( $request ); |
147 | 147 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
148 | - if( empty( $errors )) { |
|
148 | + if( empty($errors) ) { |
|
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | $this->setSessionValues( 'errors', $errors ); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
163 | 163 | { |
164 | 164 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
165 | - if( !empty( $loggedMessage )) { |
|
165 | + if( !empty($loggedMessage) ) { |
|
166 | 166 | glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
167 | 167 | } |
168 | 168 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function validateAkismet() |
174 | 174 | { |
175 | - if( !empty( $this->error ))return; |
|
176 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
175 | + if( !empty($this->error) )return; |
|
176 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
177 | 177 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
178 | 178 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
179 | 179 | } |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function validateBlacklist() |
185 | 185 | { |
186 | - if( !empty( $this->error ))return; |
|
187 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
186 | + if( !empty($this->error) )return; |
|
187 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
188 | 188 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
189 | 189 | if( $blacklistAction == 'reject' ) { |
190 | 190 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function validateCustom() |
201 | 201 | { |
202 | - if( !empty( $this->error ))return; |
|
202 | + if( !empty($this->error) )return; |
|
203 | 203 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
204 | 204 | if( $validated === true )return; |
205 | 205 | $this->setSessionValues( 'errors', [] ); |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function validateHoneyPot() |
216 | 216 | { |
217 | - if( !empty( $this->error ))return; |
|
218 | - if( empty( $this->request['gotcha'] ))return; |
|
217 | + if( !empty($this->error) )return; |
|
218 | + if( empty($this->request['gotcha']) )return; |
|
219 | 219 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
220 | 220 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
221 | 221 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function validateRecaptcha() |
227 | 227 | { |
228 | - if( !empty( $this->error ))return; |
|
228 | + if( !empty($this->error) )return; |
|
229 | 229 | $status = $this->getRecaptchaStatus(); |
230 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
230 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
231 | 231 | if( $status == static::RECAPTCHA_EMPTY ) { |
232 | 232 | $this->setSessionValues( 'recaptcha', 'unset' ); |
233 | 233 | $this->recaptchaIsUnset = true; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | protected function validateRequest( array $request ) |
249 | 249 | { |
250 | - if( !$this->isRequestValid( $request )) { |
|
250 | + if( !$this->isRequestValid( $request ) ) { |
|
251 | 251 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
252 | 252 | return $request; |
253 | 253 | } |
@@ -60,7 +60,9 @@ discard block |
||
60 | 60 | public function catchFatalError() |
61 | 61 | { |
62 | 62 | $error = error_get_last(); |
63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
64 | + return; |
|
65 | + } |
|
64 | 66 | glsr_log()->error( $error['message'] ); |
65 | 67 | } |
66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $filePaths[] = $this->path( $view ); |
112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 115 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
116 | + if( !file_exists( $file )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | return $file; |
116 | 120 | } |
117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
215 | 219 | */ |
216 | 220 | public function scheduleCronJob() |
217 | 221 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
223 | + return; |
|
224 | + } |
|
219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 226 | } |
221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
256 | 262 | || $data['action'] != 'update' |
257 | 263 | || $data['type'] != 'plugin' |
258 | - )return; |
|
264 | + ) { |
|
265 | + return; |
|
266 | + } |
|
259 | 267 | $this->upgrade(); |
260 | 268 | } |
261 | 269 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | static::$instance = $this; |
36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
37 | 37 | $plugin = get_file_data( $this->file, [ |
38 | 38 | 'languages' => 'Domain Path', |
39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $constant = 'static::'.$property; |
87 | 87 | return defined( $constant ) |
88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
89 | 89 | : ''; |
90 | 90 | } |
91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function file( $view ) |
105 | 105 | { |
106 | - $view.= '.php'; |
|
106 | + $view .= '.php'; |
|
107 | 107 | $filePaths = []; |
108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
110 | 110 | } |
111 | 111 | $filePaths[] = $this->path( $view ); |
112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 113 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
114 | + if( !file_exists( $file ) )continue; |
|
115 | 115 | return $file; |
116 | 116 | } |
117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getDefaults() |
123 | 123 | { |
124 | - if( empty( $this->defaults )) { |
|
124 | + if( empty($this->defaults) ) { |
|
125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
126 | 126 | $this->upgrade(); |
127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function hasPermission() |
135 | 135 | { |
136 | 136 | $isAdmin = $this->isAdmin(); |
137 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
137 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $path = plugin_dir_path( $this->file ); |
164 | 164 | if( !$realpath ) { |
165 | - $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file )); |
|
165 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
166 | 166 | } |
167 | 167 | $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
168 | 168 | return apply_filters( 'site-reviews/path', $path, $file ); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
195 | 195 | $this->reviewTypes = wp_parse_args( $types, [ |
196 | 196 | 'local' => __( 'Local', 'site-reviews' ), |
197 | - ]); |
|
197 | + ] ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
207 | 207 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
208 | - if( !file_exists( $file )) { |
|
208 | + if( !file_exists( $file ) ) { |
|
209 | 209 | glsr_log()->error( 'File not found: '.$file ); |
210 | 210 | return; |
211 | 211 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function scheduleCronJob() |
221 | 221 | { |
222 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
222 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
223 | 223 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
224 | 224 | } |
225 | 225 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function unscheduleCronJob() |
239 | 239 | { |
240 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
240 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public function url( $path = '' ) |
271 | 271 | { |
272 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
272 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
273 | 273 | return apply_filters( 'site-reviews/url', $url, $path ); |
274 | 274 | } |
275 | 275 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) { |
36 | 36 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
37 | 37 | // @see https://developers.google.com/search/docs/data-types/review |
38 | - if( $review->review_type != 'local' )continue; |
|
38 | + if( $review->review_type != 'local' ) { |
|
39 | + continue; |
|
40 | + } |
|
39 | 41 | $reviews[] = $this->buildReview( $review ); |
40 | 42 | } |
41 | 43 | if( !empty( $reviews )) { |
@@ -80,7 +82,9 @@ discard block |
||
80 | 82 | */ |
81 | 83 | public function render() |
82 | 84 | { |
83 | - if( empty( glsr()->schemas ))return; |
|
85 | + if( empty( glsr()->schemas )) { |
|
86 | + return; |
|
87 | + } |
|
84 | 88 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
85 | 89 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
86 | 90 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -132,7 +136,9 @@ discard block |
||
132 | 136 | { |
133 | 137 | foreach( $values as $value ) { |
134 | 138 | $option = $this->getSchemaOptionValue( $value ); |
135 | - if( empty( $option ))continue; |
|
139 | + if( empty( $option )) { |
|
140 | + continue; |
|
141 | + } |
|
136 | 142 | $schema->$value( $option ); |
137 | 143 | } |
138 | 144 | return $schema; |
@@ -242,7 +248,9 @@ discard block |
||
242 | 248 | if( $value != $fallback ) { |
243 | 249 | return $value; |
244 | 250 | } |
245 | - if( !is_single() && !is_page() )return; |
|
251 | + if( !is_single() && !is_page() ) { |
|
252 | + return; |
|
253 | + } |
|
246 | 254 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
247 | 255 | if( method_exists( $this, $method )) { |
248 | 256 | return $this->$method(); |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | if( $review->review_type != 'local' )continue; |
39 | 39 | $reviews[] = $this->buildReview( $review ); |
40 | 40 | } |
41 | - if( !empty( $reviews )) { |
|
41 | + if( !empty($reviews) ) { |
|
42 | 42 | array_walk( $reviews, function( &$review ) { |
43 | - unset( $review['@context'] ); |
|
44 | - unset( $review['itemReviewed'] ); |
|
43 | + unset($review['@context']); |
|
44 | + unset($review['itemReviewed']); |
|
45 | 45 | }); |
46 | 46 | $schema['review'] = $reviews; |
47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function buildSummary( $args = null ) |
56 | 56 | { |
57 | - if( is_array( $args )) { |
|
57 | + if( is_array( $args ) ) { |
|
58 | 58 | $this->args = $args; |
59 | 59 | } |
60 | 60 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $schema = method_exists( $this, $buildSummary ) |
63 | 63 | ? $this->$buildSummary() |
64 | 64 | : $this->buildSummaryForCustom(); |
65 | - if( !empty( $count )) { |
|
65 | + if( !empty($count) ) { |
|
66 | 66 | $schema->aggregateRating( |
67 | 67 | $this->getSchemaType( 'AggregateRating' ) |
68 | 68 | ->ratingValue( $this->getRatingValue() ) |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function render() |
82 | 82 | { |
83 | - if( empty( glsr()->schemas ))return; |
|
83 | + if( empty(glsr()->schemas) )return; |
|
84 | 84 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
85 | 85 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
86 | 86 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
87 | - )); |
|
87 | + ) ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $schemas = glsr()->schemas; |
96 | 96 | $schemas[] = $schema; |
97 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
97 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | protected function buildReview( $review ) |
105 | 105 | { |
106 | 106 | $schema = $this->getSchemaType( 'Review' ) |
107 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
107 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
108 | 108 | $schema->name( $review->title ); |
109 | 109 | }) |
110 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
110 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
111 | 111 | $schema->reviewBody( $review->content ); |
112 | 112 | }) |
113 | - ->datePublished(( new DateTime( $review->date ))) |
|
114 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
115 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
116 | - if( !empty( $review->rating )) { |
|
113 | + ->datePublished( (new DateTime( $review->date )) ) |
|
114 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
115 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
116 | + if( !empty($review->rating) ) { |
|
117 | 117 | $schema->reviewRating( |
118 | 118 | $this->getSchemaType( 'Rating' ) |
119 | 119 | ->ratingValue( $review->rating ) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | foreach( $values as $value ) { |
134 | 134 | $option = $this->getSchemaOptionValue( $value ); |
135 | - if( empty( $option ))continue; |
|
135 | + if( empty($option) )continue; |
|
136 | 136 | $schema->$value( $option ); |
137 | 137 | } |
138 | 138 | return $schema; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
147 | 147 | 'description', 'image', 'name', 'url', |
148 | - ]); |
|
148 | + ] ); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
157 | 157 | 'address', 'priceRange', 'telephone', |
158 | - ]); |
|
158 | + ] ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | { |
166 | 166 | $offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [ |
167 | 167 | 'highPrice', 'lowPrice', 'priceCurrency', |
168 | - ]); |
|
168 | + ] ); |
|
169 | 169 | return $this->buildSummaryForCustom() |
170 | 170 | ->offers( $offers ) |
171 | - ->setProperty( '@id', $this->getSchemaOptionValue( 'url' )); |
|
171 | + ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getRatingCounts() |
178 | 178 | { |
179 | - if( !isset( $this->ratingCounts )) { |
|
179 | + if( !isset($this->ratingCounts) ) { |
|
180 | 180 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args ); |
181 | 181 | } |
182 | 182 | return $this->ratingCounts; |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | protected function getSchemaOption( $option, $fallback ) |
199 | 199 | { |
200 | 200 | $option = strtolower( $option ); |
201 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
201 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
202 | 202 | return $schemaOption; |
203 | 203 | } |
204 | 204 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
205 | - if( is_array( $setting )) { |
|
205 | + if( is_array( $setting ) ) { |
|
206 | 206 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
207 | 207 | } |
208 | - return !empty( $setting ) |
|
208 | + return !empty($setting) |
|
209 | 209 | ? $setting |
210 | 210 | : $fallback; |
211 | 211 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $setting = wp_parse_args( $setting, [ |
220 | 220 | 'custom' => '', |
221 | 221 | 'default' => $fallback, |
222 | - ]); |
|
222 | + ] ); |
|
223 | 223 | return $setting['default'] != 'custom' |
224 | 224 | ? $setting['default'] |
225 | 225 | : $setting['custom']; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | } |
239 | 239 | if( !is_single() && !is_page() )return; |
240 | 240 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
241 | - if( method_exists( $this, $method )) { |
|
241 | + if( method_exists( $this, $method ) ) { |
|
242 | 242 | return $this->$method(); |
243 | 243 | } |
244 | 244 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | protected function getSchemaType( $type = null ) |
251 | 251 | { |
252 | - if( !is_string( $type )) { |
|
252 | + if( !is_string( $type ) ) { |
|
253 | 253 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
254 | 254 | } |
255 | 255 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | protected function getThingDescription() |
265 | 265 | { |
266 | 266 | $post = get_post(); |
267 | - if( !( $post instanceof WP_Post )) { |
|
267 | + if( !($post instanceof WP_Post) ) { |
|
268 | 268 | return ''; |
269 | 269 | } |
270 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
271 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
270 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
271 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function __construct( array $values = [] ) |
16 | 16 | { |
17 | 17 | $this->values = $values; |
18 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
18 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __toString() |
35 | 35 | { |
36 | - if( empty( $this->values ))return; |
|
36 | + if( empty($this->values) )return; |
|
37 | 37 | return glsr( Template::class )->build( 'templates/review', [ |
38 | 38 | 'context' => $this->values, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | } |
41 | 41 | } |
@@ -33,7 +33,9 @@ |
||
33 | 33 | */ |
34 | 34 | public function __toString() |
35 | 35 | { |
36 | - if( empty( $this->values ))return; |
|
36 | + if( empty( $this->values )) { |
|
37 | + return; |
|
38 | + } |
|
37 | 39 | return glsr( Template::class )->build( 'templates/review', [ |
38 | 40 | 'context' => $this->values, |
39 | 41 | ]); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->results = $reviews; |
32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function build( array $args = [] ) |
70 | 70 | { |
71 | - if( empty( $this->ID )) { |
|
71 | + if( empty($this->ID) ) { |
|
72 | 72 | return new ReviewHtml; |
73 | 73 | } |
74 | 74 | $partial = glsr( SiteReviewsPartial::class ); |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function offsetGet( $key ) |
94 | 94 | { |
95 | - if( property_exists( $this, $key )) { |
|
95 | + if( property_exists( $this, $key ) ) { |
|
96 | 96 | return $this->$key; |
97 | 97 | } |
98 | - if( array_key_exists( $key, (array)$this->custom )) { |
|
98 | + if( array_key_exists( $key, (array)$this->custom ) ) { |
|
99 | 99 | return $this->custom[$key]; |
100 | 100 | } |
101 | 101 | return null; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function offsetSet( $key, $value ) |
110 | 110 | { |
111 | - if( property_exists( $this, $key )) { |
|
111 | + if( property_exists( $this, $key ) ) { |
|
112 | 112 | $this->$key = $value; |
113 | 113 | return; |
114 | 114 | } |
115 | - if( !is_array( $this->custom )) { |
|
115 | + if( !is_array( $this->custom ) ) { |
|
116 | 116 | $this->custom = array_filter( (array)$this->custom ); |
117 | 117 | } |
118 | 118 | $this->custom[$key] = $value; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | 'review_type' => 'local', |
158 | 158 | ]; |
159 | 159 | $meta = array_filter( |
160 | - array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))), |
|
160 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
161 | 161 | 'strlen' |
162 | 162 | ); |
163 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
163 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
164 | 164 | $this->modified = $this->isModified( $properties ); |
165 | 165 | array_walk( $properties, function( $value, $key ) { |
166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
166 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
167 | 167 | $this->$key = maybe_unserialize( $value ); |
168 | 168 | }); |
169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | protected function setTermIds( WP_Post $post ) |
175 | 175 | { |
176 | 176 | $this->term_ids = []; |
177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
177 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
178 | 178 | foreach( $terms as $term ) { |
179 | 179 | $this->term_ids[] = $term->term_id; |
180 | 180 | } |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct( WP_Post $post ) |
38 | 38 | { |
39 | - if( $post->post_type != Application::POST_TYPE )return; |
|
39 | + if( $post->post_type != Application::POST_TYPE ) { |
|
40 | + return; |
|
41 | + } |
|
40 | 42 | $this->content = $post->post_content; |
41 | 43 | $this->date = $post->post_date; |
42 | 44 | $this->ID = intval( $post->ID ); |
@@ -163,7 +165,9 @@ discard block |
||
163 | 165 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
164 | 166 | $this->modified = $this->isModified( $properties ); |
165 | 167 | array_walk( $properties, function( $value, $key ) { |
166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
168 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
169 | + return; |
|
170 | + } |
|
167 | 171 | $this->$key = maybe_unserialize( $value ); |
168 | 172 | }); |
169 | 173 | } |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | protected function setTermIds( WP_Post $post ) |
175 | 179 | { |
176 | 180 | $this->term_ids = []; |
177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
181 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
182 | + return; |
|
183 | + } |
|
178 | 184 | foreach( $terms as $term ) { |
179 | 185 | $this->term_ids[] = $term->term_id; |
180 | 186 | } |