PluginProbe
WPGet API – Connect to any external REST API / 1.7.0
WPGet API – Connect to any external REST API v1.7.0
1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 All 97 releases
← All changes | includes/class-api.php +73 -370 2.0.31.7.0 View file →
@@ -28,11 +28,8 @@
28 28 public $header_parameters = ''; // the header paramaters
29 29 public $body_parameters = ''; // the body paramaters
30 30 public $body_json_encode = ''; // body_json_encode body
31 31 public $body_url_encode = ''; // urlencode body
32 - public $body_base64_encode = ''; // base64 encode body
33 - public $body_xml_format = ''; // xml format body
34 - public $xml_root_node = 'root'; // root node for xml
35 32
36 33 public $response = ''; // the returned response
37 34
38 35 public $final_url = ''; // final URL
@@ -37,12 +34,10 @@
37 34
38 35 public $final_url = ''; // final URL
39 36 public $final_request_args = array(); // final request_args
40 37
41 - public $results_format = 'json_string'; // results format
38 + public $results_format = 'json_string'; // reseults format
42 39
43 - public $response_code = ''; // the response code from the call
44 -
45 40 public $timeout = 10; // the timeout
46 41 public $sslverify = 1; // the paramaters
47 42 public $debug = false;
48 43
@@ -63,9 +58,9 @@
63 58 $this->endpoint_id = sanitize_text_field( $endpoint_id );
64 59 $this->keys = $keys;
65 60 $this->args = $args;
66 61
67 - add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 99, 2 );
62 + add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 5, 2 );
68 63
69 64 }
70 65
71 66
@@ -73,29 +68,8 @@
73 68 * Init our api data
74 69 */
75 70 public function init() {
76 71
77 - // if we are doing importer plugin,
78 - // we need to intercept and modify most of our methods values
79 - if( $this->api_id == 'wpgetapi_importer' ) {
80 -
81 - $data = apply_filters( 'wpgetapi_api_importer_init', $this );
82 -
83 - if( $data ) {
84 -
85 - foreach ($data as $key => $value) {
86 - $this->{$key} = $value;
87 - }
88 -
89 - $this->query_parameters = ! empty( $this->query_parameters ) ? $this->do_parameters( $this->query_parameters ) : array();
90 - $this->header_parameters = ! empty( $this->header_parameters ) ? $this->do_parameters( $this->header_parameters ) : array();
91 - $this->body_parameters = ! empty( $this->body_parameters ) ? $this->do_parameters( $this->body_parameters ) : array();
92 - return;
93 -
94 - }
95 -
96 - }
97 -
98 72 // do some checks
99 73 if( empty( $this->setup ) || ! isset( $this->setup['apis'] ) || empty( $this->setup['apis'] ) )
100 74 return 'No API found.';
101 75
@@ -114,9 +88,9 @@
114 88 // loop through endpoints
115 89 foreach ( $this->api['endpoints'] as $index => $endpoint ) {
116 90
117 91 if( $this->endpoint_id == $endpoint['id'] ) {
118 -
92 +
119 93 $this->method = isset( $endpoint['method'] ) && $endpoint['method'] != '' ? sanitize_text_field( $endpoint['method'] ) : 'GET';
120 94 $this->cache_time = isset( $endpoint['cache_time'] ) && ! empty( $endpoint['cache_time'] ) ? absint( $endpoint['cache_time'] ) : '';
121 95 $this->endpoint = isset( $endpoint['endpoint'] ) && ! empty( $endpoint['endpoint'] ) ? sanitize_text_field( $endpoint['endpoint'] ) : '';
122 96
@@ -125,35 +99,13 @@
125 99 $this->header_parameters = isset( $endpoint['header_parameters'] ) && ! empty( $endpoint['header_parameters'] ) ? $this->do_parameters( $endpoint['header_parameters'] ) : array();
126 100
127 101 $this->body_parameters = isset( $endpoint['body_parameters'] ) && ! empty( $endpoint['body_parameters'] ) ? $this->do_parameters( $endpoint['body_parameters'] ) : array();
128 102
129 - // how to encode the body
130 103 $this->body_json_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'true' ? true : false;
131 104 $this->body_url_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'url' ? true : false;
132 - $this->body_base64_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'base64' ? true : false;
133 - $this->body_xml_format = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'xml' ? true : false;
134 105
135 - $this->xml_root_node = isset( $endpoint['xml_root'] ) && ! empty( $endpoint['xml_root'] ) ? $endpoint['xml_root'] : $this->xml_root_node;
136 -
137 106 $this->results_format = isset( $endpoint['results_format'] ) ? sanitize_text_field( $endpoint['results_format'] ) : $this->results_format;
138 -
139 -
140 - if(
141 - // set the format to php array data if html format is set
142 - ( isset( $this->args['format'] ) && $this->args['format'] == 'html' && $this->results_format != 'xml_array' ) ||
143 - // set the format to php array data if it is set in the args (coming from the importer)
144 - ( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_decoded' )
145 - ) {
146 - $this->results_format = 'json_decoded';
147 - }
148 -
149 - // set the format to JSON string if it is set in the args (coming from the wpdatatables integration)
150 - if( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_string' ) {
151 - $this->results_format = 'json_string';
152 - }
153 -
154 107 }
155 -
156 108 }
157 109
158 110 $this->timeout = isset( $this->api['timeout'] ) && ! empty( $this->api['timeout'] ) ? $this->api['timeout'] : $this->timeout;
159 111 $this->sslverify = isset( $this->api['sslverify'] ) ? absint( $this->api['sslverify'] ) : $this->sslverify;
@@ -166,21 +118,58 @@
166 118 *
167 119 * @param string $field Field to retrieve
168 120 */
169 121 public function endpoint_output() {
122 + return $this->do_the_call();
123 + }
170 124
171 - do_action( 'wpgetapi_before_do_the_call', $this );
172 125
173 - return $this->do_the_call();
126 + /**
127 + * Sort out the parameters if they exist
128 + */
129 + public function do_parameters( $parameters ) {
130 +
131 + $new_array = array();
132 + $parameters = $this->decrypt($parameters);
174 133
134 + if( is_array( $parameters ) ) {
135 + foreach ( $parameters as $key => $parameter ) {
136 + if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
137 + $parameter['value'] = stripslashes( $parameter['value'] );
138 + $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
139 + }
140 + }
141 + }
142 +
143 + // look for array or json string and sort these out - for using such things in shortcode
144 + if( is_array( $new_array ) ) {
145 +
146 + foreach ( $new_array as $key => $value ) {
147 +
148 + // checking if the parameters have a json string
149 + if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
150 + $new_array[ $key ] = json_decode( $value, true);
151 + }
152 +
153 + // checking if the parameters have an array within the string
154 + // if they do, create them as an actual array
155 + if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
156 + $new_array[ $key ] = array( $value );
157 + }
158 +
159 + }
160 +
161 + }
162 +
163 + return $new_array;
164 +
175 165 }
176 166
177 -
178 167 /**
179 168 * Send the request and return our data
180 169 */
181 170 public function do_the_call() {
182 -
171 +
183 172 $this->init();
184 173
185 174 // build the URL
186 175 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
@@ -186,18 +175,9 @@
186 175 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
187 176
188 177 // build the request args
189 178 $this->final_request_args = apply_filters( 'wpgetapi_final_request_args', $this->build_request_args(), $this );
190 -
191 - /**
192 - * Check if we should stop or not. Setting $on to true, will stop us calling the api.
193 - * @param bool $on Whether on is set or not.
194 - */
195 179
196 - if ( apply_filters( 'wpgetapi_should_we_stop', false, $this ) ) {
197 - return;
198 - }
199 -
200 180 // POST request
201 181 if( $this->method == 'POST' )
202 182 $this->response = $this->POST_request();
203 183
@@ -204,20 +184,12 @@
204 184 // PUT request
205 185 if( $this->method == 'PUT' )
206 186 $this->response = $this->PUT_request();
207 187
208 - // PATCH request
209 - if( $this->method == 'PATCH' )
210 - $this->response = $this->PATCH_request();
211 -
212 188 // GET request
213 189 if( $this->method == 'GET' )
214 190 $this->response = $this->GET_request();
215 191
216 - // DELETE request
217 - if( $this->method == 'DELETE' )
218 - $this->response = $this->DELETE_request();
219 -
220 192 // wp error
221 193 if( is_wp_error( $this->response ) ) {
222 194 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
223 195 }
@@ -222,24 +194,21 @@
222 194 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
223 195 }
224 196
225 197 // get response_code
226 - $this->response_code = wp_remote_retrieve_response_code( $this->response );
198 + $response_code = wp_remote_retrieve_response_code( $this->response );
227 199
228 200 // action to intercept call depending on response_code
229 - $this->response = apply_filters( 'wpgetapi_before_retrieve_body', $this->response, $this->response_code, $this );
201 + $this->response = apply_filters( 'wpgetapi_before_retrieve_body', $this->response, $response_code, $this );
230 202
231 203 // get body
232 204 // modified in version 1.6.1 to allow for OAuth 2.0 plugin returning body already
233 205 $data = isset( $this->response['body'] ) ? $this->response['body'] : $this->response;
234 -
206 +
235 207 // returning in JSON format
236 208 if( $this->results_format == 'json_string' || $this->results_format == 'json_decoded' )
237 209 $data = $this->return_data( $data );
238 210
239 - if( $data === 'null' )
240 - $data = 'Result is null. Check that all endpoint settings are correct.';
241 -
242 211 return apply_filters( 'wpgetapi_raw_data', $data, $this );
243 212
244 213 }
245 214
@@ -252,17 +221,10 @@
252 221 // first make sure our endpoint starts with a slash
253 222 if ( substr( $this->endpoint, 0, 1 ) != '/' )
254 223 $this->endpoint = '/' . $this->endpoint;
255 224
256 - $this->endpoint = apply_filters( 'wpgetapi_endpoint', $this->endpoint, $this );
257 -
258 225 $url = untrailingslashit( $this->base_url ) . $this->endpoint;
259 226
260 - // if we have a URL pagination event from the import plugin
261 - // we need to modify the URL here
262 - if( isset( $this->args['paginate_url'] ) )
263 - $url = $this->args['paginate_url'];
264 -
265 227 // filter our params - added for use in Oauth 2.0 plugin
266 228 $params = apply_filters( 'wpgetapi_query_parameters', $this->query_parameters, $this );
267 229
268 230 // add empty array - was getting errors if it was just null or false
@@ -267,12 +229,10 @@
267 229
268 230 // add empty array - was getting errors if it was just null or false
269 231 $params = empty( $params ) ? array(''=>'') : $params;
270 232
271 - $result = add_query_arg( $params, $url );
233 + return add_query_arg( $params, $url );
272 234
273 - return $result;
274 -
275 235 }
276 236
277 237
278 238 /**
@@ -286,54 +246,26 @@
286 246 ), $this );
287 247
288 248
289 249 // if doing POST request, include body paramters
290 - if( $this->method == 'POST' || $this->method == 'PUT' || $this->method == 'DELETE' || $this->method == 'PATCH' ) {
291 -
292 - // tokens are sent through here
250 + if( $this->method == 'POST' || $this->method == 'PUT' ) {
251 +
293 252 $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this );
294 253
295 - // do we json_encode the entire body
296 - if( $this->body_json_encode == true ) {
254 + // do we json_encode the entire body as a string
255 + if( $this->body_json_encode == true )
297 256 $this->body_parameters = json_encode( $this->body_parameters );
298 - }
299 257
300 - // do we urlencode the entire body
301 - if( $this->body_parameters && $this->body_url_encode == true ) {
302 -
303 - // checking if the parameters have a json string (raw)
304 - if (
305 - ( ! is_array( $this->body_parameters ) ) &&
306 - ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' )
307 - ) {
308 - $this->body_parameters = json_decode( $this->body_parameters, true );
258 +
259 + // do we urlencode the entire body as a string
260 + if( $this->body_url_encode == true ) {
261 + $data_raw = '';
262 + foreach ($this->body_parameters as $key => $value){
263 + $data_raw = $data_raw . $key . "=" . urlencode($value) . "&";
309 264 }
310 -
311 - $this->body_parameters = http_build_query( $this->body_parameters, '', '&' );
312 -
265 + $this->body_parameters = $data_raw;
313 266 }
314 267
315 - // do we xml the entire body
316 - if( $this->body_parameters && $this->body_xml_format == true ) {
317 -
318 - $xml = new SimpleXmlElement( '<' . $this->xml_root_node . '/>' );
319 -
320 - foreach( $this->body_parameters as $key => $value) {
321 - $xml->addChild( $key, $value );
322 - }
323 -
324 - $this->body_parameters = $xml->asXML();
325 -
326 - }
327 -
328 - // do we base64 encode the entire body
329 - if( $this->body_parameters && $this->body_base64_encode == true ) {
330 -
331 - $this->body_parameters = is_array( $this->body_parameters ) ? json_encode( $this->body_parameters ) : $this->body_parameters;
332 - $this->body_parameters = base64_encode( $this->body_parameters );
333 -
334 - }
335 -
336 268 // add our body parameters
337 269 if( $this->body_parameters && ! empty( $this->body_parameters ) )
338 270 $headers['body'] = $this->body_parameters;
339 271
@@ -338,11 +270,8 @@
338 270 $headers['body'] = $this->body_parameters;
339 271
340 272 }
341 273
342 - // get our body paramters as they are formatted
343 - $this->body_parameters = apply_filters( 'wpgetapi_final_body_parameters', $this->body_parameters, $this );
344 -
345 274 // add headers to our final request args
346 275 $this->final_request_args = wp_parse_args( $headers, $this->final_request_args );
347 276
348 277 // build the args taht are sent to the request
@@ -358,10 +287,8 @@
358 287
359 288 }
360 289
361 290
362 -
363 -
364 291 /**
365 292 * Do a GET request
366 293 */
367 294 public function GET_request() {
@@ -367,19 +294,19 @@
367 294 public function GET_request() {
368 295 $response = '';
369 296 // so we can so something before the remote_get (caching)
370 297 $response = apply_filters( 'wpgetapi_before_get_request', $response, $this );
371 -
372 298 if( empty( $response ) )
373 299 $response = wp_remote_get( $this->final_url, $this->final_request_args );
300 +
374 301 return $response;
375 302 }
376 303
304 +
377 305 /**
378 306 * Do a POST request
379 307 */
380 308 public function POST_request() {
381 - $this->final_request_args['method'] = 'POST';
382 309 $response = wp_remote_post( $this->final_url, $this->final_request_args );
383 310 return $response;
384 311 }
385 312
@@ -391,28 +318,10 @@
391 318 $response = wp_remote_request( $this->final_url, $this->final_request_args );
392 319 return $response;
393 320 }
394 321
395 - /**
396 - * Do a PATCH request
397 - */
398 - public function PATCH_request() {
399 - $this->final_request_args['method'] = 'PATCH';
400 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
401 - return $response;
402 - }
403 322
404 323 /**
405 - * Do a DELETE request
406 - */
407 - public function DELETE_request() {
408 - $this->final_request_args['method'] = 'DELETE';
409 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
410 - return $response;
411 - }
412 -
413 -
414 - /**
415 324 * return data
416 325 */
417 326 public function return_data( $data ) {
418 327
@@ -418,112 +327,22 @@
418 327
419 328 $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys );
420 329
421 330 // converts all data to arrays, removing objects
422 - if( is_string( $data ) ) {
423 - $decode = json_decode( $data, true );
424 - if( json_last_error() ) {
425 - return esc_html( $data );
426 - } else {
427 - $data = $decode;
428 - }
429 - }
430 -
331 + if( is_string( $data ) )
332 + $data = json_decode( $data, true );
333 +
431 334 $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys );
432 335
433 336 if( $this->results_format == 'json_string' )
434 - return trim( json_encode( $data, JSON_PRETTY_PRINT ),'"');
435 -
337 + return trim( json_encode( $data ),'"');
338 +
436 339 if( $this->results_format == 'json_decoded' )
437 340 return $data;
438 341
439 342 }
440 343
441 - /**
442 - * Sort out the parameters if they exist
443 - */
444 - public function do_parameters( $parameters ) {
445 344
446 - $new_array = array();
447 - $raw = '';
448 - $parameters = $this->decrypt( $parameters );
449 -
450 - if( is_array( $parameters ) ) {
451 - foreach ( $parameters as $key => $parameter ) {
452 -
453 - if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
454 -
455 - $parameter['value'] = stripslashes( $parameter['value'] );
456 -
457 - // if we have wpgetapi_on, delete it so we don't send to api
458 - if( $parameter['name'] == 'wpgetapi_on' ) {
459 - unset( $parameters[ $key ] );
460 - continue;
461 - }
462 -
463 - $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
464 -
465 - // if we are sending raw body
466 - } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
467 -
468 - $raw = stripslashes( $parameter['value'] );
469 -
470 - }
471 -
472 - }
473 - }
474 -
475 - // look for array or json string and sort these out - for using such things in shortcode
476 - if( ! empty( $new_array ) ) {
477 -
478 - foreach ( $new_array as $key => $value ) {
479 -
480 - // checking if the parameters have a json string
481 - if ( strpos( $value, '{"' ) !== false && strpos( $value, '"}' ) !== false ) {
482 - //if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
483 - $new_array[ $key ] = json_decode( $value, true );
484 - } else
485 -
486 - // checking if the parameters have an array within the string
487 - // if they do, create them as an actual array
488 - if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
489 - $value = trim( $value,"[]" );
490 - $new_array[ $key ] = array( $value );
491 - }
492 -
493 - // set value as integer
494 - if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) {
495 - preg_match("/\(([^\)]*)\)/", $value, $match );
496 - $result = $match[1];
497 - $new_array[ $key ] = absint( $result );
498 - }
499 -
500 - // set value as float
501 - if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) {
502 - preg_match("/\(([^\)]*)\)/", $value, $match );
503 - $result = $match[1];
504 - $new_array[ $key ] = (float) $result;
505 -
506 - }
507 -
508 - // set value as boolean
509 - if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) {
510 - preg_match("/\(([^\)]*)\)/", $value, $match );
511 - $result = $match[1];
512 - $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN );
513 - $new_array[ $key ] = $result;
514 -
515 - }
516 -
517 - }
518 -
519 - }
520 -
521 - return $raw ? $raw : $new_array;
522 -
523 - }
524 -
525 -
526 345 /**
527 346 * decrypt our parameters from the DB
528 347 */
529 348 public function decrypt( $array_or_string ) {
@@ -558,69 +377,10 @@
558 377 ) {
559 378
560 379 $this->debug = true;
561 380
562 - // admin test endpoint button
563 381 $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false;
564 382
565 - // get api status from response code
566 - $status = array(
567 - 'title' => 'Error in API response.',
568 - 'desc' => 'Check all details within your endpoint. Something is misconfigured.',
569 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
570 - );
571 -
572 - if( $this->response_code == 200 ) {
573 - $status = array(
574 - 'title' => 'Success!',
575 - 'desc' => 'Your API is returning a success message and is returning the data as shown in the Data Output section below. You can modify this by changing the Results Format option or see <a href="https://wpgetapi.com/docs/format-api-data-as-html/">here</a> for info on formatting this data.',
576 - 'type' => '<span class="dashicons dashicons-yes-alt"></span>'
577 - );
578 - }
579 - if( $this->response_code == 400 || $this->response_code == 404 ) {
580 - $status = array(
581 - 'title' => 'Bad Request',
582 - 'desc' => 'This could indicate that the URL you are calling is incorrect or that some other data is missing or incorrect. Please check your Base URL and Endpoint are correct as well as the Request Method.',
583 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
584 - );
585 - }
586 - if( $this->response_code == 401 ) {
587 - $status = array(
588 - 'title' => 'Unauthorised',
589 - 'desc' => 'You are successfully connecting to your API. But your API key, login or API credentials are incorrect. See <a href="https://wpgetapi.com/docs/authentication-authorization/">here</a> for info on correctly authorizing your API requests.',
590 - 'type' => '<span class="dashicons dashicons-warning"></span>'
591 - );
592 - }
593 - if( $this->response_code == 403 ) {
594 - $status = array(
595 - 'title' => 'Forbidden',
596 - 'desc' => 'This could indicate that you may need to get your IP address whitelisted with your API provider or that you do not have access to this API.',
597 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
598 - );
599 - }
600 - if( $this->response_code == 405 ) {
601 - $status = array(
602 - 'title' => 'Method Not Allowed',
603 - 'desc' => 'Try changing the Request Method within the endpoint settings.',
604 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
605 - );
606 - }
607 - if( $this->response_code == 415 ) {
608 - $status = array(
609 - 'title' => 'Unsupported Media Type',
610 - 'desc' => 'Try adding "Content-type" to the Headers with the Value of "json/application" as shown <a href="https://wpgetapi.com/docs/troubleshooting/">here</a>.',
611 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
612 - );
613 - }
614 - if( $this->response_code == 500 ) {
615 - $status = array(
616 - 'title' => 'Internal Server Error',
617 - 'desc' => 'This indicates an issue with the server. Contact your API provider.',
618 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
619 - );
620 - }
621 -
622 -
623 383 ob_start(); ?>
624 384
625 385 <style>
626 386
@@ -657,10 +417,10 @@
657 417 background: #fff;
658 418 padding: 15px 20px;
659 419 display: inline-block !important;
660 420 width: 100% !important;
661 - box-shadow: 0 3px 8px rgb(0 0 0 / 6%);
662 - border: 1px solid #eee;
421 + box-shadow: 3px 3px 0 rgb(0 0 0 / 8%);
422 + border: 1px solid #efefef;
663 423 }
664 424 .wpgetapi-debug .debug-item h6 {
665 425 font-weight: bold;
666 426 font-size: 14px;
@@ -672,14 +432,15 @@
672 432 font-family: monospace !important;
673 433 font-size: 13px !important;
674 434 margin: 0 !important;
675 435 padding: 8px 12px;
676 - background: #f4f7f9;
436 + background: #f8f8f8;
677 437 }
678 438 .wpgetapi-debug .debug-item .debug-result pre {
679 439 border: none;
680 440 padding: 5px
681 441 }
442 +
682 443 .wpgetapi-debug.testing {
683 444 background: transparent;
684 445 padding: 0;
685 446 box-shadow: none;
@@ -686,72 +447,16 @@
686 447 }
687 448 .wpgetapi-debug.testing .debug-item {
688 449 margin: 5px 0;
689 450 }
690 -.wpgetapi-debug.testing .debug-item.status {
691 - border: none;
692 - box-shadow: none;
693 - margin-bottom: 15px;
694 -}
695 -.wpgetapi-debug .debug-item.status h5 {
696 - font-size: 15px;
697 -}
698 -.wpgetapi-debug .status .dashicons {
699 - margin: 0 5px 3px 0;
700 -}
701 -.wpgetapi-debug .status .dashicons-yes-alt {
702 - color: #5e9929;
703 -}
704 -.wpgetapi-debug .status .dashicons-dismiss {
705 - color: #cc4646;
706 -}
707 -.wpgetapi-debug .status .dashicons-warning {
708 - color: #dfa12e;
709 -}
710 -.wpgetapi-debug .status .desc {
711 - font-size: 14px;
712 - font-weight: 400 !important;
713 -}
714 451 </style>
715 452
716 453 <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>">
717 454
718 - <?php if( $testing ) { ?>
719 -
720 - <div class="debug-item status">
721 - <div class="">
722 - <h5><?php _e( $status['type'] ); ?> <?php esc_html_e( $status['title'] ); ?></h5>
723 - <span class="desc"><?php _e( $status['desc'] ); ?></span>
724 - </div>
725 - </div>
726 - <div class="debug-item">
727 - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
728 - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
729 - <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
730 - </div>
731 -
732 - <div class="debug-item">
733 - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
734 - <p class="small"><?php esc_html_e( 'The output that has been returned from the API. This is what the shortcode or template tag will display and can be formatted however you like.', 'wpgetapi' ); ?></p>
735 - <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
736 - </div>
737 -
738 - <div class="debug-item">
739 - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
740 - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
741 - <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
742 - </div>
743 -
744 - <div class="debug-item">
745 - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
746 - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
747 - <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
748 - </div>
749 -
750 - <?php } else { ?>
751 -
752 - <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
455 + <?php if( ! $testing ) { ?>
456 + <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
753 457 <p class="small"><?php esc_html_e( 'Below you will find debug info for the current API call. To turn this off, set debug to false in your shortcode or template tag.', 'wpgetapi' ); ?><br><?php esc_html_e( 'Connecting to API\'s can be tricky - if you require help, please see the', 'wpgetapi' ); ?> <a target="_blank" href="https://wpgetapi.com/docs/"><?php esc_html_e( 'Documentation', 'wpgetapi' ); ?></a>.</p>
458 + <?php } ?>
754 459
755 460 <div class="debug-item">
756 461 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
757 462 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
@@ -798,10 +503,8 @@
798 503 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
799 504 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
800 505 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
801 506 </div>
802 -
803 - <?php } ?>
804 507
805 508 </div>
806 509
807 510 <?php