PluginProbe
WPGet API – Connect to any external REST API / 1.4.6
WPGet API – Connect to any external REST API v1.4.6
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 +100 -423 1.9.61.4.6 View file →
@@ -28,10 +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_xml_format = ''; // xml format body
33 - public $xml_root_node = 'root'; // root node for xml
34 32
35 33 public $response = ''; // the returned response
36 34
37 35 public $final_url = ''; // final URL
@@ -36,15 +34,12 @@
36 34
37 35 public $final_url = ''; // final URL
38 36 public $final_request_args = array(); // final request_args
39 37
40 - public $results_format = 'json_string'; // results format
38 + public $results_format = 'json_string'; // reseults format
41 39
42 - public $response_code = ''; // the response code from the call
43 -
44 40 public $timeout = 10; // the timeout
45 41 public $sslverify = 1; // the paramaters
46 - public $debug = false;
47 42
48 43
49 44 /**
50 45 * Main constructor
@@ -62,9 +57,9 @@
62 57 $this->endpoint_id = sanitize_text_field( $endpoint_id );
63 58 $this->keys = $keys;
64 59 $this->args = $args;
65 60
66 - add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 99, 2 );
61 + add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 5, 2 );
67 62
68 63 }
69 64
70 65
@@ -72,29 +67,8 @@
72 67 * Init our api data
73 68 */
74 69 public function init() {
75 70
76 - // if we are doing importer plugin,
77 - // we need to intercept and modify most of our methods values
78 - if( $this->api_id == 'wpgetapi_importer' ) {
79 -
80 - $data = apply_filters( 'wpgetapi_api_importer_init', $this );
81 -
82 - if( $data ) {
83 -
84 - foreach ($data as $key => $value) {
85 - $this->{$key} = $value;
86 - }
87 -
88 - $this->query_parameters = ! empty( $this->query_parameters ) ? $this->do_parameters( $this->query_parameters ) : array();
89 - $this->header_parameters = ! empty( $this->header_parameters ) ? $this->do_parameters( $this->header_parameters ) : array();
90 - $this->body_parameters = ! empty( $this->body_parameters ) ? $this->do_parameters( $this->body_parameters ) : array();
91 - return;
92 -
93 - }
94 -
95 - }
96 -
97 71 // do some checks
98 72 if( empty( $this->setup ) || ! isset( $this->setup['apis'] ) || empty( $this->setup['apis'] ) )
99 73 return 'No API found.';
100 74
@@ -113,9 +87,9 @@
113 87 // loop through endpoints
114 88 foreach ( $this->api['endpoints'] as $index => $endpoint ) {
115 89
116 90 if( $this->endpoint_id == $endpoint['id'] ) {
117 -
91 +
118 92 $this->method = isset( $endpoint['method'] ) && $endpoint['method'] != '' ? sanitize_text_field( $endpoint['method'] ) : 'GET';
119 93 $this->cache_time = isset( $endpoint['cache_time'] ) && ! empty( $endpoint['cache_time'] ) ? absint( $endpoint['cache_time'] ) : '';
120 94 $this->endpoint = isset( $endpoint['endpoint'] ) && ! empty( $endpoint['endpoint'] ) ? sanitize_text_field( $endpoint['endpoint'] ) : '';
121 95
@@ -124,29 +98,13 @@
124 98 $this->header_parameters = isset( $endpoint['header_parameters'] ) && ! empty( $endpoint['header_parameters'] ) ? $this->do_parameters( $endpoint['header_parameters'] ) : array();
125 99
126 100 $this->body_parameters = isset( $endpoint['body_parameters'] ) && ! empty( $endpoint['body_parameters'] ) ? $this->do_parameters( $endpoint['body_parameters'] ) : array();
127 101
128 - // how to encode the body
129 102 $this->body_json_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'true' ? true : false;
130 103 $this->body_url_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'url' ? true : false;
131 - $this->body_xml_format = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'xml' ? true : false;
132 104
133 - $this->xml_root_node = isset( $endpoint['xml_root'] ) && ! empty( $endpoint['xml_root'] ) ? $endpoint['xml_root'] : $this->xml_root_node;
134 -
135 105 $this->results_format = isset( $endpoint['results_format'] ) ? sanitize_text_field( $endpoint['results_format'] ) : $this->results_format;
136 -
137 -
138 - if(
139 - // set the format to php array data if html format is set
140 - ( isset( $this->args['format'] ) && $this->args['format'] == 'html' && $this->results_format != 'xml_array' ) ||
141 - // set the format to php array data if it is set in the args (coming from the importer)
142 - ( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_decoded' )
143 - ) {
144 - $this->results_format = 'json_decoded';
145 - }
146 -
147 106 }
148 -
149 107 }
150 108
151 109 $this->timeout = isset( $this->api['timeout'] ) && ! empty( $this->api['timeout'] ) ? $this->api['timeout'] : $this->timeout;
152 110 $this->sslverify = isset( $this->api['sslverify'] ) ? absint( $this->api['sslverify'] ) : $this->sslverify;
@@ -159,21 +117,58 @@
159 117 *
160 118 * @param string $field Field to retrieve
161 119 */
162 120 public function endpoint_output() {
121 + return $this->do_the_call();
122 + }
163 123
164 - do_action( 'wpgetapi_before_do_the_call', $this );
165 124
166 - return $this->do_the_call();
125 + /**
126 + * Sort out the parameters if they exist
127 + */
128 + public function do_parameters( $parameters ) {
129 +
130 + $new_array = array();
131 + $parameters = $this->decrypt($parameters);
167 132
133 + if( is_array( $parameters ) ) {
134 + foreach ( $parameters as $key => $parameter ) {
135 + if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
136 + $parameter['value'] = stripslashes( $parameter['value'] );
137 + $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
138 + }
139 + }
140 + }
141 +
142 + // look for array or json string and sort these out - for using such things in shortcode
143 + if( is_array( $new_array ) ) {
144 +
145 + foreach ( $new_array as $key => $value ) {
146 +
147 + // checking if the parameters have a json string
148 + if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
149 + $new_array[ $key ] = json_decode( $value, true);
150 + }
151 +
152 + // checking if the parameters have an array within the string
153 + // if they do, create them as an actual array
154 + if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
155 + $new_array[ $key ] = array( $value );
156 + }
157 +
158 + }
159 +
160 + }
161 +
162 + return $new_array;
163 +
168 164 }
169 165
170 -
171 166 /**
172 167 * Send the request and return our data
173 168 */
174 169 public function do_the_call() {
175 -
170 +
176 171 $this->init();
177 172
178 173 // build the URL
179 174 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
@@ -179,60 +174,28 @@
179 174 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
180 175
181 176 // build the request args
182 177 $this->final_request_args = apply_filters( 'wpgetapi_final_request_args', $this->build_request_args(), $this );
183 -
184 - /**
185 - * Check if we should stop or not. Setting $on to true, will stop us calling the api.
186 - * @param bool $on Whether on is set or not.
187 - */
188 178
189 - if ( apply_filters( 'wpgetapi_should_we_stop', false, $this ) ) {
190 - return;
191 - }
192 -
193 179 // POST request
194 180 if( $this->method == 'POST' )
195 181 $this->response = $this->POST_request();
196 182
197 - // PUT request
198 - if( $this->method == 'PUT' )
199 - $this->response = $this->PUT_request();
200 -
201 - // PATCH request
202 - if( $this->method == 'PATCH' )
203 - $this->response = $this->PATCH_request();
204 -
205 183 // GET request
206 184 if( $this->method == 'GET' )
207 185 $this->response = $this->GET_request();
208 186
209 - // DELETE request
210 - if( $this->method == 'DELETE' )
211 - $this->response = $this->DELETE_request();
212 -
213 187 // wp error
214 188 if( is_wp_error( $this->response ) ) {
215 189 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
216 190 }
217 191
218 - // get response_code
219 - $this->response_code = wp_remote_retrieve_response_code( $this->response );
192 + $data = wp_remote_retrieve_body( $this->response );
220 193
221 - // action to intercept call depending on response_code
222 - $this->response = apply_filters( 'wpgetapi_before_retrieve_body', $this->response, $this->response_code, $this );
223 -
224 - // get body
225 - // modified in version 1.6.1 to allow for OAuth 2.0 plugin returning body already
226 - $data = isset( $this->response['body'] ) ? $this->response['body'] : $this->response;
227 -
228 194 // returning in JSON format
229 195 if( $this->results_format == 'json_string' || $this->results_format == 'json_decoded' )
230 196 $data = $this->return_data( $data );
231 197
232 - if( $data === 'null' )
233 - $data = 'Result is null. Check that all endpoint settings are correct.';
234 -
235 198 return apply_filters( 'wpgetapi_raw_data', $data, $this );
236 199
237 200 }
238 201
@@ -245,24 +208,14 @@
245 208 // first make sure our endpoint starts with a slash
246 209 if ( substr( $this->endpoint, 0, 1 ) != '/' )
247 210 $this->endpoint = '/' . $this->endpoint;
248 211
249 - $this->endpoint = apply_filters( 'wpgetapi_endpoint', $this->endpoint, $this );
250 -
251 212 $url = untrailingslashit( $this->base_url ) . $this->endpoint;
252 213
253 - // if we have a URL pagination event from the import plugin
254 - // we need to modify the URL here
255 - if( isset( $this->args['paginate_url'] ) )
256 - $url = $this->args['paginate_url'];
257 -
258 - // filter our params - added for use in Oauth 2.0 plugin
259 - $params = apply_filters( 'wpgetapi_query_parameters', $this->query_parameters, $this );
260 -
261 214 // add empty array - was getting errors if it was just null or false
262 - $params = empty( $params ) ? array(''=>'') : $params;
215 + $params = empty( $this->query_parameters ) ? array(''=>'') : $this->query_parameters;
263 216
264 - return htmlentities( add_query_arg( $params, $url ) );
217 + return add_query_arg( $params, $url );
265 218
266 219 }
267 220
268 221
@@ -277,51 +230,32 @@
277 230 ), $this );
278 231
279 232
280 233 // if doing POST request, include body paramters
281 - //if( $this->method == 'POST' || $this->method == 'PUT' || $this->method == 'DELETE' ) {
282 -
283 - // tokens are sent through here
234 + if( $this->method == 'POST' ) {
235 +
284 236 $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this );
285 237
286 - // do we json_encode the entire body
287 - if( $this->body_json_encode == true ) {
238 + // do we json_encode the entire body as a string
239 + if( $this->body_json_encode == true )
288 240 $this->body_parameters = json_encode( $this->body_parameters );
289 - }
290 241
291 - // do we urlencode the entire body
292 - if( $this->body_parameters && $this->body_url_encode == true ) {
293 -
294 - // checking if the parameters have a json string (raw)
295 - if (
296 - ( ! is_array( $this->body_parameters ) ) &&
297 - ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' )
298 - ) {
299 - $this->body_parameters = json_decode( $this->body_parameters, true );
242 +
243 + // do we urlencode the entire body as a string
244 + if( $this->body_url_encode == true ) {
245 + $data_raw = '';
246 + foreach ($this->body_parameters as $key => $value){
247 + $data_raw = $data_raw . $key . "=" . urlencode($value) . "&";
300 248 }
249 + $this->body_parameters = $data_raw;
301 250
302 - $this->body_parameters = http_build_query( $this->body_parameters, '', '&' );
303 -
304 251 }
305 252
306 - // do we xml the entire body
307 - if( $this->body_parameters && $this->body_xml_format == true ) {
308 -
309 - $xml = new SimpleXmlElement( '<' . $this->xml_root_node . '/>' );
310 -
311 - foreach( $this->body_parameters as $key => $value) {
312 - $xml->addChild( $key, $value );
313 - }
314 -
315 - $this->body_parameters = $xml->asXML();
316 -
317 - }
318 -
319 253 // add our body parameters
320 254 if( $this->body_parameters && ! empty( $this->body_parameters ) )
321 255 $headers['body'] = $this->body_parameters;
322 256
323 - //}
257 + }
324 258
325 259 // add headers to our final request args
326 260 $this->final_request_args = wp_parse_args( $headers, $this->final_request_args );
327 261
@@ -338,10 +272,8 @@
338 272
339 273 }
340 274
341 275
342 -
343 -
344 276 /**
345 277 * Do a GET request
346 278 */
347 279 public function GET_request() {
@@ -347,163 +279,42 @@
347 279 public function GET_request() {
348 280 $response = '';
349 281 // so we can so something before the remote_get (caching)
350 282 $response = apply_filters( 'wpgetapi_before_get_request', $response, $this );
351 -
352 283 if( empty( $response ) )
353 284 $response = wp_remote_get( $this->final_url, $this->final_request_args );
285 +
354 286 return $response;
355 287 }
356 288
289 +
357 290 /**
358 291 * Do a POST request
359 292 */
360 293 public function POST_request() {
361 - $this->final_request_args['method'] = 'POST';
362 294 $response = wp_remote_post( $this->final_url, $this->final_request_args );
363 295 return $response;
364 296 }
365 297
366 - /**
367 - * Do a PUT request
368 - */
369 - public function PUT_request() {
370 - $this->final_request_args['method'] = 'PUT';
371 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
372 - return $response;
373 - }
374 298
375 299 /**
376 - * Do a PATCH request
377 - */
378 - public function PATCH_request() {
379 - $this->final_request_args['method'] = 'PATCH';
380 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
381 - return $response;
382 - }
383 -
384 - /**
385 - * Do a DELETE request
386 - */
387 - public function DELETE_request() {
388 - $this->final_request_args['method'] = 'DELETE';
389 - $response = wp_remote_request( $this->final_url, $this->final_request_args );
390 - return $response;
391 - }
392 -
393 -
394 - /**
395 300 * return data
396 301 */
397 302 public function return_data( $data ) {
398 -
399 - $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys );
400 303
401 304 // converts all data to arrays, removing objects
402 - if( is_string( $data ) ) {
403 - $decode = json_decode( $data, true );
404 - if( json_last_error() ) {
405 - return esc_html( $data );
406 - } else {
407 - $data = $decode;
408 - }
409 - }
410 -
305 + $data = json_decode( $data, true );
411 306 $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys );
412 -
307 +
413 308 if( $this->results_format == 'json_string' )
414 309 return trim( json_encode( $data ),'"');
415 -
310 +
416 311 if( $this->results_format == 'json_decoded' )
417 312 return $data;
418 313
419 314 }
420 315
421 - /**
422 - * Sort out the parameters if they exist
423 - */
424 - public function do_parameters( $parameters ) {
425 -
426 - $new_array = array();
427 - $raw = '';
428 - $parameters = $this->decrypt( $parameters );
429 316
430 - if( is_array( $parameters ) ) {
431 - foreach ( $parameters as $key => $parameter ) {
432 -
433 - if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
434 -
435 - $parameter['value'] = stripslashes( $parameter['value'] );
436 -
437 - // if we have wpgetapi_on, delete it so we don't send to api
438 - if( $parameter['name'] == 'wpgetapi_on' ) {
439 - unset( $parameters[ $key ] );
440 - continue;
441 - }
442 -
443 - $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
444 -
445 - // if we are sending raw body
446 - } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
447 -
448 - $raw = stripslashes( $parameter['value'] );
449 -
450 - }
451 -
452 - }
453 - }
454 -
455 - // look for array or json string and sort these out - for using such things in shortcode
456 - if( ! empty( $new_array ) ) {
457 -
458 - foreach ( $new_array as $key => $value ) {
459 -
460 - // checking if the parameters have a json string
461 - if ( strpos( $value, '{' ) !== false && strpos( $value, '}' ) !== false ) {
462 - //if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
463 - $new_array[ $key ] = json_decode( $value, true );
464 - } else
465 -
466 - // checking if the parameters have an array within the string
467 - // if they do, create them as an actual array
468 - if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
469 - $value = trim( $value,"[]" );
470 - $new_array[ $key ] = array( $value );
471 - }
472 -
473 - // set value as integer
474 - if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) {
475 - preg_match("/\(([^\)]*)\)/", $value, $match );
476 - $result = $match[1];
477 - $new_array[ $key ] = absint( $result );
478 - }
479 -
480 - // set value as float
481 - if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) {
482 - preg_match("/\(([^\)]*)\)/", $value, $match );
483 - $result = $match[1];
484 - $new_array[ $key ] = (float) $result;
485 -
486 - }
487 -
488 - // set value as boolean
489 - if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) {
490 - preg_match("/\(([^\)]*)\)/", $value, $match );
491 - $result = $match[1];
492 - $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN );
493 - $new_array[ $key ] = $result;
494 -
495 - }
496 -
497 - }
498 -
499 - }
500 -
501 - return $raw ? $raw : $new_array;
502 -
503 - }
504 -
505 -
506 317 /**
507 318 * decrypt our parameters from the DB
508 319 */
509 320 public function decrypt( $array_or_string ) {
@@ -529,86 +340,20 @@
529 340
530 341 /**
531 342 * debug
532 343 */
533 - public function maybe_add_debug_info( $data, $wpgetapi ) {
344 + public function maybe_add_debug_info( $data, $this_data ) {
534 345
535 - if(
536 - ( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) ||
537 - ( isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) )
538 - ) {
346 + if( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) {
539 347
540 - $this->debug = true;
541 -
542 - // admin test endpoint button
543 - $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false;
544 -
545 - // get api status from response code
546 - $status = array(
547 - 'title' => 'Error in API response.',
548 - 'desc' => 'Check all details within your endpoint. Something is misconfigured.',
549 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
550 - );
551 -
552 - if( $this->response_code == 200 ) {
553 - $status = array(
554 - 'title' => 'Success!',
555 - '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.',
556 - 'type' => '<span class="dashicons dashicons-yes-alt"></span>'
557 - );
558 - }
559 - if( $this->response_code == 400 || $this->response_code == 404 ) {
560 - $status = array(
561 - 'title' => 'Bad Request',
562 - '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.',
563 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
564 - );
565 - }
566 - if( $this->response_code == 401 ) {
567 - $status = array(
568 - 'title' => 'Unauthorised',
569 - '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.',
570 - 'type' => '<span class="dashicons dashicons-warning"></span>'
571 - );
572 - }
573 - if( $this->response_code == 403 ) {
574 - $status = array(
575 - 'title' => 'Forbidden',
576 - '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.',
577 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
578 - );
579 - }
580 - if( $this->response_code == 405 ) {
581 - $status = array(
582 - 'title' => 'Method Not Allowed',
583 - 'desc' => 'Try changing the Request Method within the endpoint settings.',
584 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
585 - );
586 - }
587 - if( $this->response_code == 415 ) {
588 - $status = array(
589 - 'title' => 'Unsupported Media Type',
590 - '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>.',
591 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
592 - );
593 - }
594 - if( $this->response_code == 500 ) {
595 - $status = array(
596 - 'title' => 'Internal Server Error',
597 - 'desc' => 'This indicates an issue with the server. Contact your API provider.',
598 - 'type' => '<span class="dashicons dashicons-dismiss"></span>'
599 - );
600 - }
601 -
602 -
603 348 ob_start(); ?>
604 349
605 350 <style>
606 351
607 352 .wpgetapi-debug {
608 - background: #fff;
353 + background: #f4f4f4;
609 354 padding: 20px;
610 - box-shadow: 0 0 1px #aaa;
355 + border: 1px solid #ccc;
611 356 margin: 20px;
612 357 font-size: 15px;
613 358 }
614 359 .wpgetapi-debug
@@ -623,9 +368,9 @@
623 368 }
624 369 .wpgetapi-debug p.small {
625 370 font-size: 85%;
626 371 color: #999;
627 - margin: 0 0 12px !important;
372 + margin-bottom: 15px !important
628 373 }
629 374 .wpgetapi-debug h5 {
630 375 font-weight: bold;
631 376 font-size: 18px;
@@ -635,153 +380,85 @@
635 380 .wpgetapi-debug .debug-item {
636 381 margin: 10px 0;
637 382 background: #fff;
638 383 padding: 15px 20px;
639 - display: inline-block !important;
384 + display: inline-block !important;;
640 385 width: 100% !important;
641 - box-shadow: 0 3px 8px rgb(0 0 0 / 6%);
642 - border: 1px solid #eee;
386 + box-shadow: 0 0 5px rgba(0,0,0,0.1)
643 387 }
644 388 .wpgetapi-debug .debug-item h6 {
645 389 font-weight: bold;
646 - font-size: 14px;
647 - margin: 0;
390 + font-size: 16px;
391 + margin: 0 0 3px;
648 392 text-transform: none !important;
649 393 }
650 394 .wpgetapi-debug .debug-item .debug-result,
651 395 .wpgetapi-debug .debug-item .debug-result pre {
652 396 font-family: monospace !important;
653 - font-size: 13px !important;
397 + font-size: 15px !important;
654 398 margin: 0 !important;
655 - padding: 8px 12px;
656 - background: #f4f7f9;
399 + padding: 10px 12px;
400 + background: #f8f8f8;
657 401 }
658 402 .wpgetapi-debug .debug-item .debug-result pre {
659 403 border: none;
660 404 padding: 5px
661 405 }
662 -.wpgetapi-debug.testing {
663 - background: transparent;
664 - padding: 0;
665 - box-shadow: none;
666 -}
667 -.wpgetapi-debug.testing .debug-item {
668 - margin: 5px 0;
669 -}
670 -.wpgetapi-debug.testing .debug-item.status {
671 - border: none;
672 - box-shadow: none;
673 - margin-bottom: 15px;
674 -}
675 -.wpgetapi-debug .debug-item.status h5 {
676 - font-size: 15px;
677 -}
678 -.wpgetapi-debug .status .dashicons {
679 - margin: 0 5px 3px 0;
680 -}
681 -.wpgetapi-debug .status .dashicons-yes-alt {
682 - color: #5e9929;
683 -}
684 -.wpgetapi-debug .status .dashicons-dismiss {
685 - color: #cc4646;
686 -}
687 -.wpgetapi-debug .status .dashicons-warning {
688 - color: #dfa12e;
689 -}
690 -.wpgetapi-debug .status .desc {
691 - font-size: 14px;
692 - font-weight: 400 !important;
693 -}
406 +
694 407 </style>
695 408
696 - <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>">
409 + <div class="wpgetapi-debug">
697 410
698 - <?php if( $testing ) { ?>
411 + <h5><strong>WPGetAPI, Debug Mode - Plugin Version <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
412 + <p class="small">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.<br>Connecting to API's can be tricky - if you require help, please see the <a target="_blank" href="https://wpgetapi.com/docs/">Documentation</a> and if you can't find the answer then please use the contact form on our <a target="_blank" title="Connect WordPress with external API" href="https://wpgetapi.com/">website</a> to get assistance.</p>
699 413
700 - <div class="debug-item status">
701 - <div class="">
702 - <h5><?php _e( $status['type'] ); ?> <?php esc_html_e( $status['title'] ); ?></h5>
703 - <span class="desc"><?php _e( $status['desc'] ); ?></span>
704 - </div>
705 - </div>
706 - <div class="debug-item">
707 - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
708 - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
709 - <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
710 - </div>
711 -
712 - <div class="debug-item">
713 - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
714 - <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>
715 - <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
716 - </div>
717 -
718 - <div class="debug-item">
719 - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
720 - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
721 - <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
722 - </div>
723 -
724 - <div class="debug-item">
725 - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
726 - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
727 - <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
728 - </div>
729 -
730 - <?php } else { ?>
731 -
732 - <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
733 - <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>
734 -
735 414 <div class="debug-item">
736 - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
737 - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
415 + <h6>Full URL</h6>
416 + <p class="small">The full URL that is being called.</p>
738 417 <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
739 418 </div>
740 419
741 420 <div class="debug-item">
742 - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
743 - <p class="small"><?php esc_html_e( 'The resulting output that has been returned from the API.', 'wpgetapi' ); ?></p>
421 + <h6>Data Output</h6>
422 + <p class="small">The resulting output that has been returned from the API.</p>
744 423 <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
745 424 </div>
746 425
747 426 <div class="debug-item">
748 - <h6><?php esc_html_e( 'Query String', 'wpgetapi' ); ?></h6>
749 - <p class="small"><?php esc_html_e( 'The query string parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
427 + <h6>Arguments</h6>
428 + <p class="small">The arguments set within your shortcode or template tag.</p>
429 + <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div>
430 + </div>
431 +
432 + <div class="debug-item">
433 + <h6>Query String</h6>
434 + <p class="small">The query string parameters (if any) that you have set within the endpoint settings.</p>
750 435 <div class="debug-result"><?php wpgetapi_pp( $this->query_parameters ); ?></div>
751 436 </div>
752 437
753 438 <div class="debug-item">
754 - <h6><?php esc_html_e( 'Headers', 'wpgetapi' ); ?></h6>
755 - <p class="small"><?php esc_html_e( 'The header parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
439 + <h6>Headers</h6>
440 + <p class="small">The headers parameters (if any) that you have set within the endpoint settings.</p>
756 441 <div class="debug-result"><?php wpgetapi_pp( $this->header_parameters ); ?></div>
757 442 </div>
758 443
759 444 <div class="debug-item">
760 - <h6><?php esc_html_e( 'Body', 'wpgetapi' ); ?></h6>
761 - <p class="small"><?php esc_html_e( 'The body parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
445 + <h6>Body</h6>
446 + <p class="small">The body parameters (if any) that you have set within the endpoint settings.</p>
762 447 <div class="debug-result"><?php wpgetapi_pp( $this->body_parameters ); ?></div>
763 448 </div>
764 449
765 450 <div class="debug-item">
766 - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
767 - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
451 + <h6>Final Request Arguments</h6>
452 + <p class="small">The final request arguments sent in the API request. Includes headers and body arguments.</p>
768 453 <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
769 454 </div>
770 455
771 456 <div class="debug-item">
772 - <h6><?php esc_html_e( 'Arguments', 'wpgetapi' ); ?></h6>
773 - <p class="small"><?php esc_html_e( 'The arguments set within your shortcode or template tag.', 'wpgetapi' ); ?></p>
774 - <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div>
775 - </div>
776 -
777 - <div class="debug-item">
778 - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
779 - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
457 + <h6>Response</h6>
458 + <p class="small">The full response from the API request.</p>
780 459 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
781 460 </div>
782 -
783 - <?php } ?>
784 461
785 462 </div>
786 463
787 464 <?php