| @@ -187,10 +187,15 @@ | ||
| 187 | 187 | $headers['method'] = 'get'; |
| 188 | 188 | } |
| 189 | 189 | $methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) ); |
| 190 | 190 | |
| 191 | + $auth = isset( $headers['auth'] ) ? $headers['auth'] : ''; | |
| 192 | + $auth_username = is_array( $auth ) && isset( $auth['username'] ) ? $auth['username'] : ''; | |
| 193 | + $auth_password = is_array( $auth ) && isset( $auth['password'] ) ? $auth['password'] : ''; | |
| 194 | + $auth_string = is_string( $auth ) ? $auth : ''; | |
| 195 | + | |
| 191 | 196 | // open the headers by default? |
| 192 | - $headers_open = $headers && array_key_exists( 'auth', $headers ) && ( array_key_exists( 'username', $headers['auth'] ) && ! empty( $headers['auth']['username'] ) ) || ( ! empty( $headers['auth'] ) && is_string( $headers['auth'] ) ); | |
| 197 | + $headers_open = ! empty( $auth_username ) || ! empty( $auth_string ); | |
| 193 | 198 | ?> |
| 194 | 199 | <div id="visualizer-json-screen" style="display: none"> |
| 195 | 200 | <div class="visualizer-json-form"> |
| 196 | 201 | <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3> |
| @@ -241,9 +246,9 @@ | ||
| 241 | 246 | <input |
| 242 | 247 | type="text" |
| 243 | 248 | id="vz-import-json-username" |
| 244 | 249 | name="username" |
| 245 | - value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'username', $headers['auth'] ) ? $headers['auth']['username'] : '' ); ?>" | |
| 250 | + value="<?php echo esc_attr( $auth_username ); ?>" | |
| 246 | 251 | placeholder="<?php esc_html_e( 'Username/Access Key', 'visualizer' ); ?>" |
| 247 | 252 | class="json-form-element"> |
| 248 | 253 | & |
| 249 | 254 | <input |
| @@ -249,9 +254,9 @@ | ||
| 249 | 254 | <input |
| 250 | 255 | type="password" |
| 251 | 256 | id="vz-import-json-password" |
| 252 | 257 | name="password" |
| 253 | - value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'password', $headers['auth'] ) ? $headers['auth']['password'] : '' ); ?>" | |
| 258 | + value="<?php echo esc_attr( $auth_password ); ?>" | |
| 254 | 259 | placeholder="<?php esc_html_e( 'Password/Secret Key', 'visualizer' ); ?>" |
| 255 | 260 | class="json-form-element"> |
| 256 | 261 | </div> |
| 257 | 262 | </div> |
| @@ -265,9 +270,9 @@ | ||
| 265 | 270 | <input |
| 266 | 271 | type="text" |
| 267 | 272 | id="vz-import-json-auth" |
| 268 | 273 | name="auth" |
| 269 | - value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>" | |
| 274 | + value="<?php echo esc_attr( $auth_string ); ?>" | |
| 270 | 275 | placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>" |
| 271 | 276 | class="visualizer-input json-form-element"> |
| 272 | 277 | </div> |
| 273 | 278 | </div> |
| @@ -273,9 +278,9 @@ | ||
| 273 | 278 | </div> |
| 274 | 279 | <div class="json-wizard-header"> |
| 275 | 280 | <div class="field-title"><?php esc_html_e( 'Additional headers', 'visualizer' ); ?></div> |
| 276 | 281 | <div> |
| 277 | - <textarea name="additional_headers" class="visualizer-input" placeholder="<?php esc_html_e( 'Key:Value, Key2:Value2,...', 'visualizer' ); ?>"><?php echo isset( $headers['additional_headers'] ) ? $headers['additional_headers'] : ''; ?></textarea> | |
| 282 | + <textarea name="additional_headers" class="visualizer-input" placeholder="<?php esc_html_e( 'Key:Value, Key2:Value2,...', 'visualizer' ); ?>"><?php echo esc_textarea( isset( $headers['additional_headers'] ) ? $headers['additional_headers'] : '' ); ?></textarea> | |
| 278 | 283 | </div> |
| 279 | 284 | </div> |
| 280 | 285 | </div> |
| 281 | 286 | </div> |
| @@ -288,9 +293,9 @@ | ||
| 288 | 293 | <select name="root" id="vz-import-json-root" class="json-form-element"> |
| 289 | 294 | <?php |
| 290 | 295 | if ( ! empty( $root ) ) { |
| 291 | 296 | ?> |
| 292 | - <option value="<?php echo esc_attr( $root ); ?>"><?php echo str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ); ?></option> | |
| 297 | + <option value="<?php echo esc_attr( $root ); ?>"><?php echo esc_html( str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ) ); ?></option> | |
| 293 | 298 | <?php |
| 294 | 299 | } |
| 295 | 300 | ?> |
| 296 | 301 | </select> |
| @@ -306,9 +311,9 @@ | ||
| 306 | 311 | <option value="0" class="static"><?php _e( 'Get results from the first page only', 'visualizer' ); ?></option> |
| 307 | 312 | <?php |
| 308 | 313 | if ( ! empty( $paging ) ) { |
| 309 | 314 | ?> |
| 310 | - <option value="<?php echo esc_attr( $paging ); ?>"><?php echo sprintf( 'Get results from the first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $paging ) ); ?></option> | |
| 315 | + <option value="<?php echo esc_attr( $paging ); ?>"><?php echo esc_html( sprintf( 'Get results from the first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $paging ) ) ); ?></option> | |
| 311 | 316 | <?php |
| 312 | 317 | } |
| 313 | 318 | ?> |
| 314 | 319 | </select> |