PluginProbe
Translation with DeepL API / 2.4.5
Translation with DeepL API v2.4.5
trunk 0.1.20180323 1.0 1.2.5.1 1.5.2.5 1.7.5 2.4.3.12 2.4.3.9 2.4.5
← All changes | client/deeplapi.class.php +14 -18 trunk2.4.5 View file →
@@ -1,6 +1,6 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2 +
3 3 abstract class DeepLApi extends DeepLData {
4 4 protected $endPoint = '';
5 5 protected $http_mode = '';
6 6 private $endPointURL = false;
@@ -165,10 +165,8 @@
165 165
166 166 $this->setCacheNames();
167 167 $this->result = false;
168 168
169 -
170 -
171 169 if ( $this->isCacheValid( $this->response_cache_file ) ) {
172 170 $this->response_type = 'cache';
173 171 $this->why_no_cache = false;
174 172 $this->result = file_get_contents( $this->response_cache_file );
@@ -279,10 +277,8 @@
279 277
280 278 }
281 279 $log_bits['response_length'] = strlen($this->result);
282 280
283 - //plouf( $this ); die('erorkez');
284 -
285 281 if ( $this->result ) {
286 282 $this->result = json_decode( $this->result );
287 283
288 284 $this->result = ( array ) $this->result;
@@ -315,9 +311,9 @@
315 311
316 312 public function getEndPointURL( $add_auth_key = false ) {
317 313
318 314
319 - $APIServer = DeepLConfiguration::getAPIServer();
315 + $APIServer = DeeplConfiguration::getAPIServer();
320 316 if ( !$this->endPointURL ) {
321 317 if ( $this->endPoint === '' ) {
322 318 $this->endPointURL = $APIServer;
323 319 }
@@ -351,9 +347,9 @@
351 347
352 348 $args['headers'] = $this->addHeaders( $args['headers'] );
353 349 $args['body'] = $this->buildBody( 'POST', $this->endPoint );
354 350
355 - //wpdeepl_debug_display( $args ,__METHOD__ . "args");
351 + //plouf( $args ,__METHOD__ . "args");
356 352
357 353 /*
358 354 $args['auth_key'] = $this->authKey;
359 355
@@ -376,9 +372,9 @@
376 372
377 373 $bits = array_merge( array( $remoteURL, 'POST' ), $args );
378 374 // unsafe
379 375 //wpdeepl_log( $bits, 'apiRequests');
380 -// wpdeepl_debug_display( $args, "args" );
376 +// plouf( $args, "args" );
381 377 /*
382 378 $exec = "curl -X POST '$remoteURL' \\\n";
383 379 foreach( $args['headers'] as $key => $value ) {
384 380 $exec .= "-H '$key: $value' \\\n";
@@ -386,28 +382,28 @@
386 382 foreach( $args['body'] as $key => $value ) {
387 383 $exec .= "-d '$value' \\\n";
388 384 }
389 385
390 - wpdeepl_debug_display( $exec );
386 + plouf( $exec );
391 387 $response = exec ( $exec );
392 - wpdeepl_debug_display( $response );
388 + plouf( $response );
393 389 die('okaz4a6e4a68e4a86e');
394 390 */
395 391
396 - //wpdeepl_debug_display( $args, $remoteURL ); die('68z4e6z48a68ee8aok');
392 + //plouf( $args, $remoteURL ); die('68z4e6z48a68ee8aok');
397 393
398 394 //$args['body'] = str_replace('target_lang=NO', 'target_lang=NB', $args['body'] );
399 395 $response = wp_remote_post( $remoteURL, $args );
400 - //wpdeepl_debug_display( $args, $remoteURL, " post request"); wpdeepl_debug_display( $response ); die('okesoezporjkezor');
396 + //plouf( $args, $remoteURL, " post request"); plouf( $response ); die('okesoezporjkezor');
401 397
402 -// wpdeepl_debug_display( $args, " args pour $remoteURL" ); wpdeepl_debug_display( $response, "zeirjzpeijrpizerjpirj" ); die('okaze6aze44e');
403 - //wpdeepl_debug_display( $args, "args");
398 +// plouf( $args, " args pour $remoteURL" ); plouf( $response, "zeirjzpeijrpizerjpirj" ); die('okaze6aze44e');
399 + //plouf( $args, "args");
404 400
405 -// wpdeepl_debug_display( $args, "POST request to $remoteURL ");die('okaz5ea5zea4e');
401 +// plouf( $args, "POST request to $remoteURL ");die('okaz5ea5zea4e');
406 402
407 403 if ( is_wp_error( $response ) ) {
408 404 $this->response = $response->get_error_message();
409 - wpdeepl_debug_display( $args, $this->getEndPointURL() );
405 + plouf( $args, $this->getEndPointURL() );
410 406 die( __METHOD__ );
411 407 }
412 408 else {
413 409 $this->response = $response;
@@ -447,12 +443,12 @@
447 443 $bits = array_merge( array( $remoteURL, 'GET' ), $args );
448 444 // unsafe
449 445 //wpdeepl_log( $bits, 'apiRequests');
450 446
451 -// wpdeepl_debug_display( $args, $remoteURL ); die('oazea4ze9684e84azek');
447 +// plouf( $args, $remoteURL ); die('oazea4ze9684e84azek');
452 448
453 449 $response = wp_remote_get( $remoteURL, $args );
454 - //wpdeepl_debug_display( $args, $remoteURL ); wpdeepl_debug_display( $response ); die('ok');
450 + //plouf( $args, $remoteURL ); plouf( $response ); die('ok');
455 451 if ( is_wp_error( $response ) ) {
456 452 $this->response = $response->get_error_message();
457 453 } else {
458 454 $this->response = $response;