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

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