@@ -153,7 +153,9 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function scheduleCronJob() |
155 | 155 | { |
156 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
156 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
157 | + return; |
|
158 | + } |
|
157 | 159 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
158 | 160 | } |
159 | 161 | |
@@ -184,7 +186,9 @@ discard block |
||
184 | 186 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
185 | 187 | || $data['action'] != 'update' |
186 | 188 | || $data['type'] != 'plugin' |
187 | - )return; |
|
189 | + ) { |
|
190 | + return; |
|
191 | + } |
|
188 | 192 | $this->upgrade(); |
189 | 193 | } |
190 | 194 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getDefaults() |
68 | 68 | { |
69 | - if( empty( $this->defaults )) { |
|
69 | + if( empty($this->defaults) ) { |
|
70 | 70 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
71 | 71 | $this->upgrade(); |
72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function hasPermission() |
80 | 80 | { |
81 | 81 | $isAdmin = $this->isAdmin(); |
82 | - return !$isAdmin || ( $isAdmin && current_user_can( static::CAPABILITY )); |
|
82 | + return !$isAdmin || ($isAdmin && current_user_can( static::CAPABILITY )); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
135 | 135 | $this->reviewTypes = wp_parse_args( $types, [ |
136 | 136 | 'local' => __( 'Local', 'site-reviews' ), |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | public function render( $view, array $data = [] ) |
145 | 145 | { |
146 | 146 | $file = ''; |
147 | - if( glsr( Helper::class )->startsWith( $view, 'templates/' )) { |
|
147 | + if( glsr( Helper::class )->startsWith( $view, 'templates/' ) ) { |
|
148 | 148 | $file = str_replace( 'templates/', 'site-reviews/', $view ).'.php'; |
149 | 149 | $file = get_stylesheet_directory().'/'.$file; |
150 | 150 | } |
151 | - if( !file_exists( $file )) { |
|
151 | + if( !file_exists( $file ) ) { |
|
152 | 152 | $file = $this->path( 'views/'.$view.'.php' ); |
153 | 153 | } |
154 | 154 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
155 | - if( !file_exists( $file )) { |
|
155 | + if( !file_exists( $file ) ) { |
|
156 | 156 | glsr_log()->error( 'File not found: '.$file ); |
157 | 157 | return; |
158 | 158 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function scheduleCronJob() |
168 | 168 | { |
169 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
169 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
170 | 170 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
171 | 171 | } |
172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function unscheduleCronJob() |
177 | 177 | { |
178 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
178 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -207,6 +207,6 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function url( $path = '' ) |
209 | 209 | { |
210 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
210 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
211 | 211 | } |
212 | 212 | } |
@@ -76,7 +76,9 @@ discard block |
||
76 | 76 | $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
77 | 77 | array_walk( $args, function( &$value, $key ) { |
78 | 78 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
79 | - if( !method_exists( $this, $methodName ))return; |
|
79 | + if( !method_exists( $this, $methodName )) { |
|
80 | + return; |
|
81 | + } |
|
80 | 82 | $value = $this->$methodName( $value ); |
81 | 83 | }); |
82 | 84 | return $this->sanitize( $args ); |
@@ -141,7 +143,9 @@ discard block |
||
141 | 143 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
142 | 144 | $labels = array_map( 'trim', explode( ',', $labels )); |
143 | 145 | foreach( $defaults as $i => $label ) { |
144 | - if( empty( $labels[$i] ))continue; |
|
146 | + if( empty( $labels[$i] )) { |
|
147 | + continue; |
|
148 | + } |
|
145 | 149 | $defaults[$i] = $labels[$i]; |
146 | 150 | } |
147 | 151 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | 'after_widget' => '</div>', |
23 | 23 | 'before_title' => '<h3 class="glsr-shortcode-title">', |
24 | 24 | 'after_title' => '</h3>', |
25 | - ]); |
|
25 | + ] ); |
|
26 | 26 | $instance = $this->normalize( $instance ); |
27 | 27 | $partial = glsr( Html::class )->buildPartial( $shortcodePartial, $instance ); |
28 | - if( !empty( $instance['title'] )) { |
|
28 | + if( !empty($instance['title']) ) { |
|
29 | 29 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
30 | 30 | } |
31 | 31 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function normalize( $args ) |
70 | 70 | { |
71 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
71 | + $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args ) ); |
|
72 | 72 | array_walk( $args, function( &$value, $key ) { |
73 | 73 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
74 | - if( !method_exists( $this, $methodName ))return; |
|
74 | + if( !method_exists( $this, $methodName ) )return; |
|
75 | 75 | $value = $this->$methodName( $value ); |
76 | 76 | }); |
77 | 77 | return $this->sanitize( $args ); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function normalizeHide( $hide ) |
105 | 105 | { |
106 | - if( is_string( $hide )) { |
|
106 | + if( is_string( $hide ) ) { |
|
107 | 107 | $hide = explode( ',', $hide ); |
108 | 108 | } |
109 | 109 | $hiddenKeys = defined( 'static::HIDDEN_KEYS' ) |
110 | 110 | ? static::HIDDEN_KEYS |
111 | 111 | : []; |
112 | - return array_filter( array_map( 'trim', $hide ), function( $value ) use( $hiddenKeys ) { |
|
112 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use($hiddenKeys) { |
|
113 | 113 | return in_array( $value, $hiddenKeys ); |
114 | 114 | }); |
115 | 115 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | __( 'Terrible', 'site-reviews' ), |
138 | 138 | ]; |
139 | 139 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
140 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
140 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
141 | 141 | foreach( $defaults as $i => $label ) { |
142 | - if( empty( $labels[$i] ))continue; |
|
142 | + if( empty($labels[$i]) )continue; |
|
143 | 143 | $defaults[$i] = $labels[$i]; |
144 | 144 | } |
145 | 145 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |
@@ -29,7 +29,9 @@ |
||
29 | 29 | { |
30 | 30 | foreach( $args as $key => $value ) { |
31 | 31 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
32 | - if( !property_exists( $this, $property ))continue; |
|
32 | + if( !property_exists( $this, $property )) { |
|
33 | + continue; |
|
34 | + } |
|
33 | 35 | $this->$property = $value; |
34 | 36 | unset( $args[$key] ); |
35 | 37 | } |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | { |
31 | 31 | foreach( $args as $key => $value ) { |
32 | 32 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
33 | - if( !property_exists( $this, $property ))continue; |
|
33 | + if( !property_exists( $this, $property ) )continue; |
|
34 | 34 | $this->$property = $value; |
35 | - unset( $args[$key] ); |
|
35 | + unset($args[$key]); |
|
36 | 36 | } |
37 | 37 | $this->args = wp_parse_args( $args, [ |
38 | 38 | 'menu_name' => $this->plural, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | 'singular_name' => $this->single, |
60 | 60 | 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
61 | 61 | 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
62 | - ]); |
|
63 | - unset( $this->args['menu_name'] ); |
|
62 | + ] ); |
|
63 | + unset($this->args['menu_name']); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | protected function normalizeColumns() |
70 | 70 | { |
71 | 71 | $this->columns = ['cb' => ''] + $this->columns; |
72 | - if( array_key_exists( 'category', $this->columns )) { |
|
72 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
73 | 73 | $keys = array_keys( $this->columns ); |
74 | 74 | $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
75 | 75 | $this->columns = array_combine( $keys, $this->columns ); |
76 | 76 | } |
77 | - if( array_key_exists( 'pinned', $this->columns )) { |
|
77 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
78 | 78 | $this->columns['pinned'] = glsr( Builder::class )->span( |
79 | 79 | '<span>'.$this->columns['pinned'].'</span>', |
80 | 80 | ['class' => 'pinned-icon'] |
@@ -181,7 +181,9 @@ discard block |
||
181 | 181 | $key = $value; |
182 | 182 | $value = true; |
183 | 183 | } |
184 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
184 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
185 | + continue; |
|
186 | + } |
|
185 | 187 | $this->attributes[$key] = wp_validate_boolean( $value ); |
186 | 188 | } |
187 | 189 | } |
@@ -196,7 +198,9 @@ discard block |
||
196 | 198 | $key = $value; |
197 | 199 | $value = ''; |
198 | 200 | } |
199 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
201 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
202 | + continue; |
|
203 | + } |
|
200 | 204 | if( is_array( $value )) { |
201 | 205 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
202 | 206 | } |
@@ -210,7 +214,9 @@ discard block |
||
210 | 214 | protected function normalizeStringAttributes() |
211 | 215 | { |
212 | 216 | foreach( $this->attributes as $key => $value ) { |
213 | - if( !is_string( $value ))continue; |
|
217 | + if( !is_string( $value )) { |
|
218 | + continue; |
|
219 | + } |
|
214 | 220 | $this->attributes[$key] = trim( $value ); |
215 | 221 | } |
216 | 222 | } |
@@ -221,7 +227,9 @@ discard block |
||
221 | 227 | */ |
222 | 228 | protected function normalizeInputType( $method ) |
223 | 229 | { |
224 | - if( $method != 'input' )return; |
|
230 | + if( $method != 'input' ) { |
|
231 | + return; |
|
232 | + } |
|
225 | 233 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
226 | 234 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
227 | 235 | $this->attributes['type'] = 'text'; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function filterAttributes( array $allowedAttributeKeys ) |
119 | 119 | { |
120 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
120 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
129 | 129 | $wildcards = []; |
130 | 130 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
131 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
131 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
132 | 132 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
133 | 133 | }, ARRAY_FILTER_USE_KEY ); |
134 | 134 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | protected function getPermanentAttributes() |
143 | 143 | { |
144 | 144 | $permanentAttributes = []; |
145 | - if( array_key_exists( 'value', $this->attributes )) { |
|
145 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
146 | 146 | $permanentAttributes['value'] = $this->attributes['value']; |
147 | 147 | } |
148 | 148 | return $permanentAttributes; |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | protected function normalizeBooleanAttributes() |
195 | 195 | { |
196 | 196 | foreach( $this->attributes as $key => $value ) { |
197 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
197 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
198 | 198 | $key = $value; |
199 | 199 | $value = true; |
200 | 200 | } |
201 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
201 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
202 | 202 | $this->attributes[$key] = wp_validate_boolean( $value ); |
203 | 203 | } |
204 | 204 | } |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | protected function normalizeDataAttributes() |
210 | 210 | { |
211 | 211 | foreach( $this->attributes as $key => $value ) { |
212 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
212 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
213 | 213 | $key = $value; |
214 | 214 | $value = ''; |
215 | 215 | } |
216 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
217 | - if( is_array( $value )) { |
|
216 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
217 | + if( is_array( $value ) ) { |
|
218 | 218 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
219 | 219 | } |
220 | 220 | $this->attributes[$key] = $value; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | protected function normalizeStringAttributes() |
228 | 228 | { |
229 | 229 | foreach( $this->attributes as $key => $value ) { |
230 | - if( !is_string( $value ))continue; |
|
230 | + if( !is_string( $value ) )continue; |
|
231 | 231 | $this->attributes[$key] = trim( $value ); |
232 | 232 | } |
233 | 233 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | if( $method != 'input' )return; |
242 | 242 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
243 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
243 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
244 | 244 | $this->attributes['type'] = 'text'; |
245 | 245 | } |
246 | 246 | } |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | $permanentAttributes = $this->getPermanentAttributes(); |
255 | 255 | foreach( $this->attributes as $key => $value ) { |
256 | 256 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
257 | - unset( $attributes[$key] ); |
|
257 | + unset($attributes[$key]); |
|
258 | 258 | } |
259 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
259 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
260 | 260 | $permanentAttributes[$key] = $value; |
261 | - unset( $attributes[$key] ); |
|
261 | + unset($attributes[$key]); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -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; |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function isBlacklisted( CreateReview $review ) |
14 | 14 | { |
15 | - $target = implode( "\n", array_filter([ |
|
15 | + $target = implode( "\n", array_filter( [ |
|
16 | 16 | $review->author, |
17 | 17 | $review->content, |
18 | 18 | $review->email, |
19 | 19 | $review->ipAddress, |
20 | 20 | $review->title, |
21 | - ])); |
|
22 | - return (bool) apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
21 | + ] ) ); |
|
22 | + return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
23 | 23 | $this->check( $target ), |
24 | 24 | $review |
25 | 25 | ); |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function check( $target ) |
33 | 33 | { |
34 | - $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' )); |
|
35 | - if( empty( $blacklist )) { |
|
34 | + $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) ); |
|
35 | + if( empty($blacklist) ) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | $lines = explode( "\n", $blacklist ); |
39 | - foreach( (array) $lines as $line ) { |
|
39 | + foreach( (array)$lines as $line ) { |
|
40 | 40 | $line = trim( $line ); |
41 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
42 | - $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
|
43 | - if( preg_match( $pattern, $target )) { |
|
41 | + if( empty($line) || 256 < strlen( $line ) )continue; |
|
42 | + $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) ); |
|
43 | + if( preg_match( $pattern, $target ) ) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -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 | }); |
@@ -15,10 +15,10 @@ 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] )) )return; |
|
19 | 19 | $args['message'] = $message; |
20 | 20 | $args['type'] = $type; |
21 | - add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ))); |
|
21 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | public function get() |
55 | 55 | { |
56 | 56 | $notices = array_map( 'unserialize', |
57 | - array_unique( array_map( 'serialize', get_settings_errors( Application::ID ))) |
|
57 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
58 | 58 | ); |
59 | - if( empty( $notices ))return; |
|
59 | + if( empty($notices) )return; |
|
60 | 60 | return array_reduce( $notices, function( $carry, $notice ) { |
61 | - return $carry.$this->buildNotice( json_decode( $notice['message'], true )); |
|
61 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
62 | 62 | }); |
63 | 63 | } |
64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | return glsr( Builder::class )->div( $messages, [ |
81 | 81 | 'class' => $class, |
82 | - ]); |
|
82 | + ] ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | 'type' => '', |
95 | 95 | ]; |
96 | 96 | $args = shortcode_atts( $defaults, $args ); |
97 | - if( !in_array( $args['type'], ['error', 'warning', 'success'] )) { |
|
97 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
98 | 98 | $args['type'] = 'success'; |
99 | 99 | } |
100 | 100 | $args['messages'] = is_wp_error( $args['message'] ) |
101 | 101 | ? (array)$args['message']->get_error_message() |
102 | 102 | : (array)$args['message']; |
103 | - unset( $args['message'] ); |
|
103 | + unset($args['message']); |
|
104 | 104 | return $args; |
105 | 105 | } |
106 | 106 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | use PasswordHash; |
6 | 6 | |
7 | 7 | /** |
8 | - * This class is derived from WP Session Manager (1.2.0) |
|
9 | - */ |
|
8 | + * This class is derived from WP Session Manager (1.2.0) |
|
9 | + */ |
|
10 | 10 | class Session |
11 | 11 | { |
12 | 12 | const SESSION_COOKIE = '_glsr_session'; |
@@ -153,7 +153,7 @@ |
||
153 | 153 | $expiredSessions = []; |
154 | 154 | $sessions = $wpdb->get_results( |
155 | 155 | "SELECT option_name AS name, option_value AS expiration " . |
156 | - "FROM {$wpdb->options} " . |
|
156 | + "from {$wpdb->options} " . |
|
157 | 157 | "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " . |
158 | 158 | "ORDER BY option_value ASC " . |
159 | 159 | "LIMIT 0, ".absint( $limit ) |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() |
35 | 35 | { |
36 | - if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE )) { |
|
37 | - $cookie = explode( '||', stripslashes( $cookieId )); |
|
36 | + if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ) ) { |
|
37 | + $cookie = explode( '||', stripslashes( $cookieId ) ); |
|
38 | 38 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
39 | 39 | $this->expiryTimestamp = absint( $cookie[1] ); |
40 | 40 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | 80 | global $wpdb; |
81 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
81 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
82 | 82 | $wpdb->query( |
83 | 83 | "DELETE FROM {$wpdb->options} WHERE option_name IN ('{$expiredSessions}')" |
84 | 84 | ); |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | public function get( $key, $fallback = '', $unset = false ) |
95 | 95 | { |
96 | 96 | $key = sanitize_key( $key ); |
97 | - $value = isset( $this->sessionData[$key] ) |
|
97 | + $value = isset($this->sessionData[$key]) |
|
98 | 98 | ? maybe_unserialize( $this->sessionData[$key] ) |
99 | 99 | : $fallback; |
100 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
101 | - unset( $this->sessionData[$key] ); |
|
100 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
101 | + unset($this->sessionData[$key]); |
|
102 | 102 | $this->updateSession(); |
103 | 103 | } |
104 | 104 | return $value; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | protected function deleteSession() |
133 | 133 | { |
134 | 134 | delete_option( $this->getSessionId() ); |
135 | - delete_option( $this->getSessionId( 'expires' )); |
|
135 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function generateSessionId() |
142 | 142 | { |
143 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
143 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | global $wpdb; |
153 | 153 | $expiredSessions = []; |
154 | 154 | $sessions = $wpdb->get_results( |
155 | - "SELECT option_name AS name, option_value AS expiration " . |
|
156 | - "FROM {$wpdb->options} " . |
|
157 | - "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " . |
|
158 | - "ORDER BY option_value ASC " . |
|
155 | + "SELECT option_name AS name, option_value AS expiration ". |
|
156 | + "FROM {$wpdb->options} ". |
|
157 | + "WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' ". |
|
158 | + "ORDER BY option_value ASC ". |
|
159 | 159 | "LIMIT 0, ".absint( $limit ) |
160 | 160 | ); |
161 | - if( !empty( $sessions )) { |
|
161 | + if( !empty($sessions) ) { |
|
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | 164 | if( $now <= $session->expiration )continue; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function getSessionId( $separator = '' ) |
177 | 177 | { |
178 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
178 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | if( headers_sent() )return; |
208 | 208 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
209 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
210 | 210 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
211 | 211 | } |
212 | 212 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function updateSession() |
226 | 226 | { |
227 | - if( false === get_option( $this->getSessionId() )) { |
|
227 | + if( false === get_option( $this->getSessionId() ) ) { |
|
228 | 228 | $this->createSession(); |
229 | 229 | } |
230 | 230 | else { |
@@ -161,7 +161,9 @@ discard block |
||
161 | 161 | if( !empty( $sessions )) { |
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | - if( $now <= $session->expiration )continue; |
|
164 | + if( $now <= $session->expiration ) { |
|
165 | + continue; |
|
166 | + } |
|
165 | 167 | $expiredSessions[] = $session->name; |
166 | 168 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
167 | 169 | } |
@@ -204,7 +206,9 @@ discard block |
||
204 | 206 | */ |
205 | 207 | protected function setCookie() |
206 | 208 | { |
207 | - if( headers_sent() )return; |
|
209 | + if( headers_sent() ) { |
|
210 | + return; |
|
211 | + } |
|
208 | 212 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | 213 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
210 | 214 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 115 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 116 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -181,7 +183,9 @@ discard block |
||
181 | 183 | if( $value != $fallback ) { |
182 | 184 | return $value; |
183 | 185 | } |
184 | - if( !is_single() && !is_page() )return; |
|
186 | + if( !is_single() && !is_page() ) { |
|
187 | + return; |
|
188 | + } |
|
185 | 189 | switch( $option ) { |
186 | 190 | case 'description': |
187 | 191 | return get_the_excerpt(); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
33 | 33 | $reviews[] = $this->buildReview( $review ); |
34 | 34 | } |
35 | - if( !empty( $reviews )) { |
|
35 | + if( !empty($reviews) ) { |
|
36 | 36 | array_walk( $reviews, function( &$review ) { |
37 | - unset( $review['@context'] ); |
|
38 | - unset( $review['itemReviewed'] ); |
|
37 | + unset($review['@context']); |
|
38 | + unset($review['itemReviewed']); |
|
39 | 39 | }); |
40 | 40 | $schema['review'] = $reviews; |
41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | public function buildReview( $review ) |
50 | 50 | { |
51 | 51 | $schema = SchemaOrg::Review() |
52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
53 | 53 | $schema->name( $review->title ); |
54 | 54 | }) |
55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
56 | 56 | $schema->reviewBody( $review->content ); |
57 | 57 | }) |
58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
59 | 59 | ->author( SchemaOrg::Person() |
60 | 60 | ->name( $review->author ) |
61 | 61 | ) |
62 | 62 | ->itemReviewed( $this->getSchemaType() |
63 | 63 | ->name( $this->getThingName() ) |
64 | 64 | ); |
65 | - if( !empty( $review->rating )) { |
|
65 | + if( !empty($review->rating) ) { |
|
66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
67 | 67 | ->ratingValue( $review->rating ) |
68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function buildSummary( $args = null ) |
80 | 80 | { |
81 | - if( is_array( $args )) { |
|
81 | + if( is_array( $args ) ) { |
|
82 | 82 | $this->args = $args; |
83 | 83 | } |
84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ->image( $this->getThingImage() ) |
91 | 91 | ->url( $this->getThingUrl() ); |
92 | 92 | $count = $this->getReviewCount(); |
93 | - if( !empty( $count )) { |
|
93 | + if( !empty($count) ) { |
|
94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
95 | 95 | ->ratingValue( $this->getRatingValue() ) |
96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas ) )return; |
|
112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
115 | - )); |
|
115 | + ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function store( array $schema ) |
122 | 122 | { |
123 | - $schemas = (array) glsr()->schemas; |
|
123 | + $schemas = (array)glsr()->schemas; |
|
124 | 124 | $schemas[] = $schema; |
125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getReviews( $force = false ) |
149 | 149 | { |
150 | - if( !isset( $this->reviews ) || $force ) { |
|
150 | + if( !isset($this->reviews) || $force ) { |
|
151 | 151 | $args = wp_parse_args( ['count' => -1], $this->args ); |
152 | 152 | $this->reviews = glsr( Database::class )->getReviews( $args )->reviews; |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getSchemaOption( $option, $fallback ) |
163 | 163 | { |
164 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
164 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
165 | 165 | return $schemaOption; |
166 | 166 | } |
167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | // 'is_test' => 1, |
31 | 31 | ]; |
32 | 32 | foreach( $_SERVER as $key => $value ) { |
33 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
33 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] )) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $submission[$key] = $value; |
35 | 37 | } |
36 | 38 | return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
@@ -56,12 +58,16 @@ discard block |
||
56 | 58 | { |
57 | 59 | $query = []; |
58 | 60 | foreach( $data as $key => $value ) { |
59 | - if( is_array( $value ) || is_object( $value ))continue; |
|
61 | + if( is_array( $value ) || is_object( $value )) { |
|
62 | + continue; |
|
63 | + } |
|
60 | 64 | if( $value === false ) { |
61 | 65 | $value = '0'; |
62 | 66 | } |
63 | 67 | $value = trim( $value ); |
64 | - if( !strlen( $value ))continue; |
|
68 | + if( !strlen( $value )) { |
|
69 | + continue; |
|
70 | + } |
|
65 | 71 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
66 | 72 | } |
67 | 73 | return implode( '&', $query ); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | // 'is_test' => 1, |
32 | 32 | ]; |
33 | 33 | foreach( $_SERVER as $key => $value ) { |
34 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
34 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ) )continue; |
|
35 | 35 | $submission[$key] = $value; |
36 | 36 | } |
37 | - return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
|
37 | + return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ) ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | { |
58 | 58 | $query = []; |
59 | 59 | foreach( $data as $key => $value ) { |
60 | - if( is_array( $value ) || is_object( $value ))continue; |
|
60 | + if( is_array( $value ) || is_object( $value ) )continue; |
|
61 | 61 | if( $value === false ) { |
62 | 62 | $value = '0'; |
63 | 63 | } |
64 | 64 | $value = trim( $value ); |
65 | - if( !strlen( $value ))continue; |
|
65 | + if( !strlen( $value ) )continue; |
|
66 | 66 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
67 | 67 | } |
68 | 68 | return implode( '&', $query ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | || !is_callable( ['Akismet', 'get_api_key'] ) |
78 | 78 | || !is_callable( ['Akismet', 'http_post'] ) |
79 | 79 | ? false |
80 | - : (bool) AkismetPlugin::get_api_key(); |
|
80 | + : (bool)AkismetPlugin::get_api_key(); |
|
81 | 81 | return apply_filters( 'site-reviews/akismet/is-active', $check ); |
82 | 82 | } |
83 | 83 | } |