@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | 'is_multi' => false, |
24 | 24 | 'is_valid' => true, |
25 | 25 | 'path' => '', |
26 | - ]); |
|
26 | + ] ); |
|
27 | 27 | $this->normalize(); |
28 | 28 | } |
29 | 29 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | return glsr( Template::class )->build( 'partials/settings/form-table-row', [ |
41 | 41 | 'context' => [ |
42 | 42 | 'class' => $this->getFieldClass(), |
43 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
43 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
44 | 44 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
45 | 45 | ], |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | 'context' => [ |
64 | 64 | 'class' => $this->getFieldClass(), |
65 | 65 | 'depends_on' => $this->getFieldDependsOn(), |
66 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
66 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
67 | 67 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
68 | 68 | 'legend' => $this->field['legend'], |
69 | 69 | ], |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function getFieldDefault() |
87 | 87 | { |
88 | - return isset( $this->field['default'] ) |
|
88 | + return isset($this->field['default']) |
|
89 | 89 | ? $this->field['default'] |
90 | 90 | : ''; |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function getFieldDependsOn() |
97 | 97 | { |
98 | - return !empty( $this->field['depends_on'] ) |
|
98 | + return !empty($this->field['depends_on']) |
|
99 | 99 | ? $this->field['depends_on'] |
100 | 100 | : ''; |
101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $path, |
112 | 112 | glsr( Helper::class )->getPathValue( $path, glsr()->defaults ) |
113 | 113 | ); |
114 | - if( is_array( $expectedValue )) { |
|
114 | + if( is_array( $expectedValue ) ) { |
|
115 | 115 | return !in_array( $optionValue, $expectedValue ); |
116 | 116 | } |
117 | 117 | return $optionValue != $expectedValue; |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | 'label', 'name', 'type', |
129 | 129 | ]; |
130 | 130 | foreach( $requiredValues as $value ) { |
131 | - if( isset( $this->field[$value] ))continue; |
|
131 | + if( isset($this->field[$value]) )continue; |
|
132 | 132 | $missingValues[] = $value; |
133 | 133 | $isValid = $this->field['is_valid'] = false; |
134 | 134 | } |
135 | - if( !empty( $missingValues )) { |
|
135 | + if( !empty($missingValues) ) { |
|
136 | 136 | glsr_log() |
137 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
137 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
138 | 138 | ->info( $this->field ); |
139 | 139 | } |
140 | 140 | return $isValid; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $field = $this->field; |
150 | 150 | foreach( $field as $key => $value ) { |
151 | 151 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
152 | - if( !method_exists( $this, $methodName ))continue; |
|
152 | + if( !method_exists( $this, $methodName ) )continue; |
|
153 | 153 | $this->$methodName(); |
154 | 154 | } |
155 | 155 | $this->normalizeFieldId(); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function normalizeDependsOn() |
164 | 164 | { |
165 | - if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return; |
|
165 | + if( empty($this->field['depends_on']) || !is_array( $this->field['depends_on'] ) )return; |
|
166 | 166 | $path = key( $this->field['depends_on'] ); |
167 | 167 | $value = $this->field['depends_on'][$path]; |
168 | - $this->field['depends_on'] = json_encode([ |
|
168 | + $this->field['depends_on'] = json_encode( [ |
|
169 | 169 | 'name' => glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ), |
170 | 170 | 'value' => $value, |
171 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
171 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
172 | 172 | $this->field['is_hidden'] = $this->isFieldHidden( $path, $value ); |
173 | 173 | } |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function normalizeFieldId() |
179 | 179 | { |
180 | - if( isset( $this->field['id'] ))return; |
|
180 | + if( isset($this->field['id']) )return; |
|
181 | 181 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
182 | 182 | } |
183 | 183 | |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | protected function normalizeFieldType() |
188 | 188 | { |
189 | 189 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], 'Modules\Html\Fields' ); |
190 | - if( class_exists( $className )) { |
|
190 | + if( class_exists( $className ) ) { |
|
191 | 191 | $this->field = array_merge( $this->field, glsr( $className )->defaults() ); |
192 | 192 | } |
193 | - if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES )) { |
|
193 | + if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES ) ) { |
|
194 | 194 | $this->field['is_multi'] = true; |
195 | 195 | } |
196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function normalizeFieldValue() |
202 | 202 | { |
203 | - if( isset( $this->field['value'] ))return; |
|
203 | + if( isset($this->field['value']) )return; |
|
204 | 204 | $this->field['value'] = glsr( OptionManager::class )->get( |
205 | 205 | $this->field['path'], |
206 | 206 | $this->getFieldDefault() |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | protected function normalizeLabel() |
214 | 214 | { |
215 | 215 | $this->field['legend'] = $this->field['label']; |
216 | - unset( $this->field['label'] ); |
|
216 | + unset($this->field['label']); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function build() |
34 | 34 | { |
35 | - if( !$this->field['is_valid'] )return; |
|
35 | + if( !$this->field['is_valid'] ) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | if( $this->field['is_multi'] ) { |
37 | 39 | return $this->buildMultiField(); |
38 | 40 | } |
@@ -128,7 +130,9 @@ discard block |
||
128 | 130 | 'label', 'name', 'type', |
129 | 131 | ]; |
130 | 132 | foreach( $requiredValues as $value ) { |
131 | - if( isset( $this->field[$value] ))continue; |
|
133 | + if( isset( $this->field[$value] )) { |
|
134 | + continue; |
|
135 | + } |
|
132 | 136 | $missingValues[] = $value; |
133 | 137 | $isValid = $this->field['is_valid'] = false; |
134 | 138 | } |
@@ -145,11 +149,15 @@ discard block |
||
145 | 149 | */ |
146 | 150 | protected function normalize() |
147 | 151 | { |
148 | - if( !$this->isFieldValid() )return; |
|
152 | + if( !$this->isFieldValid() ) { |
|
153 | + return; |
|
154 | + } |
|
149 | 155 | $field = $this->field; |
150 | 156 | foreach( $field as $key => $value ) { |
151 | 157 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
152 | - if( !method_exists( $this, $methodName ))continue; |
|
158 | + if( !method_exists( $this, $methodName )) { |
|
159 | + continue; |
|
160 | + } |
|
153 | 161 | $this->$methodName(); |
154 | 162 | } |
155 | 163 | $this->normalizeFieldId(); |
@@ -162,7 +170,9 @@ discard block |
||
162 | 170 | */ |
163 | 171 | protected function normalizeDependsOn() |
164 | 172 | { |
165 | - if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return; |
|
173 | + if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] )) { |
|
174 | + return; |
|
175 | + } |
|
166 | 176 | $path = key( $this->field['depends_on'] ); |
167 | 177 | $value = $this->field['depends_on'][$path]; |
168 | 178 | $this->field['depends_on'] = json_encode([ |
@@ -177,7 +187,9 @@ discard block |
||
177 | 187 | */ |
178 | 188 | protected function normalizeFieldId() |
179 | 189 | { |
180 | - if( isset( $this->field['id'] ))return; |
|
190 | + if( isset( $this->field['id'] )) { |
|
191 | + return; |
|
192 | + } |
|
181 | 193 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
182 | 194 | } |
183 | 195 | |
@@ -200,7 +212,9 @@ discard block |
||
200 | 212 | */ |
201 | 213 | protected function normalizeFieldValue() |
202 | 214 | { |
203 | - if( isset( $this->field['value'] ))return; |
|
215 | + if( isset( $this->field['value'] )) { |
|
216 | + return; |
|
217 | + } |
|
204 | 218 | $this->field['value'] = glsr( OptionManager::class )->get( |
205 | 219 | $this->field['path'], |
206 | 220 | $this->getFieldDefault() |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | return $input; |
22 | 22 | } |
23 | 23 | $triggered = true; |
24 | - if( !is_array( $input )) { |
|
24 | + if( !is_array( $input ) ) { |
|
25 | 25 | $input = ['settings' => []]; |
26 | 26 | } |
27 | 27 | if( key( $input ) == 'settings' ) { |
28 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
28 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
29 | 29 | } |
30 | 30 | $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
31 | 31 | $options = $this->sanitizeSubmissions( $input, $options ); |
@@ -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 | /** |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function sanitizeSubmissions( array $input, array $options ) |
51 | 51 | { |
52 | - if( isset( $input['settings']['submissions'] )) { |
|
52 | + if( isset($input['settings']['submissions']) ) { |
|
53 | 53 | $inputForm = $input['settings']['submissions']; |
54 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
54 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
55 | 55 | ? $inputForm['required'] |
56 | 56 | : []; |
57 | 57 | } |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function sanitizeTranslations( array $input, array $options ) |
65 | 65 | { |
66 | - if( isset( $input['settings']['strings'] )) { |
|
67 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
66 | + if( isset($input['settings']['strings']) ) { |
|
67 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
68 | 68 | array_walk( $options['settings']['strings'], function( &$string ) { |
69 | - if( isset( $string['s2'] )) { |
|
69 | + if( isset($string['s2']) ) { |
|
70 | 70 | $string['s2'] = wp_strip_all_tags( $string['s2'] ); |
71 | 71 | } |
72 | - if( isset( $string['p2'] )) { |
|
72 | + if( isset($string['p2']) ) { |
|
73 | 73 | $string['p2'] = wp_strip_all_tags( $string['p2'] ); |
74 | 74 | } |
75 | 75 | }); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'inactive-plugin' => 'Inactive Plugins', |
38 | 38 | 'setting' => 'Plugin Settings', |
39 | 39 | ]; |
40 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
40 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
41 | 41 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
42 | 42 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
43 | 43 | return $carry.$this->implode( $details[$key], $systemDetails ); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | { |
55 | 55 | $plugins = get_plugins(); |
56 | 56 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
57 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
58 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
57 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
58 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getInactivePluginDetails() |
80 | 80 | { |
81 | 81 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
82 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
82 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | { |
90 | 90 | $plugins = array_merge( |
91 | 91 | get_mu_plugins(), |
92 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
92 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
93 | 93 | ); |
94 | - if( empty( $plugins ))return; |
|
94 | + if( empty($plugins) )return; |
|
95 | 95 | return $this->normalizePluginList( $plugins ); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function getMultisitePluginDetails() |
102 | 102 | { |
103 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
103 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
104 | 104 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
105 | 105 | } |
106 | 106 | |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
123 | 123 | 'Memory Limit' => ini_get( 'memory_limit' ), |
124 | 124 | 'Post Max Size' => ini_get( 'post_max_size' ), |
125 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
126 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
127 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
128 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
129 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
125 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
126 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
127 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
128 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
129 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
130 | 130 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
131 | 131 | ]; |
132 | 132 | } |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
155 | 155 | $settings = $helper->flattenArray( $settings, true ); |
156 | 156 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
157 | - if( empty( $settings[$key] ))continue; |
|
157 | + if( empty($settings[$key]) )continue; |
|
158 | 158 | $settings[$key] = str_repeat( '*', 10 ); |
159 | 159 | } |
160 | 160 | $details = []; |
161 | 161 | foreach( $settings as $key => $value ) { |
162 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
163 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
162 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
163 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
164 | 164 | $details[$key] = $value; |
165 | 165 | } |
166 | 166 | return $details; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | return $value; |
241 | 241 | } |
242 | 242 | } |
243 | - return implode( ',', array_filter( [DB_HOST, $serverName] )); |
|
243 | + return implode( ',', array_filter( [DB_HOST, $serverName] ) ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | { |
262 | 262 | $plugins = get_plugins(); |
263 | 263 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
264 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
265 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
264 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
265 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
266 | 266 | return $active + $inactive; |
267 | 267 | } |
268 | 268 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | protected function implode( $title, array $details ) |
274 | 274 | { |
275 | 275 | $strings = ['['.$title.']']; |
276 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
276 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
277 | 277 | $padding = max( [$padding, static::PAD] ); |
278 | 278 | foreach( $details as $key => $value ) { |
279 | 279 | $strings[] = is_string( $key ) |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | get_mu_plugins(), |
92 | 92 | get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
93 | 93 | ); |
94 | - if( empty( $plugins ))return; |
|
94 | + if( empty( $plugins )) { |
|
95 | + return; |
|
96 | + } |
|
95 | 97 | return $this->normalizePluginList( $plugins ); |
96 | 98 | } |
97 | 99 | |
@@ -100,7 +102,9 @@ discard block |
||
100 | 102 | */ |
101 | 103 | public function getMultisitePluginDetails() |
102 | 104 | { |
103 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
105 | + if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] ))) { |
|
106 | + return; |
|
107 | + } |
|
104 | 108 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
105 | 109 | } |
106 | 110 | |
@@ -154,12 +158,16 @@ discard block |
||
154 | 158 | $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
155 | 159 | $settings = $helper->flattenArray( $settings, true ); |
156 | 160 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
157 | - if( empty( $settings[$key] ))continue; |
|
161 | + if( empty( $settings[$key] )) { |
|
162 | + continue; |
|
163 | + } |
|
158 | 164 | $settings[$key] = str_repeat( '*', 10 ); |
159 | 165 | } |
160 | 166 | $details = []; |
161 | 167 | foreach( $settings as $key => $value ) { |
162 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
168 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key )) { |
|
169 | + continue; |
|
170 | + } |
|
163 | 171 | $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
164 | 172 | $details[$key] = $value; |
165 | 173 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | : $this->$method( $id ); |
24 | 24 | return glsr( Template::class )->build( 'pages/settings/'.$id, [ |
25 | 25 | 'context' => $context, |
26 | - ]); |
|
26 | + ] ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | protected function getSettingFields( $path ) |
42 | 42 | { |
43 | 43 | $settings = glsr( DefaultsManager::class )->settings(); |
44 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
44 | + return array_filter( $settings, function( $key ) use($path) { |
|
45 | 45 | return glsr( Helper::class )->startsWith( $path, $key ); |
46 | 46 | }, ARRAY_FILTER_USE_KEY ); |
47 | 47 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function getTemplateContext( $id ) |
54 | 54 | { |
55 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
55 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
56 | 56 | $rows = ''; |
57 | 57 | foreach( $fields as $name => $field ) { |
58 | 58 | $field = wp_parse_args( $field, ['name' => $name] ); |
59 | - $rows.= (new Field( $field ))->build(); |
|
59 | + $rows .= (new Field( $field ))->build(); |
|
60 | 60 | } |
61 | 61 | return [ |
62 | 62 | 'rows' => $rows, |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | protected function getTemplateContextForTranslations() |
70 | 70 | { |
71 | 71 | $translations = glsr( Translator::class )->renderAll(); |
72 | - $class = empty( $translations ) |
|
72 | + $class = empty($translations) |
|
73 | 73 | ? 'glsr-hidden' |
74 | 74 | : ''; |
75 | 75 | return [ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | wp_send_json( glsr( Html::class )->renderPartial( 'link', [ |
26 | 26 | 'post_id' => $request['ID'], |
27 | - ])); |
|
27 | + ] ) ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function routerChangeReviewStatus( array $request ) |
34 | 34 | { |
35 | - wp_send_json( $this->execute( new ChangeStatus( $request ))); |
|
35 | + wp_send_json( $this->execute( new ChangeStatus( $request ) ) ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | public function routerClearLog() |
42 | 42 | { |
43 | 43 | glsr( AdminController::class )->routerClearLog(); |
44 | - wp_send_json([ |
|
44 | + wp_send_json( [ |
|
45 | 45 | 'logger' => glsr( Logger::class )->get(), |
46 | 46 | 'notices' => glsr( Notice::class )->get(), |
47 | - ]); |
|
47 | + ] ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | { |
55 | 55 | $shortcode = $request['shortcode']; |
56 | 56 | $response = false; |
57 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
57 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
58 | 58 | $data = glsr()->mceShortcodes[$shortcode]; |
59 | - if( !empty( $data['errors'] )) { |
|
59 | + if( !empty($data['errors']) ) { |
|
60 | 60 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
61 | 61 | } |
62 | 62 | $response = [ |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | public function routerSearchPosts( array $request ) |
77 | 77 | { |
78 | 78 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
79 | - wp_send_json_success([ |
|
79 | + wp_send_json_success( [ |
|
80 | 80 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
81 | 81 | 'items' => $results, |
82 | - ]); |
|
82 | + ] ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function routerSearchTranslations( array $request ) |
89 | 89 | { |
90 | - if( empty( $request['exclude'] )) { |
|
90 | + if( empty($request['exclude']) ) { |
|
91 | 91 | $request['exclude'] = []; |
92 | 92 | } |
93 | 93 | $results = glsr( Translator::class ) |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | ->exclude() |
96 | 96 | ->exclude( $request['exclude'] ) |
97 | 97 | ->renderResults(); |
98 | - wp_send_json_success([ |
|
98 | + wp_send_json_success( [ |
|
99 | 99 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
100 | 100 | 'items' => $results, |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | { |
109 | 109 | $response = glsr( PublicController::class )->routerCreateReview( $request ); |
110 | 110 | $session = glsr( Session::class ); |
111 | - wp_send_json([ |
|
111 | + wp_send_json( [ |
|
112 | 112 | 'errors' => $session->get( $request['form_id'].'-errors', false, true ), |
113 | 113 | 'message' => $response, |
114 | 114 | 'recaptcha' => $session->get( $request['form_id'].'-recaptcha', false, true ), |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function routerTogglePinned( array $request ) |
122 | 122 | { |
123 | - wp_send_json([ |
|
123 | + wp_send_json( [ |
|
124 | 124 | 'notices' => glsr( Notice::class )->get(), |
125 | - 'pinned' => $this->execute( new TogglePinned( $request )), |
|
126 | - ]); |
|
125 | + 'pinned' => $this->execute( new TogglePinned( $request ) ), |
|
126 | + ] ); |
|
127 | 127 | } |
128 | 128 | } |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
19 | - if( !isset( $request['action'] ))return; |
|
19 | + if( !isset( $request['action'] )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | $this->checkNonce( $request['action'] ); |
21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 24 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | public function routeWebhookRequest() |
72 | 74 | { |
73 | 75 | $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
74 | - if( !$request )return; |
|
76 | + if( !$request ) { |
|
77 | + return; |
|
78 | + } |
|
75 | 79 | // @todo manage webhook here |
76 | 80 | } |
77 | 81 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
19 | - if( !isset( $request['action'] ))return; |
|
19 | + if( !isset($request['action']) )return; |
|
20 | 20 | $this->checkNonce( $request['action'] ); |
21 | 21 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 22 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function routeAjaxRequest() |
28 | 28 | { |
29 | 29 | $request = $this->normalizeAjaxRequest(); |
30 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
30 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
31 | 31 | glsr_log()->error( 'Nonce check failed for ajax request' )->info( $request ); |
32 | 32 | wp_die( -1, 403 ); |
33 | 33 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function routeRequest( $type, $action, array $request = [] ) |
54 | 54 | { |
55 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
55 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
56 | 56 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
57 | - if( is_callable( [$controller, $method] )) { |
|
57 | + if( is_callable( [$controller, $method] ) ) { |
|
58 | 58 | call_user_func( [$controller, $method], $request ); |
59 | 59 | return; |
60 | 60 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function routeWebhookRequest() |
72 | 72 | { |
73 | - $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
|
73 | + $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID ) ); |
|
74 | 74 | if( !$request )return; |
75 | 75 | // @todo manage webhook here |
76 | 76 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | protected function normalizeAjaxRequest() |
110 | 110 | { |
111 | 111 | $request = filter_input( INPUT_POST, 'request', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
112 | - if( isset( $request[Application::ID]['action'] )) { |
|
112 | + if( isset($request[Application::ID]['action']) ) { |
|
113 | 113 | $request = $request[Application::ID]; |
114 | 114 | } |
115 | - if( !isset( $request['action'] )) { |
|
115 | + if( !isset($request['action']) ) { |
|
116 | 116 | glsr_log()->error( 'The AJAX request must include an action' )->info( $request ); |
117 | 117 | wp_die(); |
118 | 118 | } |
119 | - if( !isset( $request['nonce'] )) { |
|
119 | + if( !isset($request['nonce']) ) { |
|
120 | 120 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
121 | 121 | wp_die(); |
122 | 122 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function all() |
25 | 25 | { |
26 | 26 | $options = get_option( static::databaseKey(), [] ); |
27 | - if( !is_array( $options )) { |
|
27 | + if( !is_array( $options ) ) { |
|
28 | 28 | delete_option( static::databaseKey() ); |
29 | 29 | $options = ['settings' => []]; |
30 | 30 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) )continue; |
|
46 | 46 | $pointer = &$pointer[$key]; |
47 | 47 | } |
48 | - unset( $pointer[$last] ); |
|
48 | + unset($pointer[$last]); |
|
49 | 49 | return $this->set( $options ); |
50 | 50 | } |
51 | 51 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | glsr( DefaultsManager::class )->defaults() |
78 | 78 | ); |
79 | 79 | array_walk( $options, function( &$value ) { |
80 | - if( !is_string( $value ))return; |
|
81 | - $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
|
80 | + if( !is_string( $value ) )return; |
|
81 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
82 | 82 | }); |
83 | 83 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
84 | 84 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function set( $pathOrOptions, $value = '' ) |
92 | 92 | { |
93 | - if( is_string( $pathOrOptions )) { |
|
93 | + if( is_string( $pathOrOptions ) ) { |
|
94 | 94 | $pathOrOptions = glsr( Helper::class )->setPathValue( $pathOrOptions, $value, $this->all() ); |
95 | 95 | } |
96 | 96 | return update_option( static::databaseKey(), (array)$pathOrOptions ); |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | $pointer = &$pointer[$key]; |
47 | 49 | } |
48 | 50 | unset( $pointer[$last] ); |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | glsr( DefaultsManager::class )->defaults() |
78 | 80 | ); |
79 | 81 | array_walk( $options, function( &$value ) { |
80 | - if( !is_string( $value ))return; |
|
82 | + if( !is_string( $value )) { |
|
83 | + return; |
|
84 | + } |
|
81 | 85 | $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
82 | 86 | }); |
83 | 87 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - $postId = wp_update_post([ |
|
15 | + $postId = wp_update_post( [ |
|
16 | 16 | 'ID' => $command->id, |
17 | 17 | 'post_status' => $command->status, |
18 | - ]); |
|
19 | - if( is_wp_error( $postId )) { |
|
18 | + ] ); |
|
19 | + if( is_wp_error( $postId ) ) { |
|
20 | 20 | glsr_log()->error( $postId->get_error_message() ); |
21 | 21 | return []; |
22 | 22 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'aria-label' => '“'.esc_attr( $title ).'” ('.__( 'Edit', 'site-reviews' ).')', |
38 | 38 | 'class' => 'row-title', |
39 | 39 | 'href' => get_edit_post_link( $postId ), |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | protected function getPostState( $postId ) |
48 | 48 | { |
49 | 49 | ob_start(); |
50 | - _post_states( get_post( $postId )); |
|
50 | + _post_states( get_post( $postId ) ); |
|
51 | 51 | return ob_get_clean(); |
52 | 52 | } |
53 | 53 | } |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | public function fields() |
14 | 14 | { |
15 | 15 | return [[ |
16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
17 | 17 | 'minWidth' => 320, |
18 | 18 | 'type' => 'container', |
19 | - ],[ |
|
19 | + ], [ |
|
20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
21 | 21 | 'name' => 'title', |
22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
23 | 23 | 'type' => 'textbox', |
24 | - ],[ |
|
24 | + ], [ |
|
25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
26 | 26 | 'maxLength' => 5, |
27 | 27 | 'name' => 'count', |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | 'text' => '10', |
30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
31 | 31 | 'type' => 'textbox', |
32 | - ],[ |
|
32 | + ], [ |
|
33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
34 | 34 | 'name' => 'rating', |
35 | 35 | 'options' => [ |
36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
41 | 41 | ], |
42 | 42 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
43 | 43 | 'type' => 'listbox', |
44 | - ],[ |
|
44 | + ], [ |
|
45 | 45 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
46 | 46 | 'name' => 'pagination', |
47 | 47 | 'options' => [ |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | 'name' => 'assigned_to', |
60 | 60 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
61 | 61 | 'type' => 'textbox', |
62 | - ],[ |
|
62 | + ], [ |
|
63 | 63 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
64 | 64 | 'name' => 'schema', |
65 | 65 | 'options' => [ |
@@ -68,44 +68,44 @@ discard block |
||
68 | 68 | ], |
69 | 69 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
70 | 70 | 'type' => 'listbox', |
71 | - ],[ |
|
71 | + ], [ |
|
72 | 72 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
73 | 73 | 'name' => 'class', |
74 | 74 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
75 | 75 | 'type' => 'textbox', |
76 | - ],[ |
|
76 | + ], [ |
|
77 | 77 | 'columns' => 2, |
78 | 78 | 'items' => [[ |
79 | 79 | 'name' => 'hide_author', |
80 | 80 | 'text' => esc_html__( 'Author', 'site-reviews' ), |
81 | 81 | 'tooltip' => __( 'Hide the review author?', 'site-reviews' ), |
82 | 82 | 'type' => 'checkbox', |
83 | - ],[ |
|
83 | + ], [ |
|
84 | 84 | 'name' => 'hide_avatar', |
85 | 85 | 'text' => esc_html__( 'Avatar', 'site-reviews' ), |
86 | 86 | 'tooltip' => __( 'Hide the reviewer avatar if shown?', 'site-reviews' ), |
87 | 87 | 'type' => 'checkbox', |
88 | - ],[ |
|
88 | + ], [ |
|
89 | 89 | 'name' => 'hide_date', |
90 | 90 | 'text' => esc_html__( 'Date', 'site-reviews' ), |
91 | 91 | 'tooltip' => __( 'Hide the review date?', 'site-reviews' ), |
92 | 92 | 'type' => 'checkbox', |
93 | - ],[ |
|
93 | + ], [ |
|
94 | 94 | 'name' => 'hide_excerpt', |
95 | 95 | 'text' => esc_html__( 'Excerpt', 'site-reviews' ), |
96 | 96 | 'tooltip' => __( 'Hide the review excerpt?', 'site-reviews' ), |
97 | 97 | 'type' => 'checkbox', |
98 | - ],[ |
|
98 | + ], [ |
|
99 | 99 | 'name' => 'hide_rating', |
100 | 100 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
101 | 101 | 'tooltip' => __( 'Hide the review rating?', 'site-reviews' ), |
102 | 102 | 'type' => 'checkbox', |
103 | - ],[ |
|
103 | + ], [ |
|
104 | 104 | 'name' => 'hide_response', |
105 | 105 | 'text' => esc_html__( 'Response', 'site-reviews' ), |
106 | 106 | 'tooltip' => __( 'Hide the review response?', 'site-reviews' ), |
107 | 107 | 'type' => 'checkbox', |
108 | - ],[ |
|
108 | + ], [ |
|
109 | 109 | 'name' => 'hide_title', |
110 | 110 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
111 | 111 | 'tooltip' => __( 'Hide the review title?', 'site-reviews' ), |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
116 | 116 | 'spacing' => 5, |
117 | 117 | 'type' => 'container', |
118 | - ],[ |
|
118 | + ], [ |
|
119 | 119 | 'hidden' => true, |
120 | 120 | 'name' => 'id', |
121 | 121 | 'type' => 'textbox', |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function getTerms() |
129 | 129 | { |
130 | 130 | $terms = glsr( Database::class )->getTerms(); |
131 | - if( empty( $terms )) { |
|
131 | + if( empty($terms) ) { |
|
132 | 132 | return []; |
133 | 133 | } |
134 | 134 | return [ |