@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | $this->args = $args; |
34 | 34 | $this->reviews = glsr( Database::class )->getReviews( $args ); |
35 | - if( $this->isHidden() )return; |
|
35 | + if( $this->isHidden() ) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews->results ); |
37 | 39 | $this->buildSchema(); |
38 | 40 | return glsr( Builder::class )->div( $this->buildSummary().$this->buildPercentageBars(), [ |
@@ -72,7 +74,9 @@ discard block |
||
72 | 74 | */ |
73 | 75 | protected function buildPercentageBars() |
74 | 76 | { |
75 | - if( in_array( 'bars', $this->args['hide'] ))return; |
|
77 | + if( in_array( 'bars', $this->args['hide'] )) { |
|
78 | + return; |
|
79 | + } |
|
76 | 80 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews->results )); |
77 | 81 | $range = range( Rating::MAX_RATING, 1 ); |
78 | 82 | $bars = array_reduce( $range, function( $carry, $index ) use( $percentages ) { |
@@ -88,7 +92,9 @@ discard block |
||
88 | 92 | */ |
89 | 93 | protected function buildSchema() |
90 | 94 | { |
91 | - if( !$this->args['schema'] )return; |
|
95 | + if( !$this->args['schema'] ) { |
|
96 | + return; |
|
97 | + } |
|
92 | 98 | $schema = glsr( Schema::class ); |
93 | 99 | $schema->store( $schema->buildSummary( $this->args )); |
94 | 100 | } |
@@ -99,7 +105,9 @@ discard block |
||
99 | 105 | protected function buildSummary() |
100 | 106 | { |
101 | 107 | $summary = $this->buildSummaryRating().$this->buildSummaryStars().$this->buildSummaryText(); |
102 | - if( empty( $summary ))return; |
|
108 | + if( empty( $summary )) { |
|
109 | + return; |
|
110 | + } |
|
103 | 111 | return glsr( Builder::class )->div( $summary, [ |
104 | 112 | 'class' => 'glsr-summary', |
105 | 113 | ]); |
@@ -110,7 +118,9 @@ discard block |
||
110 | 118 | */ |
111 | 119 | protected function buildSummaryRating() |
112 | 120 | { |
113 | - if( in_array( 'rating', $this->args['hide'] ))return; |
|
121 | + if( in_array( 'rating', $this->args['hide'] )) { |
|
122 | + return; |
|
123 | + } |
|
114 | 124 | return glsr( Builder::class )->span( $this->rating, [ |
115 | 125 | 'class' => 'glsr-summary-rating', |
116 | 126 | ]); |
@@ -121,7 +131,9 @@ discard block |
||
121 | 131 | */ |
122 | 132 | protected function buildSummaryStars() |
123 | 133 | { |
124 | - if( in_array( 'stars', $this->args['hide'] ))return; |
|
134 | + if( in_array( 'stars', $this->args['hide'] )) { |
|
135 | + return; |
|
136 | + } |
|
125 | 137 | $stars = glsr( Html::class )->buildPartial( 'star-rating', [ |
126 | 138 | 'rating' => $this->rating, |
127 | 139 | ]); |
@@ -135,7 +147,9 @@ discard block |
||
135 | 147 | */ |
136 | 148 | protected function buildSummaryText() |
137 | 149 | { |
138 | - if( in_array( 'summary', $this->args['hide'] ))return; |
|
150 | + if( in_array( 'summary', $this->args['hide'] )) { |
|
151 | + return; |
|
152 | + } |
|
139 | 153 | $count = count( $this->reviews->results ); |
140 | 154 | if( empty( $this->args['text'] )) { |
141 | 155 | $this->args['text'] = _nx( |
@@ -19,7 +19,9 @@ |
||
19 | 19 | public function build( $name, array $args = [] ) |
20 | 20 | { |
21 | 21 | $this->normalize( $args ); |
22 | - if( count( $this->args['tabs'] ) < 2 )return; |
|
22 | + if( count( $this->args['tabs'] ) < 2 ) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | $links = array_reduce( array_keys( $this->args['tabs'] ), function( $result, $tab ) { |
24 | 26 | return $result.$this->buildLink( $tab ); |
25 | 27 | }); |
@@ -37,7 +37,9 @@ |
||
37 | 37 | $lines = explode( "\n", $blacklist ); |
38 | 38 | foreach( (array) $lines as $line ) { |
39 | 39 | $line = trim( $line ); |
40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
40 | + if( empty( $line ) || 256 < strlen( $line )) { |
|
41 | + continue; |
|
42 | + } |
|
41 | 43 | $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
42 | 44 | if( preg_match( $pattern, $target )) { |
43 | 45 | return true; |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function send() |
65 | 65 | { |
66 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
66 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | $sent = wp_mail( |
68 | 70 | $this->to, |
69 | 71 | $this->subject, |
@@ -82,7 +84,9 @@ discard block |
||
82 | 84 | */ |
83 | 85 | public function buildPlainTextMessage( $phpmailer ) |
84 | 86 | { |
85 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
87 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
88 | + return; |
|
89 | + } |
|
86 | 90 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
87 | 91 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
88 | 92 | } |
@@ -116,8 +120,7 @@ discard block |
||
116 | 120 | $template = trim( glsr_get_option( 'general.notification_message' )); |
117 | 121 | if( !empty( $template )) { |
118 | 122 | $message = glsr( Template::class )->interpolate( $template, $email['template-tags'] ); |
119 | - } |
|
120 | - else if( $email['template'] ) { |
|
123 | + } else if( $email['template'] ) { |
|
121 | 124 | $message = glsr( Template::class )->build( 'templates/'.$email['template'], [ |
122 | 125 | 'context' => $email['template-tags'], |
123 | 126 | ]); |
@@ -190,7 +190,9 @@ discard block |
||
190 | 190 | if( $index === false |
191 | 191 | || !isset( $caller[$index+2]['class'] ) |
192 | 192 | || !isset( $caller[$index+2]['function'] ) |
193 | - )return; |
|
193 | + ) { |
|
194 | + return; |
|
195 | + } |
|
194 | 196 | return sprintf( '[%s()->%s:%s] ', |
195 | 197 | $caller[$index+2]['class'], |
196 | 198 | $caller[$index+2]['function'], |
@@ -233,8 +235,7 @@ discard block |
||
233 | 235 | { |
234 | 236 | if( $value instanceof DateTime ) { |
235 | 237 | $value = $value->format( 'Y-m-d H:i:s' ); |
236 | - } |
|
237 | - else if( $this->isObjectOrArray( $value )) { |
|
238 | + } else if( $this->isObjectOrArray( $value )) { |
|
238 | 239 | $value = json_encode( $value ); |
239 | 240 | } |
240 | 241 | return (string)$value; |
@@ -15,7 +15,9 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function add( $type, $message, array $args = [] ) |
17 | 17 | { |
18 | - if( empty( array_filter( [$message, $type] )))return; |
|
18 | + if( empty( array_filter( [$message, $type] ))) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | $args['message'] = $message; |
20 | 22 | $args['type'] = $type; |
21 | 23 | add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
@@ -56,7 +58,9 @@ discard block |
||
56 | 58 | $notices = array_map( 'unserialize', |
57 | 59 | array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
58 | 60 | ); |
59 | - if( empty( $notices ))return; |
|
61 | + if( empty( $notices )) { |
|
62 | + return; |
|
63 | + } |
|
60 | 64 | return array_reduce( $notices, function( $carry, $notice ) { |
61 | 65 | return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
62 | 66 | }); |
@@ -30,7 +30,9 @@ |
||
30 | 30 | { |
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | - if( $diff > $timePeriod[0] )continue; |
|
33 | + if( $diff > $timePeriod[0] ) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $unit = floor( $diff / $timePeriod[1] ); |
35 | 37 | $relativeDates = [ |
36 | 38 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
@@ -83,7 +83,9 @@ discard block |
||
83 | 83 | get_mu_plugins(), |
84 | 84 | get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
85 | 85 | ); |
86 | - if( empty( $plugins ))return; |
|
86 | + if( empty( $plugins )) { |
|
87 | + return; |
|
88 | + } |
|
87 | 89 | return $this->normalizePluginList( $plugins ); |
88 | 90 | } |
89 | 91 | |
@@ -92,7 +94,9 @@ discard block |
||
92 | 94 | */ |
93 | 95 | public function getMultisitePluginDetails() |
94 | 96 | { |
95 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
97 | + if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] ))) { |
|
98 | + return; |
|
99 | + } |
|
96 | 100 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
97 | 101 | } |
98 | 102 | |
@@ -146,12 +150,16 @@ discard block |
||
146 | 150 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
147 | 151 | $settings = $helper->flattenArray( $settings ); |
148 | 152 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
149 | - if( empty( $settings[$key] ))continue; |
|
153 | + if( empty( $settings[$key] )) { |
|
154 | + continue; |
|
155 | + } |
|
150 | 156 | $settings[$key] = str_repeat( '*', 10 ); |
151 | 157 | } |
152 | 158 | $details = []; |
153 | 159 | foreach( $settings as $key => $value ) { |
154 | - if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
160 | + if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key )) { |
|
161 | + continue; |
|
162 | + } |
|
155 | 163 | $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
156 | 164 | $details[$key] = $value; |
157 | 165 | } |
@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | if( time() > $this->expiryTimestampReset ) { |
42 | 42 | $this->setCookieExpiration(); |
43 | 43 | } |
44 | - } |
|
45 | - else { |
|
44 | + } else { |
|
46 | 45 | $this->sessionId = $this->generateSessionId(); |
47 | 46 | $this->setCookieExpiration(); |
48 | 47 | } |
@@ -161,7 +160,9 @@ discard block |
||
161 | 160 | if( !empty( $sessions )) { |
162 | 161 | $now = time(); |
163 | 162 | foreach( $sessions as $session ) { |
164 | - if( $now <= $session->expiration )continue; |
|
163 | + if( $now <= $session->expiration ) { |
|
164 | + continue; |
|
165 | + } |
|
165 | 166 | $expiredSessions[] = $session->name; |
166 | 167 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
167 | 168 | } |
@@ -204,7 +205,9 @@ discard block |
||
204 | 205 | */ |
205 | 206 | protected function setCookie() |
206 | 207 | { |
207 | - if( headers_sent() )return; |
|
208 | + if( headers_sent() ) { |
|
209 | + return; |
|
210 | + } |
|
208 | 211 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | 212 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( get_option( 'home' ))); |
210 | 213 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -226,8 +229,7 @@ discard block |
||
226 | 229 | { |
227 | 230 | if( false === get_option( $this->getSessionId() )) { |
228 | 231 | $this->createSession(); |
229 | - } |
|
230 | - else { |
|
232 | + } else { |
|
231 | 233 | update_option( $this->getSessionId(), $this->sessionData, false ); |
232 | 234 | } |
233 | 235 | } |