PluginProbe
WPGet API – Connect to any external REST API / 1.8.10
WPGet API – Connect to any external REST API v1.8.10
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
wpgetapi / includes / class-api.php

class-api.php in WPGet API – Connect to any external REST API 1.8.10, at includes/class-api.php

682 lines 25.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 /**
7 * The main class
8 *
9 * @since 1.0.0
10 */
11 class WpGetApi_Api {
12
13 public $encryption = ''; // the encryption class
14
15 public $setup = ''; // store the setup data from the admin page
16 public $api = ''; // store the api's from the admin page
17
18 public $api_id = ''; // the api_id that we are wanting to get
19 public $endpoint_id = ''; // the endpoint_id that we are wanting to get
20 public $args = ''; // the args
21 public $keys = ''; // the keys we want to retrieve
22
23 public $base_url = ''; // base url of the API
24 public $method = 'GET'; // the endpoint method GET POST etc
25 public $cache_time = ''; // the time to cache
26 public $endpoint = ''; // the endpoint that we will get
27 public $query_parameters = ''; // the query paramaters appended to url
28 public $header_parameters = ''; // the header paramaters
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
34
35 public $response = ''; // the returned response
36
37 public $final_url = ''; // final URL
38 public $final_request_args = array(); // final request_args
39
40 public $results_format = 'json_string'; // results format
41
42 public $timeout = 10; // the timeout
43 public $sslverify = 1; // the paramaters
44 public $debug = false;
45
46
47 /**
48 * Main constructor
49 *
50 * @since 1.0.0
51 *
52 */
53 public function __construct( $api_id = '', $endpoint_id = '', $args = array(), $keys = array() ) {
54
55 $this->setup = get_option( 'wpgetapi_setup' );
56 $this->api = get_option( 'wpgetapi_' . $api_id );
57
58 $this->encryption = new WpGetApi_Encryption();
59 $this->api_id = sanitize_text_field( $api_id );
60 $this->endpoint_id = sanitize_text_field( $endpoint_id );
61 $this->keys = $keys;
62 $this->args = $args;
63
64 add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 99, 2 );
65
66 }
67
68
69 /**
70 * Init our api data
71 */
72 public function init() {
73
74 // if we are doing importer plugin,
75 // we need to intercept and modify most of our methods values
76 if( $this->api_id == 'wpgetapi_importer' ) {
77
78 $data = apply_filters( 'wpgetapi_api_importer_init', $this );
79
80 if( $data ) {
81
82 foreach ($data as $key => $value) {
83 $this->{$key} = $value;
84 }
85
86 $this->query_parameters = ! empty( $this->query_parameters ) ? $this->do_parameters( $this->query_parameters ) : array();
87 $this->header_parameters = ! empty( $this->header_parameters ) ? $this->do_parameters( $this->header_parameters ) : array();
88 $this->body_parameters = ! empty( $this->body_parameters ) ? $this->do_parameters( $this->body_parameters ) : array();
89 return;
90
91 }
92
93 }
94
95 // do some checks
96 if( empty( $this->setup ) || ! isset( $this->setup['apis'] ) || empty( $this->setup['apis'] ) )
97 return 'No API found.';
98
99 // do some checks
100 if( ! $this->api || ! isset( $this->api['endpoints'] ) || empty( $this->api['endpoints'] ))
101 return 'API not found.';
102
103 // loop through api's
104 // set base_url
105 foreach ( $this->setup['apis'] as $index => $api_item ) {
106 if( $this->api_id == $api_item['id'] ) {
107 $this->base_url = isset( $api_item['base_url'] ) && ! empty( $api_item['base_url'] ) ? esc_url_raw( $api_item['base_url'] ) : '';
108 }
109 }
110
111 // loop through endpoints
112 foreach ( $this->api['endpoints'] as $index => $endpoint ) {
113
114 if( $this->endpoint_id == $endpoint['id'] ) {
115
116 $this->method = isset( $endpoint['method'] ) && $endpoint['method'] != '' ? sanitize_text_field( $endpoint['method'] ) : 'GET';
117 $this->cache_time = isset( $endpoint['cache_time'] ) && ! empty( $endpoint['cache_time'] ) ? absint( $endpoint['cache_time'] ) : '';
118 $this->endpoint = isset( $endpoint['endpoint'] ) && ! empty( $endpoint['endpoint'] ) ? sanitize_text_field( $endpoint['endpoint'] ) : '';
119
120 $this->query_parameters = isset( $endpoint['query_parameters'] ) && ! empty( $endpoint['query_parameters'] ) ? $this->do_parameters( $endpoint['query_parameters'] ) : array();
121
122 $this->header_parameters = isset( $endpoint['header_parameters'] ) && ! empty( $endpoint['header_parameters'] ) ? $this->do_parameters( $endpoint['header_parameters'] ) : array();
123
124 $this->body_parameters = isset( $endpoint['body_parameters'] ) && ! empty( $endpoint['body_parameters'] ) ? $this->do_parameters( $endpoint['body_parameters'] ) : array();
125
126 $this->body_json_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'true' ? true : false;
127 $this->body_url_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'url' ? true : false;
128 $this->body_xml_format = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'xml' ? true : false;
129 $this->xml_root_node = isset( $endpoint['xml_root'] ) && ! empty( $endpoint['xml_root'] ) ? $endpoint['xml_root'] : $this->xml_root_node;
130
131 $this->results_format = isset( $endpoint['results_format'] ) ? sanitize_text_field( $endpoint['results_format'] ) : $this->results_format;
132
133 // set the format to php array data if html format is set
134 if( isset( $this->args['format'] ) && $this->args['format'] == 'html' ) {
135 $this->results_format = 'json_decoded';
136 }
137
138 }
139
140 }
141
142 $this->timeout = isset( $this->api['timeout'] ) && ! empty( $this->api['timeout'] ) ? $this->api['timeout'] : $this->timeout;
143 $this->sslverify = isset( $this->api['sslverify'] ) ? absint( $this->api['sslverify'] ) : $this->sslverify;
144
145 }
146
147
148 /**
149 * The main function to output the data
150 *
151 * @param string $field Field to retrieve
152 */
153 public function endpoint_output() {
154
155 do_action( 'wpgetapi_before_do_the_call', $this );
156
157 return $this->do_the_call();
158
159 }
160
161
162 /**
163 * Send the request and return our data
164 */
165 public function do_the_call() {
166
167 $this->init();
168
169 // build the URL
170 $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this );
171
172 // build the request args
173 $this->final_request_args = apply_filters( 'wpgetapi_final_request_args', $this->build_request_args(), $this );
174
175 /**
176 * Check if we should stop or not. Setting $on to true, will stop us calling the api.
177 * @param bool $on Whether on is set or not.
178 */
179
180 if ( apply_filters( 'wpgetapi_should_we_stop', false, $this ) ) {
181 return;
182 }
183
184 // POST request
185 if( $this->method == 'POST' )
186 $this->response = $this->POST_request();
187
188 // PUT request
189 if( $this->method == 'PUT' )
190 $this->response = $this->PUT_request();
191
192 // GET request
193 if( $this->method == 'GET' )
194 $this->response = $this->GET_request();
195
196 // DELETE request
197 if( $this->method == 'DELETE' )
198 $this->response = $this->DELETE_request();
199
200 // wp error
201 if( is_wp_error( $this->response ) ) {
202 return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this );
203 }
204
205 // get response_code
206 $response_code = wp_remote_retrieve_response_code( $this->response );
207
208 // action to intercept call depending on response_code
209 $this->response = apply_filters( 'wpgetapi_before_retrieve_body', $this->response, $response_code, $this );
210
211 // get body
212 // modified in version 1.6.1 to allow for OAuth 2.0 plugin returning body already
213 $data = isset( $this->response['body'] ) ? $this->response['body'] : $this->response;
214
215 // returning in JSON format
216 if( $this->results_format == 'json_string' || $this->results_format == 'json_decoded' )
217 $data = $this->return_data( $data );
218
219 if( $data === 'null' )
220 $data = 'Result is null. Check that all endpoint settings are correct.';
221
222 return apply_filters( 'wpgetapi_raw_data', $data, $this );
223
224 }
225
226
227 /**
228 * Build the request url with the ability to add args
229 */
230 public function build_url() {
231
232 // first make sure our endpoint starts with a slash
233 if ( substr( $this->endpoint, 0, 1 ) != '/' )
234 $this->endpoint = '/' . $this->endpoint;
235
236 $this->endpoint = apply_filters( 'wpgetapi_endpoint', $this->endpoint, $this );
237
238 $url = untrailingslashit( $this->base_url ) . $this->endpoint;
239
240 // if we have a URL pagination event from the import plugin
241 // we need to modify the URL here
242 if( isset( $this->args['paginate_url'] ) )
243 $url = $this->args['paginate_url'];
244
245 // filter our params - added for use in Oauth 2.0 plugin
246 $params = apply_filters( 'wpgetapi_query_parameters', $this->query_parameters, $this );
247
248 // add empty array - was getting errors if it was just null or false
249 $params = empty( $params ) ? array(''=>'') : $params;
250
251 return add_query_arg( $params, $url );
252
253 }
254
255
256 /**
257 * build the header with the ability to add args
258 */
259 public function build_request_args() {
260
261 // add our header parameters to the headers
262 $headers = apply_filters( 'wpgetapi_header_parameters', array(
263 'headers' => $this->header_parameters,
264 ), $this );
265
266
267 // if doing POST request, include body paramters
268 if( $this->method == 'POST' || $this->method == 'PUT' || $this->method == 'DELETE' ) {
269
270 $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this );
271
272 // do we json_encode the entire body
273 if( $this->body_json_encode == true ) {
274 $this->body_parameters = json_encode( $this->body_parameters );
275 }
276
277 // do we urlencode the entire body
278 if( $this->body_url_encode == true ) {
279
280 // checking if the parameters have a json string (raw)
281 if (
282 ( ! is_array( $this->body_parameters ) ) &&
283 ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' )
284 ) {
285 $this->body_parameters = json_decode( $this->body_parameters, true );
286 }
287
288 $this->body_parameters = http_build_query( $this->body_parameters );
289
290 }
291
292 // do we xml the entire body
293 if( $this->body_xml_format == true ) {
294
295 $xml = new SimpleXmlElement( '<' . $this->xml_root_node . '/>' );
296
297 foreach( $this->body_parameters as $key => $value) {
298 $xml->addChild( $key, $value );
299 }
300
301 $this->body_parameters = $xml->asXML();
302
303 }
304
305 // add our body parameters
306 if( $this->body_parameters && ! empty( $this->body_parameters ) )
307 $headers['body'] = $this->body_parameters;
308
309 }
310
311 // add headers to our final request args
312 $this->final_request_args = wp_parse_args( $headers, $this->final_request_args );
313
314 // build the args taht are sent to the request
315 $default_args = apply_filters( 'wpgetapi_default_request_args_parameters', array(
316 'timeout' => $this->timeout,
317 'sslverify' => $this->sslverify,
318 'redirection' => 5,
319 'blocking' => true,
320 'cookies' => array(),
321 ) );
322
323 return wp_parse_args( $this->final_request_args, $default_args );
324
325 }
326
327
328 /**
329 * Do a GET request
330 */
331 public function GET_request() {
332 $response = '';
333 // so we can so something before the remote_get (caching)
334 $response = apply_filters( 'wpgetapi_before_get_request', $response, $this );
335
336 if( empty( $response ) )
337 $response = wp_remote_get( $this->final_url, $this->final_request_args );
338 return $response;
339 }
340
341 /**
342 * Do a POST request
343 */
344 public function POST_request() {
345 $this->final_request_args['method'] = 'POST';
346 $response = wp_remote_post( $this->final_url, $this->final_request_args );
347 return $response;
348 }
349
350 /**
351 * Do a PUT request
352 */
353 public function PUT_request() {
354 $this->final_request_args['method'] = 'PUT';
355 $response = wp_remote_request( $this->final_url, $this->final_request_args );
356 return $response;
357 }
358
359 /**
360 * Do a DELETE request
361 */
362 public function DELETE_request() {
363 $this->final_request_args['method'] = 'DELETE';
364 $response = wp_remote_request( $this->final_url, $this->final_request_args );
365 return $response;
366 }
367
368
369 /**
370 * return data
371 */
372 public function return_data( $data ) {
373
374 $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys );
375
376 // converts all data to arrays, removing objects
377 if( is_string( $data ) ) {
378 $decode = json_decode( $data, true );
379 if( json_last_error() ) {
380 return esc_html( $data );
381 } else {
382 $data = $decode;
383 }
384 }
385
386 $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys );
387
388 if( $this->results_format == 'json_string' )
389 return trim( json_encode( $data ),'"');
390
391 if( $this->results_format == 'json_decoded' )
392 return $data;
393
394 }
395
396 /**
397 * Sort out the parameters if they exist
398 */
399 public function do_parameters( $parameters ) {
400
401 $new_array = array();
402 $raw = '';
403 $parameters = $this->decrypt( $parameters );
404
405 if( is_array( $parameters ) ) {
406 foreach ( $parameters as $key => $parameter ) {
407
408 if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
409
410 $parameter['value'] = stripslashes( $parameter['value'] );
411
412 // if we have wpgetapi_on, delete it so we don't send to api
413 if( $parameter['name'] == 'wpgetapi_on' ) {
414 unset( $parameters[ $key ] );
415 continue;
416 }
417
418 $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
419
420 // if we are sending raw body
421 } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
422
423 $raw = stripslashes( $parameter['value'] );
424
425 }
426
427 }
428 }
429
430 // look for array or json string and sort these out - for using such things in shortcode
431 if( ! empty( $new_array ) ) {
432
433 foreach ( $new_array as $key => $value ) {
434
435 // checking if the parameters have a json string
436 if ( strpos( $value, '{' ) !== false && strpos( $value, '}' ) !== false ) {
437 //if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
438 $new_array[ $key ] = json_decode( $value, true );
439 } else
440
441 // checking if the parameters have an array within the string
442 // if they do, create them as an actual array
443 if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
444 $value = trim( $value,"[]" );
445 $new_array[ $key ] = array( $value );
446 }
447
448 // set value as integer
449 if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) {
450 preg_match("/\(([^\)]*)\)/", $value, $match );
451 $result = $match[1];
452 $new_array[ $key ] = absint( $result );
453 }
454
455 // set value as float
456 if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) {
457 preg_match("/\(([^\)]*)\)/", $value, $match );
458 $result = $match[1];
459 $new_array[ $key ] = (float) $result;
460
461 }
462
463 // set value as boolean
464 if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) {
465 preg_match("/\(([^\)]*)\)/", $value, $match );
466 $result = $match[1];
467 $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN );
468 $new_array[ $key ] = $result;
469
470 }
471
472 }
473
474 }
475
476 return $raw ? $raw : $new_array;
477
478 }
479
480
481 /**
482 * decrypt our parameters from the DB
483 */
484 public function decrypt( $array_or_string ) {
485
486 if( is_string($array_or_string) ){
487 $array_or_string = $this->encryption->decrypt($array_or_string);
488 }elseif( is_array($array_or_string) ){
489 foreach ( $array_or_string as $key => &$value ) {
490 if( $key === 'name' )
491 continue;
492 if ( is_array( $value ) ) {
493 $value = $this->decrypt($value);
494 }
495 else {
496 $value = $this->encryption->decrypt($value);
497
498 }
499 }
500 }
501 return $array_or_string;
502 }
503
504
505 /**
506 * debug
507 */
508 public function maybe_add_debug_info( $data, $wpgetapi ) {
509
510 if(
511 ( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) ||
512 ( isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) )
513 ) {
514
515 $this->debug = true;
516
517 $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false;
518
519 ob_start(); ?>
520
521 <style>
522
523 .wpgetapi-debug {
524 background: #fff;
525 padding: 20px;
526 box-shadow: 0 0 1px #aaa;
527 margin: 20px;
528 font-size: 15px;
529 }
530 .wpgetapi-debug
531 .wpgetapi-debug p
532 .wpgetapi-debug h5
533 .wpgetapi-debug h6 {
534 color: #000;
535 line-height: 1 !important;
536 text-transform: none !important;
537 font-family: sans-serif !important;
538 letter-spacing: 0px !important;
539 }
540 .wpgetapi-debug p.small {
541 font-size: 85%;
542 color: #999;
543 margin: 0 0 12px !important;
544 }
545 .wpgetapi-debug h5 {
546 font-weight: bold;
547 font-size: 18px;
548 margin: 0 0 3px;
549 text-transform: none !important;
550 }
551 .wpgetapi-debug .debug-item {
552 margin: 10px 0;
553 background: #fff;
554 padding: 15px 20px;
555 display: inline-block !important;
556 width: 100% !important;
557 box-shadow: 3px 3px 0 rgb(0 0 0 / 8%);
558 border: 1px solid #efefef;
559 }
560 .wpgetapi-debug .debug-item h6 {
561 font-weight: bold;
562 font-size: 14px;
563 margin: 0;
564 text-transform: none !important;
565 }
566 .wpgetapi-debug .debug-item .debug-result,
567 .wpgetapi-debug .debug-item .debug-result pre {
568 font-family: monospace !important;
569 font-size: 13px !important;
570 margin: 0 !important;
571 padding: 8px 12px;
572 background: #f8f8f8;
573 }
574 .wpgetapi-debug .debug-item .debug-result pre {
575 border: none;
576 padding: 5px
577 }
578
579 .wpgetapi-debug.testing {
580 background: transparent;
581 padding: 0;
582 box-shadow: none;
583 }
584 .wpgetapi-debug.testing .debug-item {
585 margin: 5px 0;
586 }
587 </style>
588
589 <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>">
590
591 <?php if( $testing ) { ?>
592
593 <div class="debug-item">
594 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
595 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
596 <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
597 </div>
598
599 <div class="debug-item">
600 <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
601 <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>
602 <p class="small"><?php esc_html_e( 'See the ', 'wpgetapi' ); ?> <a target="_blank" href="https://wpgetapi.com/docs/?utm_campaign=Test Endpoint&utm_medium=Admin&utm_source=User"><?php esc_html_e( 'documentation', 'wpgetapi' ); ?></a> <?php esc_html_e( ' for help in formatting.', 'wpgetapi' ); ?></p>
603 <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
604 </div>
605
606 <div class="debug-item">
607 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
608 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
609 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
610 </div>
611
612 <?php } else { ?>
613
614 <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
615 <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>
616
617 <div class="debug-item">
618 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
619 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
620 <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
621 </div>
622
623 <div class="debug-item">
624 <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
625 <p class="small"><?php esc_html_e( 'The resulting output that has been returned from the API.', 'wpgetapi' ); ?></p>
626 <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
627 </div>
628
629 <div class="debug-item">
630 <h6><?php esc_html_e( 'Query String', 'wpgetapi' ); ?></h6>
631 <p class="small"><?php esc_html_e( 'The query string parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
632 <div class="debug-result"><?php wpgetapi_pp( $this->query_parameters ); ?></div>
633 </div>
634
635 <div class="debug-item">
636 <h6><?php esc_html_e( 'Headers', 'wpgetapi' ); ?></h6>
637 <p class="small"><?php esc_html_e( 'The header parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
638 <div class="debug-result"><?php wpgetapi_pp( $this->header_parameters ); ?></div>
639 </div>
640
641 <div class="debug-item">
642 <h6><?php esc_html_e( 'Body', 'wpgetapi' ); ?></h6>
643 <p class="small"><?php esc_html_e( 'The body parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
644 <div class="debug-result"><?php wpgetapi_pp( $this->body_parameters ); ?></div>
645 </div>
646
647 <div class="debug-item">
648 <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
649 <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
650 <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
651 </div>
652
653 <div class="debug-item">
654 <h6><?php esc_html_e( 'Arguments', 'wpgetapi' ); ?></h6>
655 <p class="small"><?php esc_html_e( 'The arguments set within your shortcode or template tag.', 'wpgetapi' ); ?></p>
656 <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div>
657 </div>
658
659 <div class="debug-item">
660 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
661 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
662 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
663 </div>
664
665 <?php } ?>
666
667 </div>
668
669 <?php
670
671 return ob_get_clean();
672
673 } else {
674
675 return $data;
676
677 }
678
679 }
680
681
682 }