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

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