@@ -7,7 +7,7 @@ |
||
7 | 7 | <p>{{ data.s1 }}</p> |
8 | 8 | </div> |
9 | 9 | <p class="row-actions"> |
10 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
10 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | 11 | </p> |
12 | 12 | </td> |
13 | 13 | <td class="glsr-string-td2"> |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <p>{{ data.p1 }}</p> |
9 | 9 | </div> |
10 | 10 | <p class="row-actions"> |
11 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
12 | 12 | </p> |
13 | 13 | </td> |
14 | 14 | <td class="glsr-string-td2"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | return $this->translate( $translation, $domain, [ |
20 | 20 | 'single' => $text, |
21 | - ]); |
|
21 | + ] ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | return $this->translate( $translation, $domain, [ |
34 | 34 | 'context' => $context, |
35 | 35 | 'single' => $text, |
36 | - ]); |
|
36 | + ] ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'number' => $number, |
51 | 51 | 'plural' => $plural, |
52 | 52 | 'single' => $single, |
53 | - ]); |
|
53 | + ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'number' => $number, |
70 | 70 | 'plural' => $plural, |
71 | 71 | 'single' => $single, |
72 | - ]); |
|
72 | + ] ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | $args = $this->normalizeTranslationArgs( $args ); |
86 | 86 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
87 | - if( empty( $strings )) { |
|
87 | + if( empty($strings) ) { |
|
88 | 88 | return $original; |
89 | 89 | } |
90 | 90 | $string = current( $strings ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function getTranslationStrings( $single, $plural ) |
102 | 102 | { |
103 | - return array_filter( glsr( Translation::class )->translations(), function( $string ) use( $single, $plural ) { |
|
103 | + return array_filter( glsr( Translation::class )->translations(), function( $string ) use($single, $plural) { |
|
104 | 104 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
105 | 105 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
106 | 106 | }); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function translatePlural( $domain, array $string, array $args ) |
128 | 128 | { |
129 | - if( !empty( $string['s2'] )) { |
|
129 | + if( !empty($string['s2']) ) { |
|
130 | 130 | $args['single'] = $string['s2']; |
131 | 131 | } |
132 | - if( !empty( $string['p2'] )) { |
|
132 | + if( !empty($string['p2']) ) { |
|
133 | 133 | $args['plural'] = $string['p2']; |
134 | 134 | } |
135 | 135 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function translateSingle( $domain, array $string, array $args ) |
148 | 148 | { |
149 | - if( !empty( $string['s2'] )) { |
|
149 | + if( !empty($string['s2']) ) { |
|
150 | 150 | $args['single'] = $string['s2']; |
151 | 151 | } |
152 | 152 | return get_translations_for_domain( $domain )->translate( |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $className = str_replace( '.php', '', $file ); |
29 | 29 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
30 | 30 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
31 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
32 | 32 | glsr( 'Modules\\Upgrader\\'.$className ); |
33 | 33 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
34 | 34 | }); |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | $filenames = []; |
21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
22 | 22 | foreach( $iterator as $fileinfo ) { |
23 | - if( !$fileinfo->isFile() )continue; |
|
23 | + if( !$fileinfo->isFile() ) { |
|
24 | + continue; |
|
25 | + } |
|
24 | 26 | $filenames[] = $fileinfo->getFilename(); |
25 | 27 | } |
26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
28 | 30 | $className = str_replace( '.php', '', $file ); |
29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
34 | + return; |
|
35 | + } |
|
32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
34 | 38 | }); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getFieldDefault( array $field ) |
31 | 31 | { |
32 | - return isset( $field['default'] ) |
|
32 | + return isset($field['default']) |
|
33 | 33 | ? $field['default'] |
34 | 34 | : ''; |
35 | 35 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | protected function getSettingFields( $path ) |
41 | 41 | { |
42 | 42 | $settings = glsr( DefaultsManager::class )->settings(); |
43 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
43 | + return array_filter( $settings, function( $key ) use($path) { |
|
44 | 44 | return glsr( Helper::class )->startsWith( $path, $key ); |
45 | 45 | }, ARRAY_FILTER_USE_KEY ); |
46 | 46 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $field = wp_parse_args( $field, [ |
56 | 56 | 'is_setting' => true, |
57 | 57 | 'name' => $name, |
58 | - ]); |
|
59 | - $rows.= new Field( $this->normalize( $field )); |
|
58 | + ] ); |
|
59 | + $rows .= new Field( $this->normalize( $field ) ); |
|
60 | 60 | } |
61 | 61 | return $rows; |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | protected function getTemplateData( $id ) |
69 | 69 | { |
70 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
70 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
71 | 71 | return [ |
72 | 72 | 'context' => [ |
73 | 73 | 'rows' => $this->getSettingRows( $fields ), |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function getTemplateDataForAddons( $id ) |
83 | 83 | { |
84 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
84 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
85 | 85 | $settings = glsr( Helper::class )->convertDotNotationArray( $fields ); |
86 | 86 | $settingKeys = array_keys( $settings['settings']['addons'] ); |
87 | 87 | $results = []; |
88 | 88 | foreach( $settingKeys as $key ) { |
89 | - $addonFields = array_filter( $fields, function( $path ) use( $key ) { |
|
89 | + $addonFields = array_filter( $fields, function( $path ) use($key) { |
|
90 | 90 | return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path ); |
91 | 91 | }, ARRAY_FILTER_USE_KEY ); |
92 | 92 | $results[$key] = $this->getSettingRows( $addonFields ); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function getTemplateDataForTranslations() |
103 | 103 | { |
104 | 104 | $translations = glsr( Translation::class )->renderAll(); |
105 | - $class = empty( $translations ) |
|
105 | + $class = empty($translations) |
|
106 | 106 | ? 'glsr-hidden' |
107 | 107 | : ''; |
108 | 108 | return [ |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | $path, |
126 | 126 | glsr( Helper::class )->getPathValue( $path, glsr()->defaults ) |
127 | 127 | ); |
128 | - if( is_array( $expectedValue )) { |
|
128 | + if( is_array( $expectedValue ) ) { |
|
129 | 129 | return is_array( $optionValue ) |
130 | - ? count( array_intersect( $optionValue, $expectedValue )) === 0 |
|
130 | + ? count( array_intersect( $optionValue, $expectedValue ) ) === 0 |
|
131 | 131 | : !in_array( $optionValue, $expectedValue ); |
132 | 132 | } |
133 | 133 | return $optionValue != $expectedValue; |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function normalizeDependsOn( array $field ) |
151 | 151 | { |
152 | - if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) { |
|
152 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
153 | 153 | $path = key( $field['depends_on'] ); |
154 | 154 | $expectedValue = $field['depends_on'][$path]; |
155 | 155 | $fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ); |
156 | - if( is_array( $expectedValue )) { |
|
157 | - $fieldName.= '[]'; |
|
156 | + if( is_array( $expectedValue ) ) { |
|
157 | + $fieldName .= '[]'; |
|
158 | 158 | } |
159 | - $field['data-depends'] = json_encode([ |
|
159 | + $field['data-depends'] = json_encode( [ |
|
160 | 160 | 'name' => $fieldName, |
161 | 161 | 'value' => $expectedValue, |
162 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
162 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
163 | 163 | $field['is_hidden'] = $this->isFieldHidden( $path, $expectedValue ); |
164 | 164 | } |
165 | 165 | return $field; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function normalizeLabelAndLegend( array $field ) |
172 | 172 | { |
173 | - if( !empty( $field['label'] )) { |
|
173 | + if( !empty($field['label']) ) { |
|
174 | 174 | $field['legend'] = $field['label']; |
175 | - unset( $field['label'] ); |
|
175 | + unset($field['label']); |
|
176 | 176 | } |
177 | 177 | else { |
178 | 178 | $field['is_valid'] = false; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function normalizeValue( array $field ) |
188 | 188 | { |
189 | - if( !isset( $field['value'] )) { |
|
189 | + if( !isset($field['value']) ) { |
|
190 | 190 | $field['value'] = glsr( OptionManager::class )->get( |
191 | 191 | $field['name'], |
192 | 192 | $this->getFieldDefault( $field ) |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function filterAttributes( array $allowedAttributeKeys ) |
124 | 124 | { |
125 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
125 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
134 | 134 | $wildcards = []; |
135 | 135 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
136 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
136 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
137 | 137 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
138 | 138 | }, ARRAY_FILTER_USE_KEY ); |
139 | 139 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | protected function getPermanentAttributes() |
148 | 148 | { |
149 | 149 | $permanentAttributes = []; |
150 | - if( array_key_exists( 'value', $this->attributes )) { |
|
150 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
151 | 151 | $permanentAttributes['value'] = $this->attributes['value']; |
152 | 152 | } |
153 | 153 | return $permanentAttributes; |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | protected function normalizeBooleanAttributes() |
200 | 200 | { |
201 | 201 | foreach( $this->attributes as $key => $value ) { |
202 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
202 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
203 | 203 | $key = $value; |
204 | 204 | $value = true; |
205 | 205 | } |
206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
207 | 207 | $this->attributes[$key] = wp_validate_boolean( $value ); |
208 | 208 | } |
209 | 209 | } |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | protected function normalizeDataAttributes() |
215 | 215 | { |
216 | 216 | foreach( $this->attributes as $key => $value ) { |
217 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
217 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
218 | 218 | $key = $value; |
219 | 219 | $value = ''; |
220 | 220 | } |
221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
222 | - if( is_array( $value )) { |
|
223 | - $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
|
221 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
222 | + if( is_array( $value ) ) { |
|
223 | + $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
224 | 224 | } |
225 | 225 | $this->attributes[$key] = $value; |
226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | protected function normalizeStringAttributes() |
233 | 233 | { |
234 | 234 | foreach( $this->attributes as $key => $value ) { |
235 | - if( !is_string( $value ))continue; |
|
235 | + if( !is_string( $value ) )continue; |
|
236 | 236 | $this->attributes[$key] = trim( $value ); |
237 | 237 | } |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if( $method != 'input' )return; |
247 | 247 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
248 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
248 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
249 | 249 | $this->attributes['type'] = 'text'; |
250 | 250 | } |
251 | 251 | } |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | $permanentAttributes = $this->getPermanentAttributes(); |
260 | 260 | foreach( $this->attributes as $key => $value ) { |
261 | 261 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
262 | - unset( $attributes[$key] ); |
|
262 | + unset($attributes[$key]); |
|
263 | 263 | } |
264 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
264 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
265 | 265 | $permanentAttributes[$key] = $value; |
266 | - unset( $attributes[$key] ); |
|
266 | + unset($attributes[$key]); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -203,7 +203,9 @@ discard block |
||
203 | 203 | $key = $value; |
204 | 204 | $value = true; |
205 | 205 | } |
206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
207 | + continue; |
|
208 | + } |
|
207 | 209 | $this->attributes[$key] = wp_validate_boolean( $value ); |
208 | 210 | } |
209 | 211 | } |
@@ -218,7 +220,9 @@ discard block |
||
218 | 220 | $key = $value; |
219 | 221 | $value = ''; |
220 | 222 | } |
221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
223 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
224 | + continue; |
|
225 | + } |
|
222 | 226 | if( is_array( $value )) { |
223 | 227 | $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
224 | 228 | } |
@@ -232,7 +236,9 @@ discard block |
||
232 | 236 | protected function normalizeStringAttributes() |
233 | 237 | { |
234 | 238 | foreach( $this->attributes as $key => $value ) { |
235 | - if( !is_string( $value ))continue; |
|
239 | + if( !is_string( $value )) { |
|
240 | + continue; |
|
241 | + } |
|
236 | 242 | $this->attributes[$key] = trim( $value ); |
237 | 243 | } |
238 | 244 | } |
@@ -243,7 +249,9 @@ discard block |
||
243 | 249 | */ |
244 | 250 | protected function normalizeInputType( $method ) |
245 | 251 | { |
246 | - if( $method != 'input' )return; |
|
252 | + if( $method != 'input' ) { |
|
253 | + return; |
|
254 | + } |
|
247 | 255 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
248 | 256 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
249 | 257 | $this->attributes['type'] = 'text'; |
@@ -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 | try { |
48 | 48 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
49 | 49 | $entries = $this->normalize( Parser::parseFile( $potFile )->getEntries() ); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
78 | 78 | { |
79 | - if( !is_array( $entries )) { |
|
79 | + if( !is_array( $entries ) ) { |
|
80 | 80 | $entries = $this->results; |
81 | 81 | } |
82 | - if( !is_array( $filterWith )) { |
|
82 | + if( !is_array( $filterWith ) ) { |
|
83 | 83 | $filterWith = $this->translations(); |
84 | 84 | } |
85 | - $keys = array_flip( array_column( $filterWith, 'id' )); |
|
85 | + $keys = array_flip( array_column( $filterWith, 'id' ) ); |
|
86 | 86 | $this->results = $intersect |
87 | 87 | ? array_intersect_key( $entries, $keys ) |
88 | 88 | : array_diff_key( $entries, $keys ); |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | public function render( $template, array $entry ) |
97 | 97 | { |
98 | 98 | $data = array_combine( |
99 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
99 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
100 | 100 | $entry |
101 | 101 | ); |
102 | 102 | $data['data.class'] = $data['data.error'] = ''; |
103 | - if( array_search( $entry['s1'], array_column( $this->entries(), 'msgid' )) === false ) { |
|
103 | + if( array_search( $entry['s1'], array_column( $this->entries(), 'msgid' ) ) === false ) { |
|
104 | 104 | $data['data.class'] = 'is-invalid'; |
105 | 105 | $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' ); |
106 | 106 | } |
107 | 107 | return glsr( Template::class )->build( 'partials/translations/'.$template, [ |
108 | 108 | 'context' => $data, |
109 | - ]); |
|
109 | + ] ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
139 | 139 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
140 | 140 | ]; |
141 | - $text = !empty( $data['p1'] ) |
|
141 | + $text = !empty($data['p1']) |
|
142 | 142 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
143 | 143 | : $data['s1']; |
144 | 144 | $rendered .= $this->render( 'result', [ |
145 | - 'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ), |
|
145 | + 'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), |
|
146 | 146 | 'text' => wp_strip_all_tags( $text ), |
147 | - ]); |
|
147 | + ] ); |
|
148 | 148 | } |
149 | 149 | if( $resetAfterRender ) { |
150 | 150 | $this->reset(); |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | public function search( $needle = '' ) |
178 | 178 | { |
179 | 179 | $this->reset(); |
180 | - $needle = trim( strtolower( $needle )); |
|
180 | + $needle = trim( strtolower( $needle ) ); |
|
181 | 181 | foreach( $this->entries() as $key => $entry ) { |
182 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
183 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
182 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
183 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
184 | 184 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
185 | - if( in_array( $needle, [$single, $plural] )) { |
|
185 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
186 | 186 | $this->results[$key] = $entry; |
187 | 187 | } |
188 | 188 | } |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | public function translations() |
201 | 201 | { |
202 | 202 | static $translations; |
203 | - if( empty( $translations )) { |
|
203 | + if( empty($translations) ) { |
|
204 | 204 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
205 | - $translations = isset( $settings['strings'] ) |
|
206 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
205 | + $translations = isset($settings['strings']) |
|
206 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
207 | 207 | : []; |
208 | 208 | } |
209 | 209 | return $translations; |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | */ |
216 | 216 | protected function getEntryString( array $entry, $key ) |
217 | 217 | { |
218 | - return isset( $entry[$key] ) |
|
219 | - ? implode( '', (array) $entry[$key] ) |
|
218 | + return isset($entry[$key]) |
|
219 | + ? implode( '', (array)$entry[$key] ) |
|
220 | 220 | : ''; |
221 | 221 | } |
222 | 222 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $keys = [ |
229 | 229 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
230 | 230 | ]; |
231 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
231 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
232 | 232 | foreach( $keys as $key ) { |
233 | 233 | $entry = $this->normalizeEntryString( $entry, $key ); |
234 | 234 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function normalizeEntryString( array $entry, $key ) |
244 | 244 | { |
245 | - if( isset( $entry[$key] )) { |
|
245 | + if( isset($entry[$key]) ) { |
|
246 | 246 | $entry[$key] = $this->getEntryString( $entry, $key ); |
247 | 247 | } |
248 | 248 | return $entry; |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
257 | 257 | $strings = array_filter( $strings, 'is_array' ); |
258 | 258 | foreach( $strings as &$string ) { |
259 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
259 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
260 | 260 | $string = wp_parse_args( $string, $defaultString ); |
261 | 261 | } |
262 | 262 | return array_filter( $strings, function( $string ) { |
263 | - return !empty( $string['id'] ); |
|
263 | + return !empty($string['id']); |
|
264 | 264 | }); |
265 | 265 | } |
266 | 266 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | { |
75 | 75 | $this->newSettings = $this->getNewSettings(); |
76 | 76 | $this->oldSettings = $this->getOldSettings(); |
77 | - if( empty( $this->oldSettings ))return; |
|
77 | + if( empty($this->oldSettings) )return; |
|
78 | 78 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
79 | + if( empty($this->oldSettings[$old]) )continue; |
|
80 | 80 | $this->newSettings[$new] = $this->oldSettings[$old]; |
81 | 81 | } |
82 | 82 | $this->migrateNotificationSettings(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $this->migrateRequiredSettings(); |
85 | 85 | $oldSettings = glsr( Helper::class )->convertDotNotationArray( $this->oldSettings ); |
86 | 86 | $newSettings = glsr( Helper::class )->convertDotNotationArray( $this->newSettings ); |
87 | - if( isset( $oldSettings['settings']['strings'] ) && is_array( $oldSettings['settings']['strings'] )) { |
|
87 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
88 | 88 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
89 | 89 | } |
90 | 90 | glsr( OptionManager::class )->set( $newSettings ); |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | protected function getOldSettings() |
118 | 118 | { |
119 | 119 | $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
120 | - $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] )); |
|
121 | - if( !empty( $settings )) { |
|
120 | + $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] ) ); |
|
121 | + if( !empty($settings) ) { |
|
122 | 122 | $settings = wp_parse_args( $settings, $defaults ); |
123 | 123 | } |
124 | 124 | return $settings; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
152 | 152 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
153 | 153 | ]; |
154 | - if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] )) { |
|
154 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
155 | 155 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
156 | 156 | } |
157 | 157 | if( $this->oldSettings['settings.reviews-form.recaptcha.integration'] == 'invisible-recaptcha' ) { |
@@ -74,9 +74,13 @@ discard block |
||
74 | 74 | { |
75 | 75 | $this->newSettings = $this->getNewSettings(); |
76 | 76 | $this->oldSettings = $this->getOldSettings(); |
77 | - if( empty( $this->oldSettings ))return; |
|
77 | + if( empty( $this->oldSettings )) { |
|
78 | + return; |
|
79 | + } |
|
78 | 80 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
81 | + if( empty( $this->oldSettings[$old] )) { |
|
82 | + continue; |
|
83 | + } |
|
80 | 84 | $this->newSettings[$new] = $this->oldSettings[$old]; |
81 | 85 | } |
82 | 86 | $this->migrateNotificationSettings(); |
@@ -136,7 +140,9 @@ discard block |
||
136 | 140 | ]; |
137 | 141 | $this->newSettings['settings.general.notifications'] = []; |
138 | 142 | foreach( $notifications as $old => $new ) { |
139 | - if( $this->oldSettings['settings.general.notification'] != $old )continue; |
|
143 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
144 | + continue; |
|
145 | + } |
|
140 | 146 | $this->newSettings['settings.general.notifications'][] = $new; |
141 | 147 | } |
142 | 148 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function enqueueAssets() |
27 | 27 | { |
28 | - $command = new EnqueueAdminAssets([ |
|
28 | + $command = new EnqueueAdminAssets( [ |
|
29 | 29 | 'pointers' => [[ |
30 | 30 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
31 | 31 | 'id' => 'glsr-pointer-pinned', |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'target' => '#misc-pub-pinned', |
38 | 38 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
39 | 39 | ]], |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | $this->execute( $command ); |
42 | 42 | } |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
51 | 51 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
52 | - ]); |
|
52 | + ] ); |
|
53 | 53 | return $links; |
54 | 54 | } |
55 | 55 | |
@@ -60,19 +60,19 @@ discard block |
||
60 | 60 | public function filterDashboardGlanceItems( array $items ) |
61 | 61 | { |
62 | 62 | $postCount = wp_count_posts( Application::POST_TYPE ); |
63 | - if( empty( $postCount->publish )) { |
|
63 | + if( empty($postCount->publish) ) { |
|
64 | 64 | return $items; |
65 | 65 | } |
66 | 66 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
67 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
67 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
68 | 68 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
69 | 69 | ? glsr( Builder::class )->a( $text, [ |
70 | 70 | 'class' => 'glsr-review-count', |
71 | 71 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
72 | - ]) |
|
72 | + ] ) |
|
73 | 73 | : glsr( Builder::class )->span( $text, [ |
74 | 74 | 'class' => 'glsr-review-count', |
75 | - ]); |
|
75 | + ] ); |
|
76 | 76 | return $items; |
77 | 77 | } |
78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function filterTinymcePlugins( array $plugins ) |
84 | 84 | { |
85 | 85 | if( user_can_richedit() |
86 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
86 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
87 | 87 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
88 | 88 | } |
89 | 89 | return $plugins; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function registerShortcodeButtons() |
97 | 97 | { |
98 | - $command = new RegisterShortcodeButtons([ |
|
98 | + $command = new RegisterShortcodeButtons( [ |
|
99 | 99 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
100 | 100 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
101 | 101 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
102 | - ]); |
|
102 | + ] ); |
|
103 | 103 | $this->execute( $command ); |
104 | 104 | } |
105 | 105 | |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function renderReviewEditor( WP_Post $post ) |
111 | 111 | { |
112 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
112 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
113 | 113 | glsr()->render( 'partials/editor/review', [ |
114 | 114 | 'post' => $post, |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function renderReviewNotice( WP_Post $post ) |
123 | 123 | { |
124 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
125 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
124 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
125 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
126 | 126 | glsr( Template::class )->render( 'partials/editor/notice', [ |
127 | 127 | 'context' => [ |
128 | 128 | 'notices' => glsr( Notice::class )->get(), |
129 | 129 | ], |
130 | - ]); |
|
130 | + ] ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
142 | 142 | $shortcodes[$shortcode] = $values; |
143 | 143 | } |
144 | - if( empty( $shortcodes ))return; |
|
144 | + if( empty($shortcodes) )return; |
|
145 | 145 | glsr()->render( 'partials/editor/tinymce', [ |
146 | 146 | 'shortcodes' => $shortcodes, |
147 | - ]); |
|
147 | + ] ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | public function routerClearConsole() |
154 | 154 | { |
155 | 155 | glsr( Console::class )->clear(); |
156 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
156 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function routerFetchConsole() |
163 | 163 | { |
164 | - glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' )); |
|
164 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,20 +171,20 @@ discard block |
||
171 | 171 | public function routerCountReviews( $showNotice = true ) |
172 | 172 | { |
173 | 173 | $countManager = glsr( CountsManager::class ); |
174 | - $terms = get_terms([ |
|
174 | + $terms = get_terms( [ |
|
175 | 175 | 'hide_empty' => true, |
176 | 176 | 'taxonomy' => Application::TAXONOMY, |
177 | - ]); |
|
177 | + ] ); |
|
178 | 178 | foreach( $terms as $term ) { |
179 | - $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id )); |
|
179 | + $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) ); |
|
180 | 180 | } |
181 | 181 | $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' ); |
182 | 182 | foreach( $postIds as $postId ) { |
183 | - $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId )); |
|
183 | + $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) ); |
|
184 | 184 | } |
185 | 185 | $countManager->setCounts( $countManager->buildCounts() ); |
186 | 186 | if( $showNotice ) { |
187 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
187 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | { |
220 | 220 | $file = $_FILES['import-file']; |
221 | 221 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
222 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
222 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
223 | 223 | } |
224 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
225 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
224 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
225 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
226 | 226 | } |
227 | 227 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
228 | - if( empty( $settings )) { |
|
229 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
228 | + if( empty($settings) ) { |
|
229 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
230 | 230 | } |
231 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
232 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
231 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
232 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
248 | 248 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
249 | 249 | ]; |
250 | - return !isset( $errors[$errorCode] ) |
|
250 | + return !isset($errors[$errorCode]) |
|
251 | 251 | ? __( 'Unknown upload error.', 'site-reviews' ) |
252 | 252 | : $errors[$errorCode]; |
253 | 253 | } |