PluginProbe
WPGet API – Connect to any external REST API / 1.8.9
WPGet API – Connect to any external REST API v1.8.9
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.9, at includes/class-api.php

679 lines 24.9 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 ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' ) {
282 $this->body_parameters = json_decode( $this->body_parameters, true );
283 }
284
285 $this->body_parameters = http_build_query( $this->body_parameters );
286
287 }
288
289 // do we xml the entire body
290 if( $this->body_xml_format == true ) {
291
292 $xml = new SimpleXmlElement( '<' . $this->xml_root_node . '/>' );
293
294 foreach( $this->body_parameters as $key => $value) {
295 $xml->addChild( $key, $value );
296 }
297
298 $this->body_parameters = $xml->asXML();
299
300 }
301
302 // add our body parameters
303 if( $this->body_parameters && ! empty( $this->body_parameters ) )
304 $headers['body'] = $this->body_parameters;
305
306 }
307
308 // add headers to our final request args
309 $this->final_request_args = wp_parse_args( $headers, $this->final_request_args );
310
311 // build the args taht are sent to the request
312 $default_args = apply_filters( 'wpgetapi_default_request_args_parameters', array(
313 'timeout' => $this->timeout,
314 'sslverify' => $this->sslverify,
315 'redirection' => 5,
316 'blocking' => true,
317 'cookies' => array(),
318 ) );
319
320 return wp_parse_args( $this->final_request_args, $default_args );
321
322 }
323
324
325 /**
326 * Do a GET request
327 */
328 public function GET_request() {
329 $response = '';
330 // so we can so something before the remote_get (caching)
331 $response = apply_filters( 'wpgetapi_before_get_request', $response, $this );
332
333 if( empty( $response ) )
334 $response = wp_remote_get( $this->final_url, $this->final_request_args );
335 return $response;
336 }
337
338 /**
339 * Do a POST request
340 */
341 public function POST_request() {
342 $this->final_request_args['method'] = 'POST';
343 $response = wp_remote_post( $this->final_url, $this->final_request_args );
344 return $response;
345 }
346
347 /**
348 * Do a PUT request
349 */
350 public function PUT_request() {
351 $this->final_request_args['method'] = 'PUT';
352 $response = wp_remote_request( $this->final_url, $this->final_request_args );
353 return $response;
354 }
355
356 /**
357 * Do a DELETE request
358 */
359 public function DELETE_request() {
360 $this->final_request_args['method'] = 'DELETE';
361 $response = wp_remote_request( $this->final_url, $this->final_request_args );
362 return $response;
363 }
364
365
366 /**
367 * return data
368 */
369 public function return_data( $data ) {
370
371 $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys );
372
373 // converts all data to arrays, removing objects
374 if( is_string( $data ) ) {
375 $decode = json_decode( $data, true );
376 if( json_last_error() ) {
377 return esc_html( $data );
378 } else {
379 $data = $decode;
380 }
381 }
382
383 $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys );
384
385 if( $this->results_format == 'json_string' )
386 return trim( json_encode( $data ),'"');
387
388 if( $this->results_format == 'json_decoded' )
389 return $data;
390
391 }
392
393 /**
394 * Sort out the parameters if they exist
395 */
396 public function do_parameters( $parameters ) {
397
398 $new_array = array();
399 $raw = '';
400 $parameters = $this->decrypt( $parameters );
401
402 if( is_array( $parameters ) ) {
403 foreach ( $parameters as $key => $parameter ) {
404
405 if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
406
407 $parameter['value'] = stripslashes( $parameter['value'] );
408
409 // if we have wpgetapi_on, delete it so we don't send to api
410 if( $parameter['name'] == 'wpgetapi_on' ) {
411 unset( $parameters[ $key ] );
412 continue;
413 }
414
415 $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value'];
416
417 // if we are sending raw body
418 } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) {
419
420 $raw = stripslashes( $parameter['value'] );
421
422 }
423
424 }
425 }
426
427 // look for array or json string and sort these out - for using such things in shortcode
428 if( ! empty( $new_array ) ) {
429
430 foreach ( $new_array as $key => $value ) {
431
432 // checking if the parameters have a json string
433 if ( strpos( $value, '{' ) !== false && strpos( $value, '}' ) !== false ) {
434 //if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) {
435 $new_array[ $key ] = json_decode( $value, true );
436 } else
437
438 // checking if the parameters have an array within the string
439 // if they do, create them as an actual array
440 if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) {
441 $value = trim( $value,"[]" );
442 $new_array[ $key ] = array( $value );
443 }
444
445 // set value as integer
446 if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) {
447 preg_match("/\(([^\)]*)\)/", $value, $match );
448 $result = $match[1];
449 $new_array[ $key ] = absint( $result );
450 }
451
452 // set value as float
453 if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) {
454 preg_match("/\(([^\)]*)\)/", $value, $match );
455 $result = $match[1];
456 $new_array[ $key ] = (float) $result;
457
458 }
459
460 // set value as boolean
461 if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) {
462 preg_match("/\(([^\)]*)\)/", $value, $match );
463 $result = $match[1];
464 $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN );
465 $new_array[ $key ] = $result;
466
467 }
468
469 }
470
471 }
472
473 return $raw ? $raw : $new_array;
474
475 }
476
477
478 /**
479 * decrypt our parameters from the DB
480 */
481 public function decrypt( $array_or_string ) {
482
483 if( is_string($array_or_string) ){
484 $array_or_string = $this->encryption->decrypt($array_or_string);
485 }elseif( is_array($array_or_string) ){
486 foreach ( $array_or_string as $key => &$value ) {
487 if( $key === 'name' )
488 continue;
489 if ( is_array( $value ) ) {
490 $value = $this->decrypt($value);
491 }
492 else {
493 $value = $this->encryption->decrypt($value);
494
495 }
496 }
497 }
498 return $array_or_string;
499 }
500
501
502 /**
503 * debug
504 */
505 public function maybe_add_debug_info( $data, $wpgetapi ) {
506
507 if(
508 ( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) ||
509 ( isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) )
510 ) {
511
512 $this->debug = true;
513
514 $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false;
515
516 ob_start(); ?>
517
518 <style>
519
520 .wpgetapi-debug {
521 background: #fff;
522 padding: 20px;
523 box-shadow: 0 0 1px #aaa;
524 margin: 20px;
525 font-size: 15px;
526 }
527 .wpgetapi-debug
528 .wpgetapi-debug p
529 .wpgetapi-debug h5
530 .wpgetapi-debug h6 {
531 color: #000;
532 line-height: 1 !important;
533 text-transform: none !important;
534 font-family: sans-serif !important;
535 letter-spacing: 0px !important;
536 }
537 .wpgetapi-debug p.small {
538 font-size: 85%;
539 color: #999;
540 margin: 0 0 12px !important;
541 }
542 .wpgetapi-debug h5 {
543 font-weight: bold;
544 font-size: 18px;
545 margin: 0 0 3px;
546 text-transform: none !important;
547 }
548 .wpgetapi-debug .debug-item {
549 margin: 10px 0;
550 background: #fff;
551 padding: 15px 20px;
552 display: inline-block !important;
553 width: 100% !important;
554 box-shadow: 3px 3px 0 rgb(0 0 0 / 8%);
555 border: 1px solid #efefef;
556 }
557 .wpgetapi-debug .debug-item h6 {
558 font-weight: bold;
559 font-size: 14px;
560 margin: 0;
561 text-transform: none !important;
562 }
563 .wpgetapi-debug .debug-item .debug-result,
564 .wpgetapi-debug .debug-item .debug-result pre {
565 font-family: monospace !important;
566 font-size: 13px !important;
567 margin: 0 !important;
568 padding: 8px 12px;
569 background: #f8f8f8;
570 }
571 .wpgetapi-debug .debug-item .debug-result pre {
572 border: none;
573 padding: 5px
574 }
575
576 .wpgetapi-debug.testing {
577 background: transparent;
578 padding: 0;
579 box-shadow: none;
580 }
581 .wpgetapi-debug.testing .debug-item {
582 margin: 5px 0;
583 }
584 </style>
585
586 <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>">
587
588 <?php if( $testing ) { ?>
589
590 <div class="debug-item">
591 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
592 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
593 <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
594 </div>
595
596 <div class="debug-item">
597 <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
598 <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>
599 <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>
600 <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
601 </div>
602
603 <div class="debug-item">
604 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
605 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
606 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
607 </div>
608
609 <?php } else { ?>
610
611 <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5>
612 <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>
613
614 <div class="debug-item">
615 <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6>
616 <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p>
617 <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div>
618 </div>
619
620 <div class="debug-item">
621 <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6>
622 <p class="small"><?php esc_html_e( 'The resulting output that has been returned from the API.', 'wpgetapi' ); ?></p>
623 <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div>
624 </div>
625
626 <div class="debug-item">
627 <h6><?php esc_html_e( 'Query String', 'wpgetapi' ); ?></h6>
628 <p class="small"><?php esc_html_e( 'The query string parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
629 <div class="debug-result"><?php wpgetapi_pp( $this->query_parameters ); ?></div>
630 </div>
631
632 <div class="debug-item">
633 <h6><?php esc_html_e( 'Headers', 'wpgetapi' ); ?></h6>
634 <p class="small"><?php esc_html_e( 'The header parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
635 <div class="debug-result"><?php wpgetapi_pp( $this->header_parameters ); ?></div>
636 </div>
637
638 <div class="debug-item">
639 <h6><?php esc_html_e( 'Body', 'wpgetapi' ); ?></h6>
640 <p class="small"><?php esc_html_e( 'The body parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p>
641 <div class="debug-result"><?php wpgetapi_pp( $this->body_parameters ); ?></div>
642 </div>
643
644 <div class="debug-item">
645 <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6>
646 <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p>
647 <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div>
648 </div>
649
650 <div class="debug-item">
651 <h6><?php esc_html_e( 'Arguments', 'wpgetapi' ); ?></h6>
652 <p class="small"><?php esc_html_e( 'The arguments set within your shortcode or template tag.', 'wpgetapi' ); ?></p>
653 <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div>
654 </div>
655
656 <div class="debug-item">
657 <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6>
658 <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p>
659 <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div>
660 </div>
661
662 <?php } ?>
663
664 </div>
665
666 <?php
667
668 return ob_get_clean();
669
670 } else {
671
672 return $data;
673
674 }
675
676 }
677
678
679 }