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 +72 -363 1.9.91.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,30 +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 107 }
150 -
151 108 }
152 109
153 110 $this->timeout = isset( $this->api['timeout'] ) && ! empty( $this->api['timeout'] ) ? $this->api['timeout'] : $this->timeout;
154 111 $this->sslverify = isset( $this->api['sslverify'] ) ? absint( $this->api['sslverify'] ) : $this->sslverify;
@@ -161,21 +118,58 @@
161 118 *
162 119 * @param string $field Field to retrieve
163 120 */
164 121 public function endpoint_output() {
122 + return $this->do_the_call();
123 + }
165 124
166 - do_action( 'wpgetapi_before_do_the_call', $this );
167 125
168 - 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);
169 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 +
170 165 }
171 166
172 -
173 167 /**
174 168 * Send the request and return our data
175 169 */
176 170 public function do_the_call() {
177 -
171 +
178 172 $this->init();
179 173
180 174 // build the URL
181 175 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
@@ -181,18 +175,9 @@
181 175 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
182 176
183 177 // build the request args
184 178 $this->final_request_args = apply_filters( 'wpgetapi_final_request_args', $this->build_request_args(), $this );
185 -
186 - /**
187 - * Check if we should stop or not. Setting $on to true, will stop us calling the api.
188 - * @param bool $on Whether on is set or not.
189 - */
190 179
191 - if ( apply_filters( 'wpgetapi_should_we_stop', false, $this ) ) {
192 - return;
193 - }
194 -
195 180 // POST request
196 181 if( $this->method == 'POST' )
197 182 $this->response = $this->POST_request();
198 183
@@ -199,20 +184,12 @@
199 184 // PUT request
200 185 if( $this->method == 'PUT' )
201 186 $this->response = $this->PUT_request();
202 187
203 - // PATCH request
204 - if( $this->method == 'PATCH' )
205 - $this->response = $this->PATCH_request();
206 -
207 188 // GET request
208 189 if( $this->method == 'GET' )
209 190 $this->response = $this->GET_request();
210 191
211 - // DELETE request
212 - if( $this->method == 'DELETE' )
213 - $this->response = $this->DELETE_request();
214 -
215 192 // wp error
216 193 if( is_wp_error( $this->response ) ) {
217 194 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
218 195 }
@@ -217,24 +194,21 @@
217 194 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
218 195 }
219 196
220 197 // get response_code
221 - $this->response_code = wp_remote_retrieve_response_code( $this->response );
198 + $response_code = wp_remote_retrieve_response_code( $this->response );
222 199
223 200 // action to intercept call depending on response_code
224 - $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 );
225 202
226 203 // get body
227 204 // modified in version 1.6.1 to allow for OAuth 2.0 plugin returning body already
228 205 $data = isset( $this->response['body'] ) ? $this->response['body'] : $this->response;
229 -
206 +
230 207 // returning in JSON format
231 208 if( $this->results_format == 'json_string' || $this->results_format == 'json_decoded' )
232 209 $data = $this->return_data( $data );
233 210
234 - if( $data === 'null' )
235 - $data = 'Result is null. Check that all endpoint settings are correct.';
236 -
237 211 return apply_filters( 'wpgetapi_raw_data', $data, $this );
238 212
239 213 }
240 214
@@ -247,17 +221,10 @@
247 221 // first make sure our endpoint starts with a slash
248 222 if ( substr( $this->endpoint, 0, 1 ) != '/' )
249 223 $this->endpoint = '/' . $this->endpoint;
250 224
251 - $this->endpoint = apply_filters( 'wpgetapi_endpoint', $this->endpoint, $this );
252 -
253 225 $url = untrailingslashit( $this->base_url ) . $this->endpoint;
254 226
255 - // if we have a URL pagination event from the import plugin
256 - // we need to modify the URL here
257 - if( isset( $this->args['paginate_url'] ) )
258 - $url = $this->args['paginate_url'];
259 -
260 227 // filter our params - added for use in Oauth 2.0 plugin
261 228 $params = apply_filters( 'wpgetapi_query_parameters', $this->query_parameters, $this );
262 229
263 230 // add empty array - was getting errors if it was just null or false
@@ -262,12 +229,10 @@
262 229
263 230 // add empty array - was getting errors if it was just null or false
264 231 $params = empty( $params ) ? array(''=>'') : $params;
265 232
266 - $result = add_query_arg( $params, $url );
233 + return add_query_arg( $params, $url );
267 234
268 - return $result;
269 -
270 235 }
271 236
272 237
273 238 /**
@@ -281,54 +246,26 @@
281 246 ), $this );
282 247
283 248
284 249 // if doing POST request, include body paramters
285 - if( $this->method == 'POST' || $this->method == 'PUT' || $this->method == 'DELETE' || $this->method == 'PATCH' ) {
286 -
287 - // tokens are sent through here
250 + if( $this->method == 'POST' || $this->method == 'PUT' ) {
251 +
288 252 $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this );
289 253
290 - // do we json_encode the entire body
291 - if( $this->body_json_encode == true ) {
254 + // do we json_encode the entire body as a string
255 + if( $this->body_json_encode == true )
292 256 $this->body_parameters = json_encode( $this->body_parameters );
293 - }
294 257
295 - // do we urlencode the entire body
296 - if( $this->body_parameters && $this->body_url_encode == true ) {
297 -
298 - // checking if the parameters have a json string (raw)
299 - if (
300 - ( ! is_array( $this->body_parameters ) ) &&
301 - ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' )
302 - ) {
303 - $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) . "&";
304 264 }
305 -
306 - $this->body_parameters = http_build_query( $this->body_parameters, '', '&' );
307 -
265 + $this->body_parameters = $data_raw;
308 266 }
309 267
310 - // do we xml the entire body
311 - if( $this->body_parameters && $this->body_xml_format == true ) {
312 -
313 - $xml = new SimpleXmlElement( '<' . $this->xml_root_node . '/>' );
314 -
315 - foreach( $this->body_parameters as $key => $value) {
316 - $xml->addChild( $key, $value );
317 - }
318 -
319 - $this->body_parameters = $xml->asXML();
320 -
321 - }
322 -
323 - // do we base64 encode the entire body
324 - if( $this->body_parameters && $this->body_base64_encode == true ) {
325 -
326 - $this->body_parameters = is_array( $this->body_parameters ) ? json_encode( $this->body_parameters ) : $this->body_parameters;
327 - $this->body_parameters = base64_encode( $this->body_parameters );
328 -
329 - }
330 -
331 268 // add our body parameters
332 269 if( $this->body_parameters && ! empty( $this->body_parameters ) )
333 270 $headers['body'] = $this->body_parameters;
334 271
@@ -336,10 +273,8 @@
336 273
337 274 // add headers to our final request args
338 275 $this->final_request_args = wp_parse_args( $headers, $this->final_request_args );
339 276
340 - update_option( 'z_action_woo_args', $this->final_request_args );
341 -
342 277 // build the args taht are sent to the request
343 278 $default_args = apply_filters( 'wpgetapi_default_request_args_parameters', array(
344 279 'timeout' => $this->timeout,
345 280 'sslverify' => $this->sslverify,
@@ -352,10 +287,8 @@
352 287
353 288 }
354 289
355 290
356 -
357 -
358 291 /**
359 292 * Do a GET request
360 293 */
361 294 public function GET_request() {
@@ -361,19 +294,19 @@
361 294 public function GET_request() {
362 295 $response = '';
363 296 // so we can so something before the remote_get (caching)
364 297 $response = apply_filters( 'wpgetapi_before_get_request', $response, $this );
365 -
366 298 if( empty( $response ) )
367 299 $response = wp_remote_get( $this->final_url, $this->final_request_args );
300 +
368 301 return $response;
369 302 }
370 303
304 +
371 305 /**
372 306 * Do a POST request
373 307 */
374 308 public function POST_request() {
375 - $this->final_request_args['method'] = 'POST';
376 309 $response = wp_remote_post( $this->final_url, $this->final_request_args );
377 310 return $response;
378 311 }
379 312
@@ -385,139 +318,31 @@
385 318 $response = wp_remote_request( $this->final_url, $this->final_request_args );
386 319 return $response;
387 320 }
388 321
389 - /**
390 - * Do a PATCH request
391 - */
392 - public function PATCH_request() {
393 - $this->final_request_args['method'] = 'PATCH';
394 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
395 - return $response;
396 - }
397 322
398 323 /**
399 - * Do a DELETE request
400 - */
401 - public function DELETE_request() {
402 - $this->final_request_args['method'] = 'DELETE';
403 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
404 - return $response;
405 - }
406 -
407 -
408 - /**
409 324 * return data
410 325 */
411 326 public function return_data( $data ) {
412 327
413 328 $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys );
414 -
329 +
415 330 // converts all data to arrays, removing objects
416 - if( is_string( $data ) ) {
417 - $decode = json_decode( $data, true );
418 - if( json_last_error() ) {
419 - return esc_html( $data );
420 - } else {
421 - $data = $decode;
422 - }
423 - }
331 + if( is_string( $data ) )
332 + $data = json_decode( $data, true );
424 333
425 334 $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys );
426 335
427 336 if( $this->results_format == 'json_string' )
428 337 return trim( json_encode( $data ),'"');
429 -
338 +
430 339 if( $this->results_format == 'json_decoded' )
431 340 return $data;
432 341
433 342 }
434 343
435 - /**
436 - * Sort out the parameters if they exist
437 - */
438 - public function do_parameters( $parameters ) {
439 -
440 - $new_array = array();
441 - $raw = '';
442 - $parameters = $this->decrypt( $parameters );
443 344
444 - if( is_array( $parameters ) ) {
445 - foreach ( $parameters as $key => $parameter ) {
446 -
447 - if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
448 -
449 - $parameter['value'] = stripslashes( $parameter['value'] );
450 -
451 - // if we have wpgetapi_on, delete it so we don't send to api
452 - if( $parameter['name'] == 'wpgetapi_on' ) {
453 - unset( $parameters[ $key ] );
454 - continue;
455 - }
456 -
457 - $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
458 -
459 - // if we are sending raw body
460 - } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
461 -
462 - $raw = stripslashes( $parameter['value'] );
463 -
464 - }
465 -
466 - }
467 - }
468 -
469 - // look for array or json string and sort these out - for using such things in shortcode
470 - if( ! empty( $new_array ) ) {
471 -
472 - foreach ( $new_array as $key => $value ) {
473 -
474 - // checking if the parameters have a json string
475 - if ( strpos( $value, '{' ) !== false && strpos( $value, '}' ) !== false ) {
476 - //if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
477 - $new_array[ $key ] = json_decode( $value, true );
478 - } else
479 -
480 - // checking if the parameters have an array within the string
481 - // if they do, create them as an actual array
482 - if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
483 - $value = trim( $value,"[]" );
484 - $new_array[ $key ] = array( $value );
485 - }
486 -
487 - // set value as integer
488 - if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) {
489 - preg_match("/\(([^\)]*)\)/", $value, $match );
490 - $result = $match[1];
491 - $new_array[ $key ] = absint( $result );
492 - }
493 -
494 - // set value as float
495 - if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) {
496 - preg_match("/\(([^\)]*)\)/", $value, $match );
497 - $result = $match[1];
498 - $new_array[ $key ] = (float) $result;
499 -
500 - }
501 -
502 - // set value as boolean
503 - if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) {
504 - preg_match("/\(([^\)]*)\)/", $value, $match );
505 - $result = $match[1];
506 - $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN );
507 - $new_array[ $key ] = $result;
508 -
509 - }
510 -
511 - }
512 -
513 - }
514 -
515 - return $raw ? $raw : $new_array;
516 -
517 - }
518 -
519 -
520 345 /**
521 346 * decrypt our parameters from the DB
522 347 */
523 348 public function decrypt( $array_or_string ) {
@@ -552,69 +377,10 @@
552 377 ) {
553 378
554 379 $this->debug = true;
555 380
556 - // admin test endpoint button
557 381 $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false;
558 382
559 - // get api status from response code
560 - $status = array(
561 - 'title' => 'Error in API response.',
562 - 'desc' => 'Check all details within your endpoint. Something is misconfigured.',
563 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
564 - );
565 -
566 - if( $this->response_code == 200 ) {
567 - $status = array(
568 - 'title' => 'Success!',
569 - '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.',
570 - 'type' => '<span class="dashicons dashicons-yes-alt"></span>'
571 - );
572 - }
573 - if( $this->response_code == 400 || $this->response_code == 404 ) {
574 - $status = array(
575 - 'title' => 'Bad Request',
576 - '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.',
577 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
578 - );
579 - }
580 - if( $this->response_code == 401 ) {
581 - $status = array(
582 - 'title' => 'Unauthorised',
583 - '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.',
584 - 'type' => '<span class="dashicons dashicons-warning"></span>'
585 - );
586 - }
587 - if( $this->response_code == 403 ) {
588 - $status = array(
589 - 'title' => 'Forbidden',
590 - '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.',
591 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
592 - );
593 - }
594 - if( $this->response_code == 405 ) {
595 - $status = array(
596 - 'title' => 'Method Not Allowed',
597 - 'desc' => 'Try changing the Request Method within the endpoint settings.',
598 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
599 - );
600 - }
601 - if( $this->response_code == 415 ) {
602 - $status = array(
603 - 'title' => 'Unsupported Media Type',
604 - '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>.',
605 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
606 - );
607 - }
608 - if( $this->response_code == 500 ) {
609 - $status = array(
610 - 'title' => 'Internal Server Error',
611 - 'desc' => 'This indicates an issue with the server. Contact your API provider.',
612 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
613 - );
614 - }
615 -
616 -
617 383 ob_start(); ?>
618 384
619 385 <style>
620 386
@@ -651,10 +417,10 @@
651 417 background: #fff;
652 418 padding: 15px 20px;
653 419 display: inline-block !important;
654 420 width: 100% !important;
655 - box-shadow: 0 3px 8px rgb(0 0 0 / 6%);
656 - border: 1px solid #eee;
421 + box-shadow: 3px 3px 0 rgb(0 0 0 / 8%);
422 + border: 1px solid #efefef;
657 423 }
658 424 .wpgetapi-debug .debug-item h6 {
659 425 font-weight: bold;
660 426 font-size: 14px;
@@ -666,14 +432,15 @@
666 432 font-family: monospace !important;
667 433 font-size: 13px !important;
668 434 margin: 0 !important;
669 435 padding: 8px 12px;
670 - background: #f4f7f9;
436 + background: #f8f8f8;
671 437 }
672 438 .wpgetapi-debug .debug-item .debug-result pre {
673 439 border: none;
674 440 padding: 5px
675 441 }
442 +
676 443 .wpgetapi-debug.testing {
677 444 background: transparent;
678 445 padding: 0;
679 446 box-shadow: none;
@@ -680,72 +447,16 @@
680 447 }
681 448 .wpgetapi-debug.testing .debug-item {
682 449 margin: 5px 0;
683 450 }
684 -.wpgetapi-debug.testing .debug-item.status {
685 - border: none;
686 - box-shadow: none;
687 - margin-bottom: 15px;
688 -}
689 -.wpgetapi-debug .debug-item.status h5 {
690 - font-size: 15px;
691 -}
692 -.wpgetapi-debug .status .dashicons {
693 - margin: 0 5px 3px 0;
694 -}
695 -.wpgetapi-debug .status .dashicons-yes-alt {
696 - color: #5e9929;
697 -}
698 -.wpgetapi-debug .status .dashicons-dismiss {
699 - color: #cc4646;
700 -}
701 -.wpgetapi-debug .status .dashicons-warning {
702 - color: #dfa12e;
703 -}
704 -.wpgetapi-debug .status .desc {
705 - font-size: 14px;
706 - font-weight: 400 !important;
707 -}
708 451 </style>
709 452
710 453 <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>">
711 454
712 - <?php if( $testing ) { ?>
713 -
714 - <div class="debug-item status">
715 - <div class="">
716 - <h5><?php _e( $status['type'] ); ?> <?php esc_html_e( $status['title'] ); ?></h5>
717 - <span class="desc"><?php _e( $status['desc'] ); ?></span>
718 - </div>
719 - </div>
720 - <div class="debug-item">
721 - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
722 - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
723 - <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
724 - </div>
725 -
726 - <div class="debug-item">
727 - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
728 - <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>
729 - <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
730 - </div>
731 -
732 - <div class="debug-item">
733 - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
734 - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
735 - <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
736 - </div>
737 -
738 - <div class="debug-item">
739 - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
740 - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
741 - <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
742 - </div>
743 -
744 - <?php } else { ?>
745 -
746 - <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>
747 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 } ?>
748 459
749 460 <div class="debug-item">
750 461 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
751 462 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
@@ -792,10 +503,8 @@
792 503 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
793 504 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
794 505 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
795 506 </div>
796 -
797 - <?php } ?>
798 507
799 508 </div>
800 509
801 510 <?php