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