PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 1.0.5
Translate and Go multilingual – Automatic AI translation – wpLingua v1.0.5
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
wplingua / inc / ob-callback / ajax.php

ajax.php in Translate and Go multilingual – Automatic AI translation – wpLingua 1.0.5, at inc/ob-callback/ajax.php

59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * wpLingua OB Callback function : AJAX
11 *
12 * @param string $output
13 * @return string
14 */
15 function wplng_ob_callback_ajax( $output ) {
16
17 if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
18 return $output;
19 }
20
21 $referer = sanitize_url( $_SERVER['HTTP_REFERER'] );
22
23 // Check if the referer is clean
24 if ( strtolower( esc_url_raw( $referer ) ) !== strtolower( $referer ) ) {
25 return $output;
26 }
27
28 global $wplng_request_uri;
29 $wplng_request_uri = wp_make_link_relative( $referer );
30
31 if ( ! wplng_url_is_translatable( $wplng_request_uri )
32 || wplng_get_language_website_id() === wplng_get_language_current_id()
33 ) {
34 return $output;
35 }
36
37 $output_translated = wplng_ob_callback_translate( $output );
38
39 // Print debug data in debug.log file
40 if ( true === WPLNG_LOG_AJAX_DEBUG ) {
41
42 $debug = array(
43 'title' => 'wpLingua AJAX debug',
44 'request_uri' => $wplng_request_uri,
45 'value' => $output,
46 'translated' => $output_translated,
47 );
48
49 error_log(
50 var_export(
51 $debug,
52 true
53 )
54 );
55 }
56
57 return $output_translated;
58 }
59