Changeset 3236567
- Timestamp:
- 02/07/2025 12:20:31 PM (14 months ago)
- Location:
- easyling
- Files:
-
- 1 deleted
- 5 edited
- 12 copied
-
tags/2.3 (copied) (copied from easyling/trunk)
-
tags/2.3/assets (copied) (copied from easyling/trunk/assets)
-
tags/2.3/assets/.DS_Store (deleted)
-
tags/2.3/assets/css/admin.css (copied) (copied from easyling/trunk/assets/css/admin.css)
-
tags/2.3/assets/js/admin-menu.js (copied) (copied from easyling/trunk/assets/js/admin-menu.js)
-
tags/2.3/assets/js/admin.js (copied) (copied from easyling/trunk/assets/js/admin.js) (1 diff)
-
tags/2.3/easyling.php (copied) (copied from easyling/trunk/easyling.php) (3 diffs)
-
tags/2.3/gpl-2.0.txt (copied) (copied from easyling/trunk/gpl-2.0.txt)
-
tags/2.3/inc (copied) (copied from easyling/trunk/inc)
-
tags/2.3/inc/admin.php (copied) (copied from easyling/trunk/inc/admin.php) (4 diffs)
-
tags/2.3/inc/frontend.php (copied) (copied from easyling/trunk/inc/frontend.php) (2 diffs)
-
tags/2.3/inc/integration (copied) (copied from easyling/trunk/inc/integration)
-
tags/2.3/readme.txt (copied) (copied from easyling/trunk/readme.txt) (2 diffs)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/easyling.php (modified) (3 diffs)
-
trunk/inc/admin.php (modified) (4 diffs)
-
trunk/inc/frontend.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easyling/tags/2.3/assets/js/admin.js
r3098777 r3236567 19 19 $debugInfoBtn.toggleClass('active'); 20 20 } ); 21 22 $('#EasylingTestConnectionBtn').on( 'click', function( e ) { 23 e.preventDefault(); 24 testConnection(); 25 } ); 21 26 }); 27 28 function testConnection() { 29 $('#EasylingTestConnectionBtn').attr('disabled', 'disabled'); 30 31 $.ajax({ 32 'type': 'post', 33 'dataType': 'json', 34 'url': Easyling.ajaxUrl, 35 'data': { 36 'action': Easyling.testConnectionAction, 37 'nonce': Easyling.testConnectionNonce, 38 } 39 }) 40 .done(function onDone( data ) { 41 console.log('onDone', { data }); 42 if (data.status) { 43 $('#EasylingConnectionStatus').removeClass('notice-error').addClass('notice-success'); 44 } else { 45 $('#EasylingConnectionStatus').removeClass('notice-success').addClass('notice-error'); 46 } 47 $('#EasylingConnectionStatus').show().html( data.message ); 48 }) 49 .fail(function onFail() { 50 console.log('onFail'); 51 $('#EasylingConnectionStatus').removeClass('notice-success').addClass('notice-error'); 52 $('#EasylingConnectionStatus').show().html( 'Unknown error occurred' ); 53 }) 54 .always(function onFail() { 55 $('#EasylingTestConnectionBtn').removeAttr('disabled'); 56 }) 57 ; 58 } 22 59 23 60 function updateCustomLocationVisibility() { -
easyling/tags/2.3/easyling.php
r3235653 r3236567 4 4 Plugin URI: https://www.easyling.com/ 5 5 Description: One-click website translation solution from Easyling. 6 Version: 2. 26 Version: 2.3 7 7 Author: Easyling 8 8 Copyright: Easyling … … 80 80 private function __construct() { 81 81 $this->settings = array( 82 'version' => '2. 1',82 'version' => '2.3', 83 83 'path' => plugin_dir_path( __FILE__ ), 84 84 'url' => plugin_dir_url( __FILE__ ), … … 184 184 185 185 /** 186 * Performs request to the app server 187 */ 188 public function app_request( $params ) { 189 extract( $params ); // publishing_mode, locale, project_code, location_host, request_method, request_body, request_uri 190 191 $timeout = 180; 192 193 if ( 'js' === $publishing_mode ) { 194 $proxy_host = "{$locale}-{$project_code}-j.app.easyling.com"; 195 } else { 196 // Proxy mode 197 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 198 } 199 200 // Prepare headers 201 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 202 $headers['Origin'] = $http_host; 203 $headers['Host'] = $proxy_host; 204 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 205 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 206 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 207 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 208 209 // Prepare request args 210 $proxy_request_args = array( 211 'method' => $request_method, 212 'headers' => $headers, 213 'timeout' => $timeout, 214 'redirection' => 0, 215 ); 216 217 if ( ! empty( $request_body ) ) { 218 $proxy_request_args['body'] = $request_body; 219 } 220 221 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 222 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 223 $proxy_url = "{$request_scheme}://{$proxy_host}{$request_uri}"; 224 225 // Proxy request 226 set_time_limit( $timeout + 10 ); 227 228 return array( 229 'proxy_url' => $proxy_url, 230 'proxy_request_args' => $proxy_request_args, 231 'response' => wp_remote_request( $proxy_url, $proxy_request_args ), 232 ); 233 } 234 235 236 /** 186 237 * Initialize plugin 187 238 */ -
easyling/tags/2.3/inc/admin.php
r3188801 r3236567 32 32 add_action( 'admin_menu', array( $this, 'setup_menu' ) ); 33 33 add_filter( 'plugin_action_links_' . easyling()->get_setting('basename'), array( $this, 'plugin_actions' ) ); 34 } 35 36 if ( is_admin() ) { 37 add_action( 'wp_ajax_easyling_test_connection', array( $this, 'ajax_test_connection' ) ); 34 38 } 35 39 } … … 170 174 } 171 175 176 $is_configured = ! empty( $project_settings['languages'] ) && ! empty( $config['project_code'] ); 172 177 173 178 $new_tab_link_icon = '<i aria-hidden="true" class="dashicons dashicons-external" style="text-decoration:none;"></i>'; … … 274 279 </tr> 275 280 <tr> 281 <th><?php esc_html_e( 'Connection testing', 'easyling' ) ?></th> 282 <td> 283 <a id="EasylingTestConnectionBtn" href="#" class="button button-primary"<?php echo $is_configured ? '' : ' disabled' ?>><?php esc_html_e( 'Test connection', 'easyling' ) ?></a> 284 <?php if ( ! $is_configured ) : ?> 285 <p><?php esc_html_e( 'Configure and save settings first before you can test your connection.', 'easyling' ) ?></p> 286 <?php else : ?> 287 <p id="EasylingConnectionStatus" class="notice" style="display: none;"></p> 288 <p><?php esc_html_e( 'Click to check if your connection works fine.', 'easyling' ) ?></p> 289 <?php endif; ?> 290 </td> 291 </tr> 292 <tr> 276 293 <th><?php esc_html_e( 'Floating language selector', 'easyling' ) ?></th> 277 294 <td> … … 370 387 wp_enqueue_style( 'easyling-admin', easyling()->get_setting('url') . 'assets/css/admin.css', array(), easyling()->get_setting('version'), 'all' ); 371 388 wp_enqueue_script( 'easyling-admin', easyling()->get_setting('url') . 'assets/js/admin.js', array( 'jquery' ), easyling()->get_setting('version'), true ); 372 } 389 wp_localize_script( 390 'easyling-admin', 391 'Easyling', 392 array( 393 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 394 'testConnectionNonce' => wp_create_nonce( 'easyling_test_connection' ), 395 'testConnectionAction' => 'easyling_test_connection', 396 ) 397 ); 398 } 399 } 400 401 402 /** 403 * Test connection of the configured project 404 */ 405 public function ajax_test_connection() { 406 try { 407 check_ajax_referer( 'easyling_test_connection', 'nonce' ); 408 409 $user_config = easyling()->get_user_config(); 410 411 $project_settings = easyling()->get_project_settings(); 412 if ( empty( $project_settings ) ) { 413 throw new Exception( __( 'Project settings are not saved yet', 'easyling' ), 1); 414 } 415 416 $subdir_locale_map = ! empty( $project_settings['subdir_locale_map'] ) ? $project_settings['subdir_locale_map'] : array(); 417 if ( empty( $subdir_locale_map ) ) { 418 throw new Exception( __( 'Languages are not configured', 'easyling' ), 1); 419 } 420 421 $location_host = $user_config['location_host'] === 'custom' ? $user_config['custom_location_host'] : $user_config['location_host']; 422 $location_host = ! empty( $location_host ) ? trim( $location_host ) : $location_host; 423 if ( empty( $location_host ) ) { 424 throw new Exception( __( 'Easyling location is invalid', 'easyling' ), 1); 425 } 426 $locale_prefix = array_key_first( $subdir_locale_map ); 427 $locale = $subdir_locale_map[ $locale_prefix ]; 428 429 $result = easyling()->app_request( array( 430 'publishing_mode' => $user_config['publishing_mode'], 431 'locale' => $locale, 432 'project_code' => $user_config['project_code'], 433 'location_host' => $location_host, 434 'request_method' => 'GET', 435 'request_body' => null, 436 'request_uri' => "/{$locale_prefix}/", 437 ) ); 438 $response = $result['response']; 439 440 if ( is_wp_error( $response ) ) { 441 $error = sprintf( 442 __( 'Failed fetching %s, error: %s', 'easyling' ), 443 $result['proxy_url'], 444 $response->get_error_message() 445 ); 446 throw new Exception( $error, 1 ); 447 } 448 449 echo json_encode( array( 450 'result' => $result, 451 'status' => true, 452 'message' => sprintf( 453 __( 'Successfully fetched %s, response code %s', 'easyling' ), 454 $result['proxy_url'], 455 $response['response']['code'] 456 ), 457 ) ); 458 } catch (Exception $e) { 459 echo json_encode( array( 460 'status' => false, 461 'message' => $e->getMessage(), 462 ) ); 463 } 464 465 die(); 373 466 } 374 467 -
easyling/tags/2.3/inc/frontend.php
r3235653 r3236567 86 86 $has_language_prefix = ! empty( $language_subdirectories ) && preg_match( "#^/($language_subdirectories)(/|\?|$)#i", $server_request_uri, $language_subdirectory_matches ); 87 87 $language_subdirectory = $has_language_prefix && ! empty( $language_subdirectory_matches[1] ) ? $language_subdirectory_matches[1] : null; 88 $locale = ! empty( $ project_settings['subdir_locale_map'][ $language_subdirectory ] ) ? strtolower( $project_settings['subdir_locale_map'][ $language_subdirectory ] ) : '';88 $locale = ! empty( $subdir_locale_map[ $language_subdirectory ] ) ? strtolower( $subdir_locale_map[ $language_subdirectory ] ) : ''; 89 89 90 90 if ( ! empty( $has_language_prefix ) && preg_match( "#/{$language_subdirectory}/wp-admin#i", $server_request_uri ) ) { … … 246 246 // Non-bot request processing 247 247 248 if ( 'js' === $publishing_mode ) { 249 $proxy_host = "{$locale}-{$project_code}-j.app.easyling.com"; 250 } else { 251 // Proxy mode 252 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 253 } 254 255 256 // Prepare headers 257 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 258 $headers['Origin'] = $http_host; 259 $headers['Host'] = $proxy_host; 260 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 261 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 262 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 263 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 264 265 // Prepare request args 266 $proxy_request_args = array( 267 'method' => $request_method, 268 'headers' => $headers, 269 'timeout' => 180, 270 'redirection' => 0, 271 ); 272 273 if ( ! empty( $request_body ) ) { 274 $proxy_request_args['body'] = $request_body; 275 } 276 277 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 278 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 279 $proxy_url = "{$request_scheme}://{$proxy_host}{$server_request_uri}"; 280 281 // Proxy request 282 $response = wp_remote_request( $proxy_url, $proxy_request_args ); 248 $result = easyling()->app_request( array( 249 'publishing_mode' => $publishing_mode, 250 'locale' => $locale, 251 'project_code' => $project_code, 252 'location_host' => $location_host, 253 'request_method' => $request_method, 254 'request_body' => $request_body, 255 'request_uri' => $server_request_uri, 256 ) ); 257 $response = $result['response']; 283 258 $response_body = ! is_wp_error( $response ) ? wp_remote_retrieve_body( $response ) : ''; 284 259 $response_body = is_wp_error( $response_body ) ? '' : $response_body; -
easyling/tags/2.3/readme.txt
r3235653 r3236567 4 4 Requires at least: 4.7 5 5 Tested up to: 6.7 6 Stable tag: 2. 26 Stable tag: 2.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 44 44 45 45 == Changelog == 46 = 2.3 = 47 Release Date: February 7th, 2025 48 49 Enhancements: 50 51 * Connection testing feature 52 46 53 = 2.2 = 47 54 Release Date: February 5th, 2025 -
easyling/trunk/assets/js/admin.js
r3098777 r3236567 19 19 $debugInfoBtn.toggleClass('active'); 20 20 } ); 21 22 $('#EasylingTestConnectionBtn').on( 'click', function( e ) { 23 e.preventDefault(); 24 testConnection(); 25 } ); 21 26 }); 27 28 function testConnection() { 29 $('#EasylingTestConnectionBtn').attr('disabled', 'disabled'); 30 31 $.ajax({ 32 'type': 'post', 33 'dataType': 'json', 34 'url': Easyling.ajaxUrl, 35 'data': { 36 'action': Easyling.testConnectionAction, 37 'nonce': Easyling.testConnectionNonce, 38 } 39 }) 40 .done(function onDone( data ) { 41 console.log('onDone', { data }); 42 if (data.status) { 43 $('#EasylingConnectionStatus').removeClass('notice-error').addClass('notice-success'); 44 } else { 45 $('#EasylingConnectionStatus').removeClass('notice-success').addClass('notice-error'); 46 } 47 $('#EasylingConnectionStatus').show().html( data.message ); 48 }) 49 .fail(function onFail() { 50 console.log('onFail'); 51 $('#EasylingConnectionStatus').removeClass('notice-success').addClass('notice-error'); 52 $('#EasylingConnectionStatus').show().html( 'Unknown error occurred' ); 53 }) 54 .always(function onFail() { 55 $('#EasylingTestConnectionBtn').removeAttr('disabled'); 56 }) 57 ; 58 } 22 59 23 60 function updateCustomLocationVisibility() { -
easyling/trunk/easyling.php
r3235653 r3236567 4 4 Plugin URI: https://www.easyling.com/ 5 5 Description: One-click website translation solution from Easyling. 6 Version: 2. 26 Version: 2.3 7 7 Author: Easyling 8 8 Copyright: Easyling … … 80 80 private function __construct() { 81 81 $this->settings = array( 82 'version' => '2. 1',82 'version' => '2.3', 83 83 'path' => plugin_dir_path( __FILE__ ), 84 84 'url' => plugin_dir_url( __FILE__ ), … … 184 184 185 185 /** 186 * Performs request to the app server 187 */ 188 public function app_request( $params ) { 189 extract( $params ); // publishing_mode, locale, project_code, location_host, request_method, request_body, request_uri 190 191 $timeout = 180; 192 193 if ( 'js' === $publishing_mode ) { 194 $proxy_host = "{$locale}-{$project_code}-j.app.easyling.com"; 195 } else { 196 // Proxy mode 197 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 198 } 199 200 // Prepare headers 201 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 202 $headers['Origin'] = $http_host; 203 $headers['Host'] = $proxy_host; 204 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 205 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 206 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 207 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 208 209 // Prepare request args 210 $proxy_request_args = array( 211 'method' => $request_method, 212 'headers' => $headers, 213 'timeout' => $timeout, 214 'redirection' => 0, 215 ); 216 217 if ( ! empty( $request_body ) ) { 218 $proxy_request_args['body'] = $request_body; 219 } 220 221 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 222 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 223 $proxy_url = "{$request_scheme}://{$proxy_host}{$request_uri}"; 224 225 // Proxy request 226 set_time_limit( $timeout + 10 ); 227 228 return array( 229 'proxy_url' => $proxy_url, 230 'proxy_request_args' => $proxy_request_args, 231 'response' => wp_remote_request( $proxy_url, $proxy_request_args ), 232 ); 233 } 234 235 236 /** 186 237 * Initialize plugin 187 238 */ -
easyling/trunk/inc/admin.php
r3188801 r3236567 32 32 add_action( 'admin_menu', array( $this, 'setup_menu' ) ); 33 33 add_filter( 'plugin_action_links_' . easyling()->get_setting('basename'), array( $this, 'plugin_actions' ) ); 34 } 35 36 if ( is_admin() ) { 37 add_action( 'wp_ajax_easyling_test_connection', array( $this, 'ajax_test_connection' ) ); 34 38 } 35 39 } … … 170 174 } 171 175 176 $is_configured = ! empty( $project_settings['languages'] ) && ! empty( $config['project_code'] ); 172 177 173 178 $new_tab_link_icon = '<i aria-hidden="true" class="dashicons dashicons-external" style="text-decoration:none;"></i>'; … … 274 279 </tr> 275 280 <tr> 281 <th><?php esc_html_e( 'Connection testing', 'easyling' ) ?></th> 282 <td> 283 <a id="EasylingTestConnectionBtn" href="#" class="button button-primary"<?php echo $is_configured ? '' : ' disabled' ?>><?php esc_html_e( 'Test connection', 'easyling' ) ?></a> 284 <?php if ( ! $is_configured ) : ?> 285 <p><?php esc_html_e( 'Configure and save settings first before you can test your connection.', 'easyling' ) ?></p> 286 <?php else : ?> 287 <p id="EasylingConnectionStatus" class="notice" style="display: none;"></p> 288 <p><?php esc_html_e( 'Click to check if your connection works fine.', 'easyling' ) ?></p> 289 <?php endif; ?> 290 </td> 291 </tr> 292 <tr> 276 293 <th><?php esc_html_e( 'Floating language selector', 'easyling' ) ?></th> 277 294 <td> … … 370 387 wp_enqueue_style( 'easyling-admin', easyling()->get_setting('url') . 'assets/css/admin.css', array(), easyling()->get_setting('version'), 'all' ); 371 388 wp_enqueue_script( 'easyling-admin', easyling()->get_setting('url') . 'assets/js/admin.js', array( 'jquery' ), easyling()->get_setting('version'), true ); 372 } 389 wp_localize_script( 390 'easyling-admin', 391 'Easyling', 392 array( 393 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 394 'testConnectionNonce' => wp_create_nonce( 'easyling_test_connection' ), 395 'testConnectionAction' => 'easyling_test_connection', 396 ) 397 ); 398 } 399 } 400 401 402 /** 403 * Test connection of the configured project 404 */ 405 public function ajax_test_connection() { 406 try { 407 check_ajax_referer( 'easyling_test_connection', 'nonce' ); 408 409 $user_config = easyling()->get_user_config(); 410 411 $project_settings = easyling()->get_project_settings(); 412 if ( empty( $project_settings ) ) { 413 throw new Exception( __( 'Project settings are not saved yet', 'easyling' ), 1); 414 } 415 416 $subdir_locale_map = ! empty( $project_settings['subdir_locale_map'] ) ? $project_settings['subdir_locale_map'] : array(); 417 if ( empty( $subdir_locale_map ) ) { 418 throw new Exception( __( 'Languages are not configured', 'easyling' ), 1); 419 } 420 421 $location_host = $user_config['location_host'] === 'custom' ? $user_config['custom_location_host'] : $user_config['location_host']; 422 $location_host = ! empty( $location_host ) ? trim( $location_host ) : $location_host; 423 if ( empty( $location_host ) ) { 424 throw new Exception( __( 'Easyling location is invalid', 'easyling' ), 1); 425 } 426 $locale_prefix = array_key_first( $subdir_locale_map ); 427 $locale = $subdir_locale_map[ $locale_prefix ]; 428 429 $result = easyling()->app_request( array( 430 'publishing_mode' => $user_config['publishing_mode'], 431 'locale' => $locale, 432 'project_code' => $user_config['project_code'], 433 'location_host' => $location_host, 434 'request_method' => 'GET', 435 'request_body' => null, 436 'request_uri' => "/{$locale_prefix}/", 437 ) ); 438 $response = $result['response']; 439 440 if ( is_wp_error( $response ) ) { 441 $error = sprintf( 442 __( 'Failed fetching %s, error: %s', 'easyling' ), 443 $result['proxy_url'], 444 $response->get_error_message() 445 ); 446 throw new Exception( $error, 1 ); 447 } 448 449 echo json_encode( array( 450 'result' => $result, 451 'status' => true, 452 'message' => sprintf( 453 __( 'Successfully fetched %s, response code %s', 'easyling' ), 454 $result['proxy_url'], 455 $response['response']['code'] 456 ), 457 ) ); 458 } catch (Exception $e) { 459 echo json_encode( array( 460 'status' => false, 461 'message' => $e->getMessage(), 462 ) ); 463 } 464 465 die(); 373 466 } 374 467 -
easyling/trunk/inc/frontend.php
r3235653 r3236567 86 86 $has_language_prefix = ! empty( $language_subdirectories ) && preg_match( "#^/($language_subdirectories)(/|\?|$)#i", $server_request_uri, $language_subdirectory_matches ); 87 87 $language_subdirectory = $has_language_prefix && ! empty( $language_subdirectory_matches[1] ) ? $language_subdirectory_matches[1] : null; 88 $locale = ! empty( $ project_settings['subdir_locale_map'][ $language_subdirectory ] ) ? strtolower( $project_settings['subdir_locale_map'][ $language_subdirectory ] ) : '';88 $locale = ! empty( $subdir_locale_map[ $language_subdirectory ] ) ? strtolower( $subdir_locale_map[ $language_subdirectory ] ) : ''; 89 89 90 90 if ( ! empty( $has_language_prefix ) && preg_match( "#/{$language_subdirectory}/wp-admin#i", $server_request_uri ) ) { … … 246 246 // Non-bot request processing 247 247 248 if ( 'js' === $publishing_mode ) { 249 $proxy_host = "{$locale}-{$project_code}-j.app.easyling.com"; 250 } else { 251 // Proxy mode 252 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 253 } 254 255 256 // Prepare headers 257 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 258 $headers['Origin'] = $http_host; 259 $headers['Host'] = $proxy_host; 260 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 261 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 262 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 263 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 264 265 // Prepare request args 266 $proxy_request_args = array( 267 'method' => $request_method, 268 'headers' => $headers, 269 'timeout' => 180, 270 'redirection' => 0, 271 ); 272 273 if ( ! empty( $request_body ) ) { 274 $proxy_request_args['body'] = $request_body; 275 } 276 277 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 278 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 279 $proxy_url = "{$request_scheme}://{$proxy_host}{$server_request_uri}"; 280 281 // Proxy request 282 $response = wp_remote_request( $proxy_url, $proxy_request_args ); 248 $result = easyling()->app_request( array( 249 'publishing_mode' => $publishing_mode, 250 'locale' => $locale, 251 'project_code' => $project_code, 252 'location_host' => $location_host, 253 'request_method' => $request_method, 254 'request_body' => $request_body, 255 'request_uri' => $server_request_uri, 256 ) ); 257 $response = $result['response']; 283 258 $response_body = ! is_wp_error( $response ) ? wp_remote_retrieve_body( $response ) : ''; 284 259 $response_body = is_wp_error( $response_body ) ? '' : $response_body; -
easyling/trunk/readme.txt
r3235653 r3236567 4 4 Requires at least: 4.7 5 5 Tested up to: 6.7 6 Stable tag: 2. 26 Stable tag: 2.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 44 44 45 45 == Changelog == 46 = 2.3 = 47 Release Date: February 7th, 2025 48 49 Enhancements: 50 51 * Connection testing feature 52 46 53 = 2.2 = 47 54 Release Date: February 5th, 2025
Note: See TracChangeset
for help on using the changeset viewer.