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

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

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