@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function getSettingFields( $path ) |
45 | 45 | { |
46 | - return array_filter( $this->settings, function( $key ) use( $path ) { |
|
46 | + return array_filter( $this->settings, function( $key ) use($path) { |
|
47 | 47 | return glsr( Helper::class )->startsWith( $path, $key ); |
48 | 48 | }, ARRAY_FILTER_USE_KEY ); |
49 | 49 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $field = wp_parse_args( $field, [ |
59 | 59 | 'is_setting' => true, |
60 | 60 | 'name' => $name, |
61 | - ]); |
|
62 | - $rows.= new Field( $this->normalize( $field )); |
|
61 | + ] ); |
|
62 | + $rows .= new Field( $this->normalize( $field ) ); |
|
63 | 63 | } |
64 | 64 | return $rows; |
65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function getTemplateData( $id ) |
72 | 72 | { |
73 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
73 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
74 | 74 | return [ |
75 | 75 | 'context' => [ |
76 | 76 | 'rows' => $this->getSettingRows( $fields ), |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function getTemplateDataForAddons( $id ) |
86 | 86 | { |
87 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
87 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
88 | 88 | $settings = glsr( Helper::class )->convertDotNotationArray( $fields ); |
89 | 89 | $settingKeys = array_keys( $settings['settings']['addons'] ); |
90 | 90 | $results = []; |
91 | 91 | foreach( $settingKeys as $key ) { |
92 | - $addonFields = array_filter( $fields, function( $path ) use( $key ) { |
|
92 | + $addonFields = array_filter( $fields, function( $path ) use($key) { |
|
93 | 93 | return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path ); |
94 | 94 | }, ARRAY_FILTER_USE_KEY ); |
95 | 95 | $results[$key] = $this->getSettingRows( $addonFields ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function getTemplateDataForLicenses( $id ) |
108 | 108 | { |
109 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
109 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
110 | 110 | ksort( $fields ); |
111 | 111 | return [ |
112 | 112 | 'context' => [ |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | protected function getTemplateDataForTranslations() |
122 | 122 | { |
123 | 123 | $translations = glsr( Translation::class )->renderAll(); |
124 | - $class = empty( $translations ) |
|
124 | + $class = empty($translations) |
|
125 | 125 | ? 'glsr-hidden' |
126 | 126 | : ''; |
127 | 127 | return [ |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $path, |
145 | 145 | glsr( Helper::class )->dataGet( glsr()->defaults, $path ) |
146 | 146 | ); |
147 | - if( is_array( $expectedValue )) { |
|
147 | + if( is_array( $expectedValue ) ) { |
|
148 | 148 | return is_array( $optionValue ) |
149 | - ? count( array_intersect( $optionValue, $expectedValue )) === 0 |
|
149 | + ? count( array_intersect( $optionValue, $expectedValue ) ) === 0 |
|
150 | 150 | : !in_array( $optionValue, $expectedValue ); |
151 | 151 | } |
152 | 152 | return $optionValue != $expectedValue; |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function isMultiDependency( $path ) |
159 | 159 | { |
160 | - if( isset( $this->settings[$path] )) { |
|
160 | + if( isset($this->settings[$path]) ) { |
|
161 | 161 | $field = $this->settings[$path]; |
162 | - return ( $field['type'] == 'checkbox' && !empty( $field['options'] )) |
|
163 | - || !empty( $field['multiple'] ); |
|
162 | + return ($field['type'] == 'checkbox' && !empty($field['options'])) |
|
163 | + || !empty($field['multiple']); |
|
164 | 164 | } |
165 | 165 | return false; |
166 | 166 | } |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function normalizeDependsOn( array $field ) |
183 | 183 | { |
184 | - if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) { |
|
184 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
185 | 185 | $path = key( $field['depends_on'] ); |
186 | 186 | $expectedValue = $field['depends_on'][$path]; |
187 | 187 | $fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ); |
188 | - if( $this->isMultiDependency( $path )) { |
|
189 | - $fieldName.= '[]'; |
|
188 | + if( $this->isMultiDependency( $path ) ) { |
|
189 | + $fieldName .= '[]'; |
|
190 | 190 | } |
191 | - $field['data-depends'] = json_encode([ |
|
191 | + $field['data-depends'] = json_encode( [ |
|
192 | 192 | 'name' => $fieldName, |
193 | 193 | 'value' => $expectedValue, |
194 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
194 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
195 | 195 | $field['is_hidden'] = $this->isFieldHidden( $path, $expectedValue ); |
196 | 196 | } |
197 | 197 | return $field; |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function normalizeLabelAndLegend( array $field ) |
204 | 204 | { |
205 | - if( !empty( $field['label'] )) { |
|
205 | + if( !empty($field['label']) ) { |
|
206 | 206 | $field['legend'] = $field['label']; |
207 | - unset( $field['label'] ); |
|
207 | + unset($field['label']); |
|
208 | 208 | } |
209 | 209 | else { |
210 | 210 | $field['is_valid'] = false; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function normalizeValue( array $field ) |
220 | 220 | { |
221 | - if( !isset( $field['value'] )) { |
|
221 | + if( !isset($field['value']) ) { |
|
222 | 222 | $field['value'] = glsr( OptionManager::class )->get( |
223 | 223 | $field['name'], |
224 | 224 | $this->getFieldDefault( $field ) |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
109 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + if( !array_key_exists( $instance->tag, $this->fields ) )return; |
|
109 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
110 | 110 | $key = $instance->tag.'_'.$args['type']; |
111 | - $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |
|
111 | + $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag ) ); |
|
112 | 112 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
113 | 113 | do_action_ref_array( 'site-reviews/customize/'.$this->style, [&$instance] ); |
114 | 114 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $args = wp_parse_args( $instance->args, [ |
141 | 141 | 'is_public' => false, |
142 | 142 | 'is_raw' => false, |
143 | - ]); |
|
143 | + ] ); |
|
144 | 144 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
145 | 145 | return false; |
146 | 146 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 97 | } |
94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
105 | 109 | */ |
106 | 110 | protected function customize( Builder $instance ) |
107 | 111 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
113 | + return; |
|
114 | + } |
|
109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
110 | 116 | $key = $instance->tag.'_'.$args['type']; |
111 | 117 | $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | |
12 | 12 | class Console |
13 | 13 | { |
14 | - const DEBUG_0 = 'debug'; // Detailed debug information |
|
15 | - const INFO_1 = 'info'; // Interesting events |
|
16 | - const NOTICE_2 = 'notice'; // Normal but significant events |
|
17 | - const WARNING_3 = 'warning'; // Exceptional occurrences that are not errors |
|
18 | - const ERROR_4 = 'error'; // Runtime errors that do not require immediate action |
|
19 | - const CRITICAL_5 = 'critical'; // Critical conditions |
|
20 | - const ALERT_6 = 'alert'; // Action must be taken immediately |
|
14 | + const DEBUG_0 = 'debug'; // Detailed debug information |
|
15 | + const INFO_1 = 'info'; // Interesting events |
|
16 | + const NOTICE_2 = 'notice'; // Normal but significant events |
|
17 | + const WARNING_3 = 'warning'; // Exceptional occurrences that are not errors |
|
18 | + const ERROR_4 = 'error'; // Runtime errors that do not require immediate action |
|
19 | + const CRITICAL_5 = 'critical'; // Critical conditions |
|
20 | + const ALERT_6 = 'alert'; // Action must be taken immediately |
|
21 | 21 | const EMERGENCY_7 = 'emergency'; // System is unusable |
22 | 22 | |
23 | 23 | protected $file; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function get() |
114 | 114 | { |
115 | - return empty( $this->log ) |
|
115 | + return empty($this->log) |
|
116 | 116 | ? __( 'Console is empty', 'site-reviews' ) |
117 | 117 | : $this->log; |
118 | 118 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getLevels() |
124 | 124 | { |
125 | - return array_values( (new ReflectionClass(__CLASS__))->getConstants() ); |
|
125 | + return array_values( (new ReflectionClass( __CLASS__ ))->getConstants() ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | public function humanSize( $valueIfEmpty = null ) |
133 | 133 | { |
134 | 134 | $bytes = $this->size(); |
135 | - if( empty( $bytes ) && is_string( $valueIfEmpty )) { |
|
135 | + if( empty($bytes) && is_string( $valueIfEmpty ) ) { |
|
136 | 136 | return $valueIfEmpty; |
137 | 137 | } |
138 | - $exponent = floor( log( max( $bytes, 1 ), 1024 )); |
|
139 | - return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes','KB','MB','GB'][$exponent]; |
|
138 | + $exponent = floor( log( max( $bytes, 1 ), 1024 ) ); |
|
139 | + return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function log( $level, $message, $context = [], $backtraceLine = '' ) |
162 | 162 | { |
163 | - if( empty( $backtraceLine )) { |
|
163 | + if( empty($backtraceLine) ) { |
|
164 | 164 | $backtraceLine = $this->getBacktraceLine(); |
165 | 165 | } |
166 | - if( $this->canLogEntry( $level, $backtraceLine )) { |
|
166 | + if( $this->canLogEntry( $level, $backtraceLine ) ) { |
|
167 | 167 | $context = glsr( Helper::class )->consolidateArray( $context ); |
168 | 168 | $entry = $this->buildLogEntry( |
169 | 169 | $level, |
170 | 170 | $this->interpolate( $message, $context ), |
171 | 171 | $this->normalizeBacktraceLine( $backtraceLine ) |
172 | 172 | ); |
173 | - file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND|LOCK_EX ); |
|
173 | + file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX ); |
|
174 | 174 | $this->reset(); |
175 | 175 | } |
176 | 176 | return $this; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $once = glsr( Helper::class )->consolidateArray( $once ); |
186 | 186 | $levels = $this->getLevels(); |
187 | 187 | foreach( $once as $entry ) { |
188 | - if( !in_array( glsr_get( $entry, 'level' ), $levels ))continue; |
|
188 | + if( !in_array( glsr_get( $entry, 'level' ), $levels ) )continue; |
|
189 | 189 | $level = glsr_get( $entry, 'level' ); |
190 | 190 | $message = glsr_get( $entry, 'message' ); |
191 | 191 | $backtraceLine = glsr_get( $entry, 'backtrace' ); |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | { |
215 | 215 | $once = glsr( Session::class )->get( $this->onceSessionKey, [] ); |
216 | 216 | $once = glsr( Helper::class )->consolidateArray( $once ); |
217 | - $filtered = array_filter( $once, function( $entry ) use( $level, $handle ) { |
|
217 | + $filtered = array_filter( $once, function( $entry ) use($level, $handle) { |
|
218 | 218 | return glsr_get( $entry, 'level' ) == $level |
219 | 219 | && glsr_get( $entry, 'handle' ) == $handle; |
220 | 220 | }); |
221 | - if( !empty( $filtered ))return; |
|
221 | + if( !empty($filtered) )return; |
|
222 | 222 | $once[] = [ |
223 | 223 | 'backtrace' => $this->getBacktraceLineFromData( $data ), |
224 | 224 | 'handle' => $handle, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | protected function buildLogEntry( $level, $message, $backtraceLine = '' ) |
273 | 273 | { |
274 | - if( !empty( $backtraceLine )) { |
|
274 | + if( !empty($backtraceLine) ) { |
|
275 | 275 | $backtraceLine = '|'.$backtraceLine; |
276 | 276 | } |
277 | 277 | return sprintf( '[%s%s] %s: %s', |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | protected function getBacktraceLine() |
303 | 303 | { |
304 | 304 | $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 6 ); |
305 | - $search = array_search( 'log', glsr_array_column( $backtrace, 'function' )); |
|
305 | + $search = array_search( 'log', glsr_array_column( $backtrace, 'function' ) ); |
|
306 | 306 | if( $search !== false ) { |
307 | - $index = glsr_get( $backtrace, ( $search + 2 ).'.function' ) == '{closure}' |
|
307 | + $index = glsr_get( $backtrace, ($search + 2).'.function' ) == '{closure}' |
|
308 | 308 | ? $search + 4 |
309 | 309 | : $search + 1; |
310 | 310 | return $this->buildBacktraceLine( $backtrace, $index ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | protected function interpolate( $message, $context = [] ) |
345 | 345 | { |
346 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
346 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
347 | 347 | return print_r( $message, true ); |
348 | 348 | } |
349 | 349 | $replace = []; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | glsr()->path( 'plugin/' ), |
373 | 373 | glsr()->path( 'plugin/', false ), |
374 | 374 | trailingslashit( glsr()->path() ), |
375 | - trailingslashit( glsr()->path( '', false )), |
|
375 | + trailingslashit( glsr()->path( '', false ) ), |
|
376 | 376 | WP_CONTENT_DIR, |
377 | 377 | ABSPATH |
378 | 378 | ]; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | if( $value instanceof DateTime ) { |
401 | 401 | $value = $value->format( 'Y-m-d H:i:s' ); |
402 | 402 | } |
403 | - else if( $this->isObjectOrArray( $value )) { |
|
403 | + else if( $this->isObjectOrArray( $value ) ) { |
|
404 | 404 | $value = json_encode( $value ); |
405 | 405 | } |
406 | 406 | return (string)$value; |
@@ -185,7 +185,9 @@ discard block |
||
185 | 185 | $once = glsr( Helper::class )->consolidateArray( $once ); |
186 | 186 | $levels = $this->getLevels(); |
187 | 187 | foreach( $once as $entry ) { |
188 | - if( !in_array( glsr_get( $entry, 'level' ), $levels ))continue; |
|
188 | + if( !in_array( glsr_get( $entry, 'level' ), $levels )) { |
|
189 | + continue; |
|
190 | + } |
|
189 | 191 | $level = glsr_get( $entry, 'level' ); |
190 | 192 | $message = glsr_get( $entry, 'message' ); |
191 | 193 | $backtraceLine = glsr_get( $entry, 'backtrace' ); |
@@ -218,7 +220,9 @@ discard block |
||
218 | 220 | return glsr_get( $entry, 'level' ) == $level |
219 | 221 | && glsr_get( $entry, 'handle' ) == $handle; |
220 | 222 | }); |
221 | - if( !empty( $filtered ))return; |
|
223 | + if( !empty( $filtered )) { |
|
224 | + return; |
|
225 | + } |
|
222 | 226 | $once[] = [ |
223 | 227 | 'backtrace' => $this->getBacktraceLineFromData( $data ), |
224 | 228 | 'handle' => $handle, |
@@ -411,7 +415,9 @@ discard block |
||
411 | 415 | */ |
412 | 416 | protected function reset() |
413 | 417 | { |
414 | - if( $this->size() <= pow( 1024, 2 ) / 8 )return; |
|
418 | + if( $this->size() <= pow( 1024, 2 ) / 8 ) { |
|
419 | + return; |
|
420 | + } |
|
415 | 421 | $this->clear(); |
416 | 422 | file_put_contents( |
417 | 423 | $this->file, |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $translations = $this->translations(); |
32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
36 | 36 | : ''; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function entries() |
45 | 45 | { |
46 | - if( !isset( $this->entries )) { |
|
46 | + if( !isset($this->entries) ) { |
|
47 | 47 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
48 | 48 | $entries = $this->extractEntriesFromPotFile( $potFile ); |
49 | 49 | $entries = apply_filters( 'site-reviews/translation/entries', $entries ); |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
90 | 90 | { |
91 | - if( !is_array( $entries )) { |
|
91 | + if( !is_array( $entries ) ) { |
|
92 | 92 | $entries = $this->results; |
93 | 93 | } |
94 | - if( !is_array( $filterWith )) { |
|
94 | + if( !is_array( $filterWith ) ) { |
|
95 | 95 | $filterWith = $this->translations(); |
96 | 96 | } |
97 | - $keys = array_flip( glsr_array_column( $filterWith, 'id' )); |
|
97 | + $keys = array_flip( glsr_array_column( $filterWith, 'id' ) ); |
|
98 | 98 | $this->results = $intersect |
99 | 99 | ? array_intersect_key( $entries, $keys ) |
100 | 100 | : array_diff_key( $entries, $keys ); |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | public function render( $template, array $entry ) |
109 | 109 | { |
110 | 110 | $data = array_combine( |
111 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
111 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
112 | 112 | $entry |
113 | 113 | ); |
114 | 114 | $data['data.class'] = $data['data.error'] = ''; |
115 | - if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' )) === false ) { |
|
115 | + if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) === false ) { |
|
116 | 116 | $data['data.class'] = 'is-invalid'; |
117 | 117 | $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' ); |
118 | 118 | } |
119 | 119 | return glsr( Template::class )->build( 'partials/translations/'.$template, [ |
120 | 120 | 'context' => $data, |
121 | - ]); |
|
121 | + ] ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
151 | 151 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
152 | 152 | ]; |
153 | - $text = !empty( $data['p1'] ) |
|
153 | + $text = !empty($data['p1']) |
|
154 | 154 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
155 | 155 | : $data['s1']; |
156 | 156 | $rendered .= $this->render( 'result', [ |
157 | - 'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ), |
|
157 | + 'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), |
|
158 | 158 | 'text' => wp_strip_all_tags( $text ), |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | if( $resetAfterRender ) { |
162 | 162 | $this->reset(); |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | public function search( $needle = '' ) |
190 | 190 | { |
191 | 191 | $this->reset(); |
192 | - $needle = trim( strtolower( $needle )); |
|
192 | + $needle = trim( strtolower( $needle ) ); |
|
193 | 193 | foreach( $this->entries() as $key => $entry ) { |
194 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
195 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
194 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
195 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
196 | 196 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
197 | - if( in_array( $needle, [$single, $plural] )) { |
|
197 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
198 | 198 | $this->results[$key] = $entry; |
199 | 199 | } |
200 | 200 | } |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | public function translations() |
213 | 213 | { |
214 | 214 | static $translations; |
215 | - if( empty( $translations )) { |
|
215 | + if( empty($translations) ) { |
|
216 | 216 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
217 | - $translations = isset( $settings['strings'] ) |
|
218 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
217 | + $translations = isset($settings['strings']) |
|
218 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
219 | 219 | : []; |
220 | 220 | } |
221 | 221 | return $translations; |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | */ |
228 | 228 | protected function getEntryString( array $entry, $key ) |
229 | 229 | { |
230 | - return isset( $entry[$key] ) |
|
231 | - ? implode( '', (array) $entry[$key] ) |
|
230 | + return isset($entry[$key]) |
|
231 | + ? implode( '', (array)$entry[$key] ) |
|
232 | 232 | : ''; |
233 | 233 | } |
234 | 234 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $keys = [ |
241 | 241 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
242 | 242 | ]; |
243 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
243 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
244 | 244 | foreach( $keys as $key ) { |
245 | 245 | try { |
246 | 246 | $entry = $this->normalizeEntryString( $entry, $key ); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | protected function normalizeEntryString( array $entry, $key ) |
262 | 262 | { |
263 | - if( isset( $entry[$key] )) { |
|
263 | + if( isset($entry[$key]) ) { |
|
264 | 264 | $entry[$key] = $this->getEntryString( $entry, $key ); |
265 | 265 | } |
266 | 266 | return $entry; |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
275 | 275 | $strings = array_filter( $strings, 'is_array' ); |
276 | 276 | foreach( $strings as &$string ) { |
277 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
277 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
278 | 278 | $string = wp_parse_args( $string, $defaultString ); |
279 | 279 | } |
280 | 280 | return array_filter( $strings, function( $string ) { |
281 | - return !empty( $string['id'] ); |
|
281 | + return !empty($string['id']); |
|
282 | 282 | }); |
283 | 283 | } |
284 | 284 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function callbackRegisterSettings( $input ) |
19 | 19 | { |
20 | - if( !is_array( $input )) { |
|
20 | + if( !is_array( $input ) ) { |
|
21 | 21 | $input = ['settings' => []]; |
22 | 22 | } |
23 | 23 | if( key( $input ) == 'settings' ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $options = $this->sanitizeSubmissions( $input, $options ); |
27 | 27 | $options = $this->sanitizeTranslations( $input, $options ); |
28 | 28 | if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
29 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
29 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
30 | 30 | } |
31 | 31 | return $options; |
32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
44 | - ]); |
|
44 | + ] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | protected function sanitizeSubmissions( array $input, array $options ) |
67 | 67 | { |
68 | 68 | $inputForm = $input['settings']['submissions']; |
69 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
69 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
70 | 70 | ? $inputForm['required'] |
71 | 71 | : []; |
72 | 72 | return $options; |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function sanitizeTranslations( array $input, array $options ) |
79 | 79 | { |
80 | - if( isset( $input['settings']['strings'] )) { |
|
81 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
80 | + if( isset($input['settings']['strings']) ) { |
|
81 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
82 | 82 | $allowedTags = [ |
83 | 83 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
84 | 84 | 'span' => ['class' => []], |
85 | 85 | ]; |
86 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
87 | - if( isset( $string['s2'] )) { |
|
86 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
87 | + if( isset($string['s2']) ) { |
|
88 | 88 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
89 | 89 | } |
90 | - if( isset( $string['p2'] )) { |
|
90 | + if( isset($string['p2']) ) { |
|
91 | 91 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
92 | 92 | } |
93 | 93 | }); |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | protected function isPolylangActiveAndSupported() |
102 | 102 | { |
103 | 103 | if( !glsr( Polylang::class )->isActive() ) { |
104 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
104 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | else if( !glsr( Polylang::class )->isSupported() ) { |
108 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
108 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | return true; |