@@ -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'; |
@@ -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; |
@@ -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 | }); |
@@ -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(); |
@@ -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 ); |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $counts = array_fill_keys( [5,4,3,2,1], [] ); |
64 | 64 | array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
65 | 65 | $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
66 | - if( !isset( $review->rating ))return; |
|
66 | + if( !isset( $review->rating )) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | return $review->rating == $key; |
68 | 70 | })); |
69 | 71 | }); |
@@ -83,7 +85,9 @@ discard block |
||
83 | 85 | public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 ) |
84 | 86 | { |
85 | 87 | $numRatings = count( $upDownRatings ); |
86 | - if( !$numRatings )return 0; |
|
88 | + if( !$numRatings ) { |
|
89 | + return 0; |
|
90 | + } |
|
87 | 91 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 92 | return $value > 0; |
89 | 93 | })); |
@@ -16,9 +16,13 @@ discard block |
||
16 | 16 | { |
17 | 17 | $queries = []; |
18 | 18 | foreach( $keys as $key ) { |
19 | - if( !array_key_exists( $key, $values ))continue; |
|
19 | + if( !array_key_exists( $key, $values )) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | $methodName = glsr( Helper::class )->buildMethodName( $key, $prefix = __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
23 | + if( !method_exists( $this, $methodName )) { |
|
24 | + continue; |
|
25 | + } |
|
22 | 26 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | 27 | if( is_array( $query )) { |
24 | 28 | $queries[] = $query; |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | protected function buildQueryAssignedTo( $value ) |
92 | 96 | { |
93 | - if( empty( $value ))return; |
|
97 | + if( empty( $value )) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return [ |
95 | 101 | 'compare' => 'IN', |
96 | 102 | 'key' => 'assigned_to', |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildQueryCategory( $value ) |
106 | 112 | { |
107 | - if( empty( $value ))return; |
|
113 | + if( empty( $value )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | return [ |
109 | 117 | 'field' => 'term_id', |
110 | 118 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildQueryRating( $value ) |
120 | 128 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
129 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | return [ |
123 | 133 | 'compare' => '>=', |
124 | 134 | 'key' => 'rating', |
@@ -132,7 +142,9 @@ discard block |
||
132 | 142 | */ |
133 | 143 | protected function buildQueryType( $value ) |
134 | 144 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
145 | + if( in_array( $value, ['','all'] )) { |
|
146 | + return; |
|
147 | + } |
|
136 | 148 | return [ |
137 | 149 | 'key' => 'review_type', |
138 | 150 | 'value' => $value, |
@@ -4,7 +4,8 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * @return mixed |
6 | 6 | */ |
7 | -function glsr( $alias = null ) { |
|
7 | +function glsr( $alias = null ) |
|
8 | +{ |
|
8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
9 | 10 | return empty( $alias ) |
10 | 11 | ? $app |
@@ -15,7 +16,8 @@ discard block |
||
15 | 16 | * get_current_screen() is unreliable because it is not defined on all admin pages |
16 | 17 | * @return \WP_Screen|object |
17 | 18 | */ |
18 | -function glsr_current_screen() { |
|
19 | +function glsr_current_screen() |
|
20 | +{ |
|
19 | 21 | if( function_exists( 'get_current_screen' )) { |
20 | 22 | $screen = get_current_screen(); |
21 | 23 | } |
@@ -27,7 +29,8 @@ discard block |
||
27 | 29 | /** |
28 | 30 | * @return \GeminiLabs\SiteReviews\Database |
29 | 31 | */ |
30 | -function glsr_db() { |
|
32 | +function glsr_db() |
|
33 | +{ |
|
31 | 34 | return glsr( 'Database' ); |
32 | 35 | } |
33 | 36 | |
@@ -35,7 +38,8 @@ discard block |
||
35 | 38 | * @param mixed ...$vars |
36 | 39 | * @return void |
37 | 40 | */ |
38 | -function glsr_debug( ...$vars ) { |
|
41 | +function glsr_debug( ...$vars ) |
|
42 | +{ |
|
39 | 43 | if( count( $vars ) == 1 ) { |
40 | 44 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
41 | 45 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -52,7 +56,8 @@ discard block |
||
52 | 56 | /** |
53 | 57 | * @return \GeminiLabs\SiteReviews\Modules\Logger |
54 | 58 | */ |
55 | -function glsr_log() { |
|
59 | +function glsr_log() |
|
60 | +{ |
|
56 | 61 | $args = func_get_args(); |
57 | 62 | $context = isset( $args[1] ) |
58 | 63 | ? $args[1] |
@@ -68,7 +73,8 @@ discard block |
||
68 | 73 | * @return void |
69 | 74 | * @callback register_taxonomy() "meta_box_cb" |
70 | 75 | */ |
71 | -function glsr_categories_meta_box( $post, $box ) { |
|
76 | +function glsr_categories_meta_box( $post, $box ) |
|
77 | +{ |
|
72 | 78 | glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box ); |
73 | 79 | } |
74 | 80 | |
@@ -77,14 +83,16 @@ discard block |
||
77 | 83 | * @param mixed $fallback |
78 | 84 | * @return string|array |
79 | 85 | */ |
80 | -function glsr_get_option( $option_path = '', $fallback = '' ) { |
|
86 | +function glsr_get_option( $option_path = '', $fallback = '' ) |
|
87 | +{ |
|
81 | 88 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$option_path, $fallback ); |
82 | 89 | } |
83 | 90 | |
84 | 91 | /** |
85 | 92 | * @return array |
86 | 93 | */ |
87 | -function glsr_get_options() { |
|
94 | +function glsr_get_options() |
|
95 | +{ |
|
88 | 96 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
89 | 97 | } |
90 | 98 |
@@ -15,7 +15,9 @@ |
||
15 | 15 | */ |
16 | 16 | public function download( $filename, $content ) |
17 | 17 | { |
18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
18 | + if( !current_user_can( Application::CAPABILITY )) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | nocache_headers(); |
20 | 22 | header( 'Content-Type: text/plain' ); |
21 | 23 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |