| @@ -26,13 +26,9 @@ | ||
| 26 | 26 | public $endpoint = ''; // the endpoint that we will get |
| 27 | 27 | public $query_parameters = ''; // the query paramaters appended to url |
| 28 | 28 | public $header_parameters = ''; // the header paramaters |
| 29 | 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_base64_encode = ''; // base64 encode body | |
| 33 | - public $body_xml_format = ''; // xml format body | |
| 34 | - public $xml_root_node = 'root'; // root node for xml | |
| 30 | + public $body_json_encode = ''; // the body_json_encode | |
| 35 | 31 | |
| 36 | 32 | public $response = ''; // the returned response |
| 37 | 33 | |
| 38 | 34 | public $final_url = ''; // final URL |
| @@ -37,17 +33,12 @@ | ||
| 37 | 33 | |
| 38 | 34 | public $final_url = ''; // final URL |
| 39 | 35 | public $final_request_args = array(); // final request_args |
| 40 | 36 | |
| 41 | - public $results_format = 'json_string'; // results format | |
| 37 | + public $results_format = 'json_string'; // reseults format | |
| 42 | 38 | |
| 43 | - public $response_code = ''; // the response code from the call | |
| 44 | - | |
| 45 | 39 | public $timeout = 10; // the timeout |
| 46 | - public $sslverify = 1; // ssl verify | |
| 47 | - public $debug = false; | |
| 48 | - | |
| 49 | - public $pro_plugin = false; | |
| 40 | + public $sslverify = 1; // the paramaters | |
| 50 | 41 | |
| 51 | 42 | |
| 52 | 43 | /** |
| 53 | 44 | * Main constructor |
| @@ -65,10 +56,9 @@ | ||
| 65 | 56 | $this->endpoint_id = sanitize_text_field( $endpoint_id ); |
| 66 | 57 | $this->keys = $keys; |
| 67 | 58 | $this->args = $args; |
| 68 | 59 | |
| 69 | - add_filter( 'wpgetapi_raw_error_data', array( $this, 'maybe_add_debug_info' ), 99, 2 ); | |
| 70 | - add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 99, 2 ); | |
| 60 | + add_filter( 'wpgetapi_raw_data', array( $this, 'maybe_add_debug_info' ), 5, 2 ); | |
| 71 | 61 | |
| 72 | 62 | } |
| 73 | 63 | |
| 74 | 64 | |
| @@ -76,35 +66,8 @@ | ||
| 76 | 66 | * Init our api data |
| 77 | 67 | */ |
| 78 | 68 | public function init() { |
| 79 | 69 | |
| 80 | - if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 81 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 82 | - } | |
| 83 | - | |
| 84 | - $this->pro_plugin = is_plugin_active( 'wpgetapi-extras/wpgetapi-extras.php' ) ? true : false; | |
| 85 | - | |
| 86 | - // if we are doing importer plugin, | |
| 87 | - // we need to intercept and modify most of our methods values | |
| 88 | - if( $this->api_id === 'wpgetapi_importer' ) { | |
| 89 | - | |
| 90 | - $data = apply_filters( 'wpgetapi_api_importer_init', $this ); | |
| 91 | - | |
| 92 | - if( $data ) { | |
| 93 | - | |
| 94 | - foreach ($data as $key => $value) { | |
| 95 | - $this->{$key} = $value; | |
| 96 | - } | |
| 97 | - | |
| 98 | - $this->query_parameters = ! empty( $this->query_parameters ) ? $this->do_parameters( $this->query_parameters ) : array(); | |
| 99 | - $this->header_parameters = ! empty( $this->header_parameters ) ? $this->do_parameters( $this->header_parameters ) : array(); | |
| 100 | - $this->body_parameters = ! empty( $this->body_parameters ) ? $this->do_parameters( $this->body_parameters ) : array(); | |
| 101 | - return; | |
| 102 | - | |
| 103 | - } | |
| 104 | - | |
| 105 | - } | |
| 106 | - | |
| 107 | 70 | // do some checks |
| 108 | 71 | if( empty( $this->setup ) || ! isset( $this->setup['apis'] ) || empty( $this->setup['apis'] ) ) |
| 109 | 72 | return 'No API found.'; |
| 110 | 73 | |
| @@ -123,11 +86,10 @@ | ||
| 123 | 86 | // loop through endpoints |
| 124 | 87 | foreach ( $this->api['endpoints'] as $index => $endpoint ) { |
| 125 | 88 | |
| 126 | 89 | if( $this->endpoint_id == $endpoint['id'] ) { |
| 127 | - | |
| 90 | + | |
| 128 | 91 | $this->method = isset( $endpoint['method'] ) && $endpoint['method'] != '' ? sanitize_text_field( $endpoint['method'] ) : 'GET'; |
| 129 | - $this->timeout = isset( $endpoint['timeout'] ) && ! empty( $endpoint['timeout'] ) ? absint( $endpoint['timeout'] ) : ''; | |
| 130 | 92 | $this->cache_time = isset( $endpoint['cache_time'] ) && ! empty( $endpoint['cache_time'] ) ? absint( $endpoint['cache_time'] ) : ''; |
| 131 | 93 | $this->endpoint = isset( $endpoint['endpoint'] ) && ! empty( $endpoint['endpoint'] ) ? sanitize_text_field( $endpoint['endpoint'] ) : ''; |
| 132 | 94 | |
| 133 | 95 | $this->query_parameters = isset( $endpoint['query_parameters'] ) && ! empty( $endpoint['query_parameters'] ) ? $this->do_parameters( $endpoint['query_parameters'] ) : array(); |
| @@ -135,40 +97,11 @@ | ||
| 135 | 97 | $this->header_parameters = isset( $endpoint['header_parameters'] ) && ! empty( $endpoint['header_parameters'] ) ? $this->do_parameters( $endpoint['header_parameters'] ) : array(); |
| 136 | 98 | |
| 137 | 99 | $this->body_parameters = isset( $endpoint['body_parameters'] ) && ! empty( $endpoint['body_parameters'] ) ? $this->do_parameters( $endpoint['body_parameters'] ) : array(); |
| 138 | 100 | |
| 139 | - // how to encode the body | |
| 140 | - $this->body_json_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'true' ? true : false; | |
| 141 | - $this->body_url_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'url' ? true : false; | |
| 142 | - $this->body_base64_encode = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'base64' ? true : false; | |
| 143 | - $this->body_xml_format = isset( $endpoint['body_json_encode'] ) && $endpoint['body_json_encode'] == 'xml' ? true : false; | |
| 144 | - | |
| 145 | - $this->xml_root_node = isset( $endpoint['xml_root'] ) && ! empty( $endpoint['xml_root'] ) ? $endpoint['xml_root'] : $this->xml_root_node; | |
| 146 | - | |
| 101 | + $this->body_json_encode = isset( $endpoint['body_json_encode'] ) && ! empty( $endpoint['body_json_encode'] ) ? sanitize_text_field( $endpoint['body_json_encode'] ) : true; | |
| 147 | 102 | $this->results_format = isset( $endpoint['results_format'] ) ? sanitize_text_field( $endpoint['results_format'] ) : $this->results_format; |
| 148 | - | |
| 149 | - | |
| 150 | - if( | |
| 151 | - // set the format to php array data if html format is set | |
| 152 | - ( isset( $this->args['format'] ) && $this->args['format'] == 'html' && $this->results_format != 'xml_array' ) || | |
| 153 | - // set the format to php array data if it is set in the args (coming from the importer) | |
| 154 | - ( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_decoded' ) | |
| 155 | - ) { | |
| 156 | - $this->results_format = 'json_decoded'; | |
| 157 | - } | |
| 158 | - | |
| 159 | - // set the format to JSON string if it is set in the args (coming from the wpdatatables integration) | |
| 160 | - if( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_string' ) { | |
| 161 | - $this->results_format = 'json_string'; | |
| 162 | - } | |
| 163 | - | |
| 164 | - // set the format to JSON string if it is set in the args (coming from the wpdatatables integration) | |
| 165 | - if( isset( $this->args['results_format'] ) && $this->args['results_format'] == 'json_decoded' ) { | |
| 166 | - $this->results_format = 'json_decoded'; | |
| 167 | - } | |
| 168 | - | |
| 169 | 103 | } |
| 170 | - | |
| 171 | 104 | } |
| 172 | 105 | |
| 173 | 106 | $this->timeout = isset( $this->api['timeout'] ) && ! empty( $this->api['timeout'] ) ? $this->api['timeout'] : $this->timeout; |
| 174 | 107 | $this->sslverify = isset( $this->api['sslverify'] ) ? absint( $this->api['sslverify'] ) : $this->sslverify; |
| @@ -181,21 +114,58 @@ | ||
| 181 | 114 | * |
| 182 | 115 | * @param string $field Field to retrieve |
| 183 | 116 | */ |
| 184 | 117 | public function endpoint_output() { |
| 118 | + return $this->do_the_call(); | |
| 119 | + } | |
| 185 | 120 | |
| 186 | - do_action( 'wpgetapi_before_do_the_call', $this ); | |
| 187 | 121 | |
| 188 | - return $this->do_the_call(); | |
| 122 | + /** | |
| 123 | + * Sort out the parameters if they exist | |
| 124 | + */ | |
| 125 | + public function do_parameters( $parameters ) { | |
| 126 | + | |
| 127 | + $new_array = array(); | |
| 128 | + $parameters = $this->decrypt($parameters); | |
| 189 | 129 | |
| 130 | + if( is_array( $parameters ) ) { | |
| 131 | + foreach ( $parameters as $key => $parameter ) { | |
| 132 | + if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) { | |
| 133 | + $parameter['value'] = stripslashes( $parameter['value'] ); | |
| 134 | + $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value']; | |
| 135 | + } | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | + // look for array or json string and sort these out - for using such things in shortcode | |
| 140 | + if( is_array( $new_array ) ) { | |
| 141 | + | |
| 142 | + foreach ( $new_array as $key => $value ) { | |
| 143 | + | |
| 144 | + // checking if the parameters have a json string | |
| 145 | + if ( substr( $value, 0, 1 ) === '{' && substr( $value, -1 ) === '}' ) { | |
| 146 | + $new_array[ $key ] = json_decode( $value, true); | |
| 147 | + } | |
| 148 | + | |
| 149 | + // checking if the parameters have an array within the string | |
| 150 | + // if they do, create them as an actual array | |
| 151 | + if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) { | |
| 152 | + $new_array[ $key ] = array( $value ); | |
| 153 | + } | |
| 154 | + | |
| 155 | + } | |
| 156 | + | |
| 157 | + } | |
| 158 | + | |
| 159 | + return $new_array; | |
| 160 | + | |
| 190 | 161 | } |
| 191 | 162 | |
| 192 | - | |
| 193 | 163 | /** |
| 194 | 164 | * Send the request and return our data |
| 195 | 165 | */ |
| 196 | 166 | public function do_the_call() { |
| 197 | - | |
| 167 | + | |
| 198 | 168 | $this->init(); |
| 199 | 169 | |
| 200 | 170 | // build the URL |
| 201 | 171 | $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this ); |
| @@ -201,60 +171,28 @@ | ||
| 201 | 171 | $this->final_url = apply_filters( 'wpgetapi_final_url', $this->build_url(), $this ); |
| 202 | 172 | |
| 203 | 173 | // build the request args |
| 204 | 174 | $this->final_request_args = apply_filters( 'wpgetapi_final_request_args', $this->build_request_args(), $this ); |
| 205 | - | |
| 206 | - /** | |
| 207 | - * Check if we should stop or not. Setting $on to true, will stop us calling the api. | |
| 208 | - * @param bool $on Whether on is set or not. | |
| 209 | - */ | |
| 210 | 175 | |
| 211 | - if ( apply_filters( 'wpgetapi_should_we_stop', false, $this ) ) { | |
| 212 | - return; | |
| 213 | - } | |
| 214 | - | |
| 215 | 176 | // POST request |
| 216 | 177 | if( $this->method == 'POST' ) |
| 217 | 178 | $this->response = $this->POST_request(); |
| 218 | 179 | |
| 219 | - // PUT request | |
| 220 | - if( $this->method == 'PUT' ) | |
| 221 | - $this->response = $this->PUT_request(); | |
| 222 | - | |
| 223 | - // PATCH request | |
| 224 | - if( $this->method == 'PATCH' ) | |
| 225 | - $this->response = $this->PATCH_request(); | |
| 226 | - | |
| 227 | 180 | // GET request |
| 228 | 181 | if( $this->method == 'GET' ) |
| 229 | 182 | $this->response = $this->GET_request(); |
| 230 | 183 | |
| 231 | - // DELETE request | |
| 232 | - if( $this->method == 'DELETE' ) | |
| 233 | - $this->response = $this->DELETE_request(); | |
| 234 | - | |
| 235 | 184 | // wp error |
| 236 | 185 | if( is_wp_error( $this->response ) ) { |
| 237 | - return apply_filters( 'wpgetapi_raw_error_data', json_encode( $this->response ), $this ); | |
| 186 | + return apply_filters( 'wpgetapi_raw_data', json_encode( $this->response ), $this ); | |
| 238 | 187 | } |
| 239 | 188 | |
| 240 | - // get response_code | |
| 241 | - $this->response_code = wp_remote_retrieve_response_code( $this->response ); | |
| 189 | + $data = wp_remote_retrieve_body( $this->response ); | |
| 242 | 190 | |
| 243 | - // action to intercept call depending on response_code | |
| 244 | - $this->response = apply_filters( 'wpgetapi_before_retrieve_body', $this->response, $this->response_code, $this ); | |
| 245 | - | |
| 246 | - // get body | |
| 247 | - // modified in version 1.6.1 to allow for OAuth 2.0 plugin returning body already | |
| 248 | - $data = isset( $this->response['body'] ) ? $this->response['body'] : $this->response; | |
| 249 | - | |
| 250 | 191 | // returning in JSON format |
| 251 | 192 | if( $this->results_format == 'json_string' || $this->results_format == 'json_decoded' ) |
| 252 | - $data = $this->return_data( $data ); | |
| 193 | + $data = $this->output_json( $data ); | |
| 253 | 194 | |
| 254 | - if( $data === 'null' ) | |
| 255 | - $data = 'Result is null. Check that all endpoint settings are correct.'; | |
| 256 | - | |
| 257 | 195 | return apply_filters( 'wpgetapi_raw_data', $data, $this ); |
| 258 | 196 | |
| 259 | 197 | } |
| 260 | 198 | |
| @@ -267,33 +205,15 @@ | ||
| 267 | 205 | // first make sure our endpoint starts with a slash |
| 268 | 206 | if ( substr( $this->endpoint, 0, 1 ) != '/' ) |
| 269 | 207 | $this->endpoint = '/' . $this->endpoint; |
| 270 | 208 | |
| 271 | - // if we have item_key from api to posts plugin | |
| 272 | - // replace our keyword with the actual item_key value | |
| 273 | - if ( isset( $this->args['item_key'] ) && strpos( $this->endpoint, '(importer:item_key)' ) !== false ) { | |
| 274 | - $this->endpoint = str_replace( '(importer:item_key)', $this->args['item_key'], $this->endpoint ); | |
| 275 | - } | |
| 276 | - | |
| 277 | - $this->endpoint = apply_filters( 'wpgetapi_endpoint', $this->endpoint, $this ); | |
| 278 | - | |
| 279 | 209 | $url = untrailingslashit( $this->base_url ) . $this->endpoint; |
| 280 | 210 | |
| 281 | - // if we have a URL pagination event from the import plugin | |
| 282 | - // we need to modify the URL here | |
| 283 | - if( isset( $this->args['paginate_url'] ) ) | |
| 284 | - $url = $this->args['paginate_url']; | |
| 285 | - | |
| 286 | - // filter our params - added for use in Oauth 2.0 plugin | |
| 287 | - $params = apply_filters( 'wpgetapi_query_parameters', $this->query_parameters, $this ); | |
| 288 | - | |
| 289 | 211 | // add empty array - was getting errors if it was just null or false |
| 290 | - $params = empty( $params ) ? array(''=>'') : $params; | |
| 212 | + $params = empty( $this->query_parameters ) ? array(''=>'') : $this->query_parameters; | |
| 291 | 213 | |
| 292 | - $result = add_query_arg( $params, $url ); | |
| 214 | + return add_query_arg( $params, $url ); | |
| 293 | 215 | |
| 294 | - return $result; | |
| 295 | - | |
| 296 | 216 | } |
| 297 | 217 | |
| 298 | 218 | |
| 299 | 219 | /** |
| @@ -307,76 +227,27 @@ | ||
| 307 | 227 | ), $this ); |
| 308 | 228 | |
| 309 | 229 | |
| 310 | 230 | // if doing POST request, include body paramters |
| 311 | - if( $this->method == 'POST' || $this->method == 'PUT' || $this->method == 'DELETE' || $this->method == 'PATCH' ) { | |
| 231 | + if( $this->method == 'POST' ) { | |
| 232 | + | |
| 233 | + $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this ); | |
| 312 | 234 | |
| 313 | - // tokens are sent through here | |
| 314 | - $this->body_parameters = apply_filters( 'wpgetapi_body_parameters', $this->body_parameters, $this ); | |
| 315 | - | |
| 316 | - // do we json_encode the entire body | |
| 317 | - if( $this->body_json_encode == true ) { | |
| 235 | + // do we json_encode the entire body as a string | |
| 236 | + if( $this->body_json_encode === true || $this->body_json_encode === 'true' ) | |
| 318 | 237 | $this->body_parameters = json_encode( $this->body_parameters ); |
| 319 | - } | |
| 320 | 238 | |
| 321 | - // do we urlencode the entire body | |
| 322 | - if( $this->body_parameters && $this->body_url_encode == true ) { | |
| 323 | - | |
| 324 | - // checking if the parameters have a json string (raw) | |
| 325 | - if ( | |
| 326 | - ( ! is_array( $this->body_parameters ) ) && | |
| 327 | - ( substr( $this->body_parameters, 0, 1 ) === '{' || substr( $this->body_parameters, 0, 1 ) === '[' ) | |
| 328 | - ) { | |
| 329 | - $this->body_parameters = json_decode( $this->body_parameters, true ); | |
| 330 | - } | |
| 331 | - | |
| 332 | - $this->body_parameters = http_build_query( $this->body_parameters, '', '&' ); | |
| 239 | + // add our body parameters | |
| 240 | + $headers['headers']['body'] = $this->body_parameters; | |
| 333 | 241 | |
| 334 | - } | |
| 335 | - | |
| 336 | - // do we xml the entire body | |
| 337 | - if( $this->body_parameters && $this->body_xml_format == true ) { | |
| 338 | - | |
| 339 | - $root_node = $this->xml_root_node != '' ? '<' . $this->xml_root_node . '/>' : ''; | |
| 340 | - | |
| 341 | - $xml_element = apply_filters( 'wpgetapi_xml_element', '<?xml version="1.0" encoding="UTF-8"?>' . $root_node ); | |
| 342 | - | |
| 343 | - $xml = new SimpleXmlElement( $xml_element ); | |
| 344 | - | |
| 345 | - foreach( $this->body_parameters as $key => $value) { | |
| 346 | - $xml->addChild( $key, $value ); | |
| 347 | - } | |
| 348 | - | |
| 349 | - $this->body_parameters = $xml->asXML(); | |
| 350 | - | |
| 351 | - } | |
| 352 | - | |
| 353 | - // do we base64 encode the entire body | |
| 354 | - if( $this->body_parameters && $this->body_base64_encode == true ) { | |
| 355 | - | |
| 356 | - $this->body_parameters = is_array( $this->body_parameters ) ? json_encode( $this->body_parameters ) : $this->body_parameters; | |
| 357 | - $this->body_parameters = base64_encode( $this->body_parameters ); | |
| 358 | - | |
| 359 | - } | |
| 360 | - | |
| 361 | - $this->body_parameters = apply_filters( 'wpgetapi_modify_formatted_body_parameters', $this->body_parameters, $this ); | |
| 362 | - | |
| 363 | - // add our body parameters | |
| 364 | - if( $this->body_parameters && ! empty( $this->body_parameters ) ) | |
| 365 | - $headers['body'] = $this->body_parameters; | |
| 366 | - | |
| 367 | 242 | } |
| 368 | 243 | |
| 369 | - // get our body paramters as they are formatted | |
| 370 | - // this won't change anything, it just allows us to get the parameters | |
| 371 | - $this->body_parameters = apply_filters( 'wpgetapi_final_body_parameters', $this->body_parameters, $this ); | |
| 372 | - | |
| 373 | 244 | // add headers to our final request args |
| 374 | 245 | $this->final_request_args = wp_parse_args( $headers, $this->final_request_args ); |
| 375 | 246 | |
| 376 | 247 | // build the args taht are sent to the request |
| 377 | 248 | $default_args = apply_filters( 'wpgetapi_default_request_args_parameters', array( |
| 378 | - 'timeout' => ( absint( $this->timeout ) > 0 ? absint( $this->timeout ) : 10 ), | |
| 249 | + 'timeout' => $this->timeout, | |
| 379 | 250 | 'sslverify' => $this->sslverify, |
| 380 | 251 | 'redirection' => 5, |
| 381 | 252 | 'blocking' => true, |
| 382 | 253 | 'cookies' => array(), |
| @@ -386,236 +257,50 @@ | ||
| 386 | 257 | |
| 387 | 258 | } |
| 388 | 259 | |
| 389 | 260 | |
| 390 | - | |
| 391 | - | |
| 392 | 261 | /** |
| 393 | 262 | * Do a GET request |
| 394 | 263 | */ |
| 395 | 264 | public function GET_request() { |
| 396 | - | |
| 397 | 265 | $response = ''; |
| 398 | 266 | // so we can so something before the remote_get (caching) |
| 399 | 267 | $response = apply_filters( 'wpgetapi_before_get_request', $response, $this ); |
| 400 | - | |
| 401 | 268 | if( empty( $response ) ) |
| 402 | 269 | $response = wp_remote_get( $this->final_url, $this->final_request_args ); |
| 403 | 270 | |
| 404 | 271 | return $response; |
| 272 | + } | |
| 405 | 273 | |
| 406 | - } | |
| 407 | 274 | |
| 408 | 275 | /** |
| 409 | 276 | * Do a POST request |
| 410 | 277 | */ |
| 411 | 278 | public function POST_request() { |
| 412 | - | |
| 413 | - $response = ''; | |
| 414 | - // so we can so something before the remote_post (caching) | |
| 415 | - $response = apply_filters( 'wpgetapi_before_post_request', $response, $this ); | |
| 416 | - | |
| 417 | - //$this->final_request_args['method'] = 'POST'; | |
| 418 | - | |
| 419 | - if( empty( $response ) ) | |
| 420 | - $response = wp_remote_post( $this->final_url, $this->final_request_args ); | |
| 421 | - | |
| 279 | + $response = wp_remote_post( $this->final_url, $this->final_request_args ); | |
| 422 | 280 | return $response; |
| 423 | 281 | } |
| 424 | 282 | |
| 425 | - /** | |
| 426 | - * Do a PUT request | |
| 427 | - */ | |
| 428 | - public function PUT_request() { | |
| 429 | - $this->final_request_args['method'] = 'PUT'; | |
| 430 | - $response = wp_remote_request( $this->final_url, $this->final_request_args ); | |
| 431 | - return $response; | |
| 432 | - } | |
| 433 | 283 | |
| 434 | 284 | /** |
| 435 | - * Do a PATCH request | |
| 285 | + * return JSON data | |
| 436 | 286 | */ |
| 437 | - public function PATCH_request() { | |
| 438 | - $this->final_request_args['method'] = 'PATCH'; | |
| 439 | - $response = wp_remote_request( $this->final_url, $this->final_request_args ); | |
| 440 | - return $response; | |
| 441 | - } | |
| 287 | + public function output_json( $data ) { | |
| 442 | 288 | |
| 443 | - /** | |
| 444 | - * Do a DELETE request | |
| 445 | - */ | |
| 446 | - public function DELETE_request() { | |
| 447 | - $this->final_request_args['method'] = 'DELETE'; | |
| 448 | - $response = wp_remote_request( $this->final_url, $this->final_request_args ); | |
| 449 | - return $response; | |
| 450 | - } | |
| 451 | - | |
| 452 | - | |
| 453 | - /** | |
| 454 | - * return data | |
| 455 | - */ | |
| 456 | - public function return_data( $data ) { | |
| 457 | - | |
| 458 | - $data = apply_filters( 'wpgetapi_json_response_body_before_decode', $data, $this->keys ); | |
| 459 | - | |
| 460 | 289 | // converts all data to arrays, removing objects |
| 461 | - if( is_string( $data ) ) { | |
| 462 | - $decode = json_decode( $data, true ); | |
| 463 | - if( json_last_error() ) { | |
| 464 | - return esc_html( $data ); | |
| 465 | - } else { | |
| 466 | - $data = $decode; | |
| 467 | - } | |
| 468 | - } | |
| 290 | + $data = json_decode( $data, true ); | |
| 291 | + $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys ); | |
| 469 | 292 | |
| 470 | - $data = apply_filters( 'wpgetapi_json_response_body', $data, $this->keys ); | |
| 471 | - | |
| 472 | 293 | if( $this->results_format == 'json_string' ) |
| 473 | - return trim( json_encode( $data, JSON_PRETTY_PRINT ),'"'); | |
| 474 | - | |
| 294 | + return trim( json_encode( $data ),'"'); | |
| 295 | + | |
| 475 | 296 | if( $this->results_format == 'json_decoded' ) |
| 476 | 297 | return $data; |
| 477 | 298 | |
| 478 | 299 | } |
| 479 | 300 | |
| 480 | - /** | |
| 481 | - * Sort out the parameters if they exist | |
| 482 | - */ | |
| 483 | - public function do_parameters( $parameters ) { | |
| 484 | 301 | |
| 485 | - $new_array = array(); | |
| 486 | - $raw = ''; | |
| 487 | - $parameters = $this->decrypt( $parameters ); | |
| 488 | - | |
| 489 | - if( is_array( $parameters ) ) { | |
| 490 | - foreach ( $parameters as $key => $parameter ) { | |
| 491 | - | |
| 492 | - if( ! empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) { | |
| 493 | - | |
| 494 | - $parameter['value'] = stripslashes( $parameter['value'] ); | |
| 495 | - | |
| 496 | - // if we have wpgetapi_on, delete it so we don't send to api | |
| 497 | - if( $parameter['name'] == 'wpgetapi_on' ) { | |
| 498 | - unset( $parameters[ $key ] ); | |
| 499 | - continue; | |
| 500 | - } | |
| 501 | - | |
| 502 | - // if we have item_key from api to posts plugin | |
| 503 | - // replace our keyword with the actual item_key value | |
| 504 | - if ( isset( $this->args['item_key'] ) && strpos( $parameter['value'], '(importer:item_key)' ) !== false ) { | |
| 505 | - $parameter['value'] = str_replace( '(importer:item_key)', $this->args['item_key'], $parameter['value'] ); | |
| 506 | - } | |
| 507 | - | |
| 508 | - $new_array[ sanitize_text_field( $parameter['name'] ) ] = $parameter['value']; | |
| 509 | - | |
| 510 | - // if we are sending raw body | |
| 511 | - } else if( empty( $parameter['name'] ) && ! empty( $parameter['value'] ) ) { | |
| 512 | - | |
| 513 | - $raw = stripslashes( $parameter['value'] ); | |
| 514 | - | |
| 515 | - } | |
| 516 | - | |
| 517 | - } | |
| 518 | - } | |
| 519 | - | |
| 520 | - // now look for array or json string and sort these out - for using such things in shortcode | |
| 521 | - if( ! empty( $new_array ) ) { | |
| 522 | - | |
| 523 | - foreach ( $new_array as $key => $value ) { | |
| 524 | - | |
| 525 | - // checking if the parameters have a json string | |
| 526 | - if ( strpos( $value, '{"' ) !== false && strpos( $value, '}' ) !== false ) { | |
| 527 | - | |
| 528 | - $tmp_val = $value; | |
| 529 | - $tmp_val = json_decode( $tmp_val, true ); | |
| 530 | - $new_array[ $key ] = $tmp_val ? $tmp_val : $value; | |
| 531 | - | |
| 532 | - } else | |
| 533 | - | |
| 534 | - // checking if the parameters have an array within the string | |
| 535 | - // if they do, create them as an actual array | |
| 536 | - if ( substr( $value, 0, 1 ) === '[' && substr( $value, -1 ) === ']' ) { | |
| 537 | - $value = trim( $value,"[]" ); | |
| 538 | - $new_array[ $key ] = array( $value ); | |
| 539 | - } | |
| 540 | - | |
| 541 | - // set value as integer | |
| 542 | - if ( strpos( $value, 'integer(' ) !== false && substr( $value, -1 ) === ')' ) { | |
| 543 | - | |
| 544 | - preg_match("/\(([^\)]*)\)/", $value, $match ); | |
| 545 | - $result = trim( $match[1] ); | |
| 546 | - | |
| 547 | - // checking if we have additional token within | |
| 548 | - // and we need to send this directly to PRO plugin from here | |
| 549 | - if( strpos( $value, '(' ) !== false && strpos( $value, ':' ) !== false && $this->pro_plugin ) { | |
| 550 | - $result = $this->replace_tokens( $result ); | |
| 551 | - } else { | |
| 552 | - $result = $result; | |
| 553 | - } | |
| 554 | - | |
| 555 | - $new_array[ $key ] = absint( $result ); | |
| 556 | - | |
| 557 | - } | |
| 558 | - | |
| 559 | - // set value as float | |
| 560 | - if ( strpos( $value, 'float(' ) !== false && substr( $value, -1 ) === ')' ) { | |
| 561 | - | |
| 562 | - preg_match("/\(([^\)]*)\)/", $value, $match ); | |
| 563 | - $result = trim( $match[1] ); | |
| 564 | - if ( substr( $result, 0, 1 ) === '"' && substr( $result, -1 ) === '"' ) | |
| 565 | - $result = trim( $result,'""' ); | |
| 566 | - | |
| 567 | - // checking if we have additional token within | |
| 568 | - // and we need to send this directly to PRO plugin from here | |
| 569 | - if( strpos( $value, '(' ) !== false && strpos( $value, ':' ) !== false && $this->pro_plugin ) { | |
| 570 | - $result = $this->replace_tokens( $result ); | |
| 571 | - } | |
| 572 | - | |
| 573 | - $new_array[ $key ] = (float) $result; | |
| 574 | - | |
| 575 | - } | |
| 576 | - | |
| 577 | - // set value as boolean | |
| 578 | - if ( strpos( $value, 'boolean(' ) !== false && substr( $value, -1 ) === ')' ) { | |
| 579 | - preg_match("/\(([^\)]*)\)/", $value, $match ); | |
| 580 | - $result = $match[1]; | |
| 581 | - | |
| 582 | - // checking if we have additional token within | |
| 583 | - // and we need to send this directly to PRO plugin from here | |
| 584 | - if( strpos( $value, '(' ) !== false && strpos( $value, ':' ) !== false && $this->pro_plugin ) { | |
| 585 | - $result = $this->replace_tokens( $result ); | |
| 586 | - } else { | |
| 587 | - $result = $result; | |
| 588 | - } | |
| 589 | - | |
| 590 | - $result = filter_var( $result, FILTER_VALIDATE_BOOLEAN ); | |
| 591 | - | |
| 592 | - $new_array[ $key ] = $result; | |
| 593 | - | |
| 594 | - } | |
| 595 | - | |
| 596 | - } | |
| 597 | - | |
| 598 | - } | |
| 599 | - | |
| 600 | - return $raw ? $raw : $new_array; | |
| 601 | - | |
| 602 | - } | |
| 603 | - | |
| 604 | - | |
| 605 | 302 | /** |
| 606 | - * Do a direct token replacement if PRO plugin installed and is required. | |
| 607 | - */ | |
| 608 | - public function replace_tokens( $value ) { | |
| 609 | - $tokens = new WpGetApi_Extras_Tokens(); | |
| 610 | - $action_args = isset( $this->args['action_args'] ) ? $this->args['action_args'] : null; | |
| 611 | - $value = ( substr( $value, -1 ) !== ')' ? $value . ')' : $value ); | |
| 612 | - $result = $tokens->replace_tokens( $value, $action_args ); | |
| 613 | - return $result; | |
| 614 | - } | |
| 615 | - | |
| 616 | - | |
| 617 | - /** | |
| 618 | 303 | * decrypt our parameters from the DB |
| 619 | 304 | */ |
| 620 | 305 | public function decrypt( $array_or_string ) { |
| 621 | 306 | |
| @@ -640,187 +325,126 @@ | ||
| 640 | 325 | |
| 641 | 326 | /** |
| 642 | 327 | * debug |
| 643 | 328 | */ |
| 644 | - public function maybe_add_debug_info( $data, $wpgetapi ) { | |
| 329 | + public function maybe_add_debug_info( $data, $this_data ) { | |
| 645 | 330 | |
| 646 | - if( | |
| 647 | - ( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) || | |
| 648 | - ( isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ) | |
| 649 | - ) { | |
| 331 | + if( isset( $this->args['debug'] ) && ( $this->args['debug'] === true || $this->args['debug'] === 'true' ) ) { | |
| 650 | 332 | |
| 651 | - $this->debug = true; | |
| 652 | - | |
| 653 | - // admin test endpoint button | |
| 654 | - $testing = isset( $this->args['test_endpoint'] ) && ( $this->args['test_endpoint'] === true ) ? true : false; | |
| 655 | - | |
| 656 | - // get api status from response code | |
| 657 | - $status = array( | |
| 658 | - 'title' => 'Error in API response.', | |
| 659 | - 'desc' => 'Check all details within your endpoint. Something is misconfigured.', | |
| 660 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 661 | - ); | |
| 662 | - | |
| 663 | - $search = 'cURL error 28'; | |
| 664 | - if( isset( $data ) && ! is_array( $data ) && preg_match( "/{$search}/i", $data ) ) { | |
| 665 | - $status = array( | |
| 666 | - 'title' => 'Error!', | |
| 667 | - 'desc' => 'Timeout error. Try increasing the timeout value.', | |
| 668 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 669 | - ); | |
| 670 | - } | |
| 671 | - | |
| 672 | - $search = 'cURL error 60'; | |
| 673 | - if( isset( $data ) && ! is_array( $data ) && preg_match( "/{$search}/i", $data ) ) { | |
| 674 | - $status = array( | |
| 675 | - 'title' => 'Error!', | |
| 676 | - 'desc' => 'SSL verification has failed. See <a href="https://wordpress.stackexchange.com/a/167910/11827" target="_blank">here</a> for possible solution.', | |
| 677 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 678 | - ); | |
| 679 | - } | |
| 680 | - | |
| 681 | - if( $this->response_code >= 200 && $this->response_code <= 299 ) { | |
| 682 | - $status = array( | |
| 683 | - 'title' => 'Success!', | |
| 684 | - 'desc' => 'Your API is returning a success message and is returning the data as shown in the Data Output section below. You can modify this by changing the Results Format option or see <a href="https://wpgetapi.com/docs/format-api-data-as-html/">here</a> for info on formatting this data.', | |
| 685 | - 'type' => '<span class="dashicons dashicons-yes-alt"></span>' | |
| 686 | - ); | |
| 687 | - } | |
| 688 | - if( $this->response_code >= 400 && $this->response_code <= 499 ) { | |
| 689 | - $status = array( | |
| 690 | - 'title' => 'Bad Request', | |
| 691 | - 'desc' => 'This could indicate that the URL you are calling is incorrect or that some other data is missing or incorrect. Please check your Base URL and Endpoint are correct as well as the Request Method.', | |
| 692 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 693 | - ); | |
| 694 | - } | |
| 695 | - if( $this->response_code == 401 ) { | |
| 696 | - $status = array( | |
| 697 | - 'title' => 'Unauthorised', | |
| 698 | - 'desc' => 'You are successfully connecting to your API. But your API key, login or API credentials are incorrect. See <a href="https://wpgetapi.com/docs/authentication-authorization/">here</a> for info on correctly authorizing your API requests.', | |
| 699 | - 'type' => '<span class="dashicons dashicons-warning"></span>' | |
| 700 | - ); | |
| 701 | - } | |
| 702 | - if( $this->response_code == 403 ) { | |
| 703 | - $status = array( | |
| 704 | - 'title' => 'Forbidden', | |
| 705 | - 'desc' => 'This could indicate that you may need to get your IP address whitelisted with your API provider or that you do not have access to this API.', | |
| 706 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 707 | - ); | |
| 708 | - } | |
| 709 | - if( $this->response_code == 405 ) { | |
| 710 | - $status = array( | |
| 711 | - 'title' => 'Method Not Allowed', | |
| 712 | - 'desc' => 'Try changing the Request Method within the endpoint settings.', | |
| 713 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 714 | - ); | |
| 715 | - } | |
| 716 | - if( $this->response_code == 415 ) { | |
| 717 | - $status = array( | |
| 718 | - 'title' => 'Unsupported Media Type', | |
| 719 | - 'desc' => 'Try adding "Content-type" to the Headers with the Value of "json/application" as shown <a href="https://wpgetapi.com/docs/troubleshooting/">here</a>.', | |
| 720 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 721 | - ); | |
| 722 | - } | |
| 723 | - if( $this->response_code >= 500 && $this->response_code <= 599 ) { | |
| 724 | - $status = array( | |
| 725 | - 'title' => 'Internal Server Error', | |
| 726 | - 'desc' => 'This indicates an issue with the API server. Contact your API provider.', | |
| 727 | - 'type' => '<span class="dashicons dashicons-dismiss"></span>' | |
| 728 | - ); | |
| 729 | - } | |
| 730 | - | |
| 731 | - | |
| 732 | 333 | ob_start(); ?> |
| 733 | 334 | |
| 734 | - <div class="wpgetapi-debug <?php echo $testing ? 'testing' : ''; ?>"> | |
| 735 | - | |
| 736 | - <?php if( $testing ) { ?> | |
| 335 | +<style> | |
| 737 | 336 | |
| 738 | - <div class="debug-item status"> | |
| 739 | - <div class=""> | |
| 740 | - <h5><?php _e( $status['type'] ); ?> <?php esc_html_e( $status['title'] ); ?></h5> | |
| 741 | - <span class="desc"><?php _e( $status['desc'] ); ?></span> | |
| 742 | - </div> | |
| 743 | - </div> | |
| 744 | - <div class="debug-item"> | |
| 745 | - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6> | |
| 746 | - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p> | |
| 747 | - <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div> | |
| 748 | - </div> | |
| 337 | +.wpgetapi-debug { | |
| 338 | + background: #f4f4f4; | |
| 339 | + padding: 20px; | |
| 340 | + border: 1px solid #ccc; | |
| 341 | + margin: 20px; | |
| 342 | + font-size: 15px; | |
| 343 | +} | |
| 344 | +.wpgetapi-debug | |
| 345 | +.wpgetapi-debug p | |
| 346 | +.wpgetapi-debug h5 | |
| 347 | +.wpgetapi-debug h6 { | |
| 348 | + color: #000; | |
| 349 | + line-height: 1 !important; | |
| 350 | + text-transform: none !important; | |
| 351 | + font-family: sans-serif !important; | |
| 352 | + letter-spacing: 0px !important; | |
| 353 | +} | |
| 354 | +.wpgetapi-debug p.small { | |
| 355 | + font-size: 85%; | |
| 356 | + color: #999; | |
| 357 | + margin-bottom: 15px !important | |
| 358 | +} | |
| 359 | +.wpgetapi-debug h5 { | |
| 360 | + font-weight: bold; | |
| 361 | + font-size: 18px; | |
| 362 | + margin: 0 0 3px; | |
| 363 | + text-transform: none !important; | |
| 364 | +} | |
| 365 | +.wpgetapi-debug .debug-item { | |
| 366 | + margin: 10px 0; | |
| 367 | + background: #fff; | |
| 368 | + padding: 15px 20px; | |
| 369 | + display: inline-block !important;; | |
| 370 | + width: 100% !important; | |
| 371 | + box-shadow: 0 0 5px rgba(0,0,0,0.1) | |
| 372 | +} | |
| 373 | +.wpgetapi-debug .debug-item h6 { | |
| 374 | + font-weight: bold; | |
| 375 | + font-size: 16px; | |
| 376 | + margin: 0 0 3px; | |
| 377 | + text-transform: none !important; | |
| 378 | +} | |
| 379 | +.wpgetapi-debug .debug-item .debug-result, | |
| 380 | +.wpgetapi-debug .debug-item .debug-result pre { | |
| 381 | + font-family: monospace !important; | |
| 382 | + font-size: 15px !important; | |
| 383 | + margin: 0 !important; | |
| 384 | + padding: 10px 12px; | |
| 385 | + background: #f8f8f8; | |
| 386 | +} | |
| 387 | +.wpgetapi-debug .debug-item .debug-result pre { | |
| 388 | + border: none; | |
| 389 | + padding: 5px | |
| 390 | +} | |
| 749 | 391 | |
| 750 | - <div class="debug-item"> | |
| 751 | - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6> | |
| 752 | - <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> | |
| 753 | - <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div> | |
| 754 | - </div> | |
| 392 | +</style> | |
| 755 | 393 | |
| 756 | - <div class="debug-item"> | |
| 757 | - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6> | |
| 758 | - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p> | |
| 759 | - <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div> | |
| 760 | - </div> | |
| 761 | - | |
| 762 | - <div class="debug-item"> | |
| 763 | - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6> | |
| 764 | - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p> | |
| 765 | - <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div> | |
| 766 | - </div> | |
| 394 | + <div class="wpgetapi-debug"> | |
| 767 | 395 | |
| 768 | - <?php } else { ?> | |
| 396 | + <h5><strong>WPGetAPI, Debug Mode - Plugin Version <?php esc_html_e( WpGetApi()->version ); ?></strong></h5> | |
| 397 | + <p class="small">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.<br>Connecting to API's can be tricky - if you require help, please see the <a target="_blank" href="https://wpgetapi.com/docs/">Documentation</a> and if you can't find the answer then please use the contact form on our <a target="_blank" title="Connect WordPress with external API" href="https://wpgetapi.com/">website</a> to get assistance.</p> | |
| 769 | 398 | |
| 770 | - <h5><strong><?php esc_html_e( 'WPGetAPI, Debug Mode - Plugin Version', 'wpgetapi' ); ?> <?php esc_html_e( WpGetApi()->version ); ?></strong></h5> | |
| 771 | - <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> | |
| 772 | - | |
| 773 | 399 | <div class="debug-item"> |
| 774 | - <h6><?php esc_html_e( 'Full URL', 'wpgetapi' ); ?></h6> | |
| 775 | - <p class="small"><?php esc_html_e( 'The full URL that is being called.', 'wpgetapi' ); ?></p> | |
| 400 | + <h6>Full URL</h6> | |
| 401 | + <p class="small">The full URL that is being called.</p> | |
| 776 | 402 | <div class="debug-result"><?php esc_html_e( $this->final_url ); ?></div> |
| 777 | 403 | </div> |
| 778 | 404 | |
| 779 | 405 | <div class="debug-item"> |
| 780 | - <h6><?php esc_html_e( 'Data Output', 'wpgetapi' ); ?></h6> | |
| 781 | - <p class="small"><?php esc_html_e( 'The resulting output that has been returned from the API.', 'wpgetapi' ); ?></p> | |
| 406 | + <h6>Data Output</h6> | |
| 407 | + <p class="small">The resulting output that has been returned from the API.</p> | |
| 782 | 408 | <div class="debug-result"><?php wpgetapi_pp( $data ); ?></div> |
| 783 | 409 | </div> |
| 784 | 410 | |
| 785 | 411 | <div class="debug-item"> |
| 786 | - <h6><?php esc_html_e( 'Query String', 'wpgetapi' ); ?></h6> | |
| 787 | - <p class="small"><?php esc_html_e( 'The query string parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p> | |
| 412 | + <h6>Arguments</h6> | |
| 413 | + <p class="small">The arguments set within your shortcode or template tag.</p> | |
| 414 | + <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div> | |
| 415 | + </div> | |
| 416 | + | |
| 417 | + <div class="debug-item"> | |
| 418 | + <h6>Query String</h6> | |
| 419 | + <p class="small">The query string parameters (if any) that you have set within the endpoint settings.</p> | |
| 788 | 420 | <div class="debug-result"><?php wpgetapi_pp( $this->query_parameters ); ?></div> |
| 789 | 421 | </div> |
| 790 | 422 | |
| 791 | 423 | <div class="debug-item"> |
| 792 | - <h6><?php esc_html_e( 'Headers', 'wpgetapi' ); ?></h6> | |
| 793 | - <p class="small"><?php esc_html_e( 'The header parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p> | |
| 424 | + <h6>Headers</h6> | |
| 425 | + <p class="small">The headers parameters (if any) that you have set within the endpoint settings.</p> | |
| 794 | 426 | <div class="debug-result"><?php wpgetapi_pp( $this->header_parameters ); ?></div> |
| 795 | 427 | </div> |
| 796 | 428 | |
| 797 | 429 | <div class="debug-item"> |
| 798 | - <h6><?php esc_html_e( 'Body', 'wpgetapi' ); ?></h6> | |
| 799 | - <p class="small"><?php esc_html_e( 'The body parameters (if any) that you have set within the endpoint settings.', 'wpgetapi' ); ?></p> | |
| 430 | + <h6>Body</h6> | |
| 431 | + <p class="small">The body parameters (if any) that you have set within the endpoint settings.</p> | |
| 800 | 432 | <div class="debug-result"><?php wpgetapi_pp( $this->body_parameters ); ?></div> |
| 801 | 433 | </div> |
| 802 | 434 | |
| 803 | 435 | <div class="debug-item"> |
| 804 | - <h6><?php esc_html_e( 'Final Request Arguments', 'wpgetapi' ); ?></h6> | |
| 805 | - <p class="small"><?php esc_html_e( 'The final request arguments sent in the API request. Includes headers and body arguments.', 'wpgetapi' ); ?></p> | |
| 436 | + <h6>Final Request Arguments</h6> | |
| 437 | + <p class="small">The final request arguments sent in the API request. Includes headers and body arguments.</p> | |
| 806 | 438 | <div class="debug-result"><?php wpgetapi_pp( $this->final_request_args ); ?></div> |
| 807 | 439 | </div> |
| 808 | 440 | |
| 809 | 441 | <div class="debug-item"> |
| 810 | - <h6><?php esc_html_e( 'Arguments', 'wpgetapi' ); ?></h6> | |
| 811 | - <p class="small"><?php esc_html_e( 'The arguments set within your shortcode or template tag.', 'wpgetapi' ); ?></p> | |
| 812 | - <div class="debug-result"><?php wpgetapi_pp( $this->args ); ?></div> | |
| 813 | - </div> | |
| 814 | - | |
| 815 | - <div class="debug-item"> | |
| 816 | - <h6><?php esc_html_e( 'Response', 'wpgetapi' ); ?></h6> | |
| 817 | - <p class="small"><?php esc_html_e( 'The full response from the API request.', 'wpgetapi' ); ?></p> | |
| 442 | + <h6>Response</h6> | |
| 443 | + <p class="small">The full response from the API request.</p> | |
| 818 | 444 | <div class="debug-result"><?php wpgetapi_pp( $this->response); ?></div> |
| 819 | 445 | </div> |
| 820 | 446 | |
| 821 | - <?php } ?> | |
| 822 | - | |
| 823 | 447 | </div> |
| 824 | 448 | |
| 825 | 449 | <?php |
| 826 | 450 | |
| @@ -830,9 +454,11 @@ | ||
| 830 | 454 | |
| 831 | 455 | return $data; |
| 832 | 456 | |
| 833 | 457 | } |
| 458 | + | |
| 459 | + | |
| 834 | 460 | |
| 835 | 461 | } |
| 836 | 462 | |
| 837 | 463 | |
| 838 | 464 | } |