Changeset 3236569
- Timestamp:
- 02/07/2025 12:22:28 PM (12 months ago)
- Location:
- motionpoint-express
- Files:
-
- 6 edited
- 8 copied
-
tags/1.9 (copied) (copied from motionpoint-express/trunk)
-
tags/1.9/assets (copied) (copied from motionpoint-express/trunk/assets)
-
tags/1.9/assets/js/admin.js (modified) (1 diff)
-
tags/1.9/gpl-2.0.txt (copied) (copied from motionpoint-express/trunk/gpl-2.0.txt)
-
tags/1.9/inc (copied) (copied from motionpoint-express/trunk/inc)
-
tags/1.9/inc/admin.php (copied) (copied from motionpoint-express/trunk/inc/admin.php) (5 diffs)
-
tags/1.9/inc/frontend.php (copied) (copied from motionpoint-express/trunk/inc/frontend.php) (2 diffs)
-
tags/1.9/motionpoint-express.php (copied) (copied from motionpoint-express/trunk/motionpoint-express.php) (3 diffs)
-
tags/1.9/readme.txt (copied) (copied from motionpoint-express/trunk/readme.txt) (2 diffs)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/inc/admin.php (modified) (5 diffs)
-
trunk/inc/frontend.php (modified) (2 diffs)
-
trunk/motionpoint-express.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
motionpoint-express/tags/1.9/assets/js/admin.js
r3094569 r3236569 19 19 $debugInfoBtn.toggleClass('active'); 20 20 } ); 21 22 $('#MotionPointExpressTestConnectionBtn').on( 'click', function( e ) { 23 e.preventDefault(); 24 testConnection(); 25 } ); 21 26 }); 27 28 function testConnection() { 29 $('#MotionPointExpressTestConnectionBtn').attr('disabled', 'disabled'); 30 31 $.ajax({ 32 'type': 'post', 33 'dataType': 'json', 34 'url': MotionPointExpress.ajaxUrl, 35 'data': { 36 'action': MotionPointExpress.testConnectionAction, 37 'nonce': MotionPointExpress.testConnectionNonce, 38 } 39 }) 40 .done(function onDone( data ) { 41 console.log('onDone', { data }); 42 if (data.status) { 43 $('#MotionPointExpressConnectionStatus').removeClass('notice-error').addClass('notice-success'); 44 } else { 45 $('#MotionPointExpressConnectionStatus').removeClass('notice-success').addClass('notice-error'); 46 } 47 $('#MotionPointExpressConnectionStatus').show().html( data.message ); 48 }) 49 .fail(function onFail() { 50 console.log('onFail'); 51 $('#MotionPointExpressConnectionStatus').removeClass('notice-success').addClass('notice-error'); 52 $('#MotionPointExpressConnectionStatus').show().html( 'Unknown error occurred' ); 53 }) 54 .always(function onFail() { 55 $('#MotionPointExpressTestConnectionBtn').removeAttr('disabled'); 56 }) 57 ; 58 } 22 59 23 60 function updateCustomLocationVisibility() { -
motionpoint-express/tags/1.9/inc/admin.php
r3188804 r3236569 33 33 add_filter( 'plugin_action_links_' . motionpointexpress()->get_setting('basename'), array( $this, 'plugin_actions' ) ); 34 34 add_action( 'admin_notices', array( $this, 'admin_notices' ) ); 35 } 36 37 if ( is_admin() ) { 38 add_action( 'wp_ajax_motionpointexpress_test_connection', array( $this, 'ajax_test_connection' ) ); 35 39 } 36 40 } … … 157 161 } 158 162 163 $is_configured = ! empty( $project_settings['languages'] ) && ! empty( $config['project_code'] ); 159 164 160 165 $new_tab_link_icon = '<i aria-hidden="true" class="dashicons dashicons-external" style="text-decoration:none;"></i>'; … … 261 266 </tr> 262 267 <tr> 268 <th><?php esc_html_e( 'Connection testing', 'motionpoint-express' ) ?></th> 269 <td> 270 <a id="MotionPointExpressTestConnectionBtn" href="#" class="button button-primary"<?php echo $is_configured ? '' : ' disabled' ?>><?php esc_html_e( 'Test connection', 'motionpoint-express' ) ?></a> 271 <?php if ( ! $is_configured ) : ?> 272 <p><?php esc_html_e( 'Configure and save settings first before you can test your connection.', 'motionpoint-express' ) ?></p> 273 <?php else : ?> 274 <p id="MotionPointExpressConnectionStatus" class="notice" style="display: none;"></p> 275 <p><?php esc_html_e( 'Click to check if your connection works fine.', 'motionpoint-express' ) ?></p> 276 <?php endif; ?> 277 </td> 278 </tr> 279 <tr> 263 280 <th><?php esc_html_e( 'Floating language selector', 'motionpoint-express' ) ?></th> 264 281 <td> … … 268 285 <?php endforeach; ?> 269 286 </select> 270 <p><?php esc_html_e( 'Override project settings for the floating sidebar language selector or choose "Default" to leave it as it is.', ' easyling' ) ?></p>287 <p><?php esc_html_e( 'Override project settings for the floating sidebar language selector or choose "Default" to leave it as it is.', 'motionpoint-express' ) ?></p> 271 288 </td> 272 289 </tr> … … 357 374 wp_enqueue_style( 'motionpointexpress-admin', motionpointexpress()->get_setting('url') . 'assets/css/admin.css', array(), motionpointexpress()->get_setting('version'), 'all' ); 358 375 wp_enqueue_script( 'motionpointexpress-admin', motionpointexpress()->get_setting('url') . 'assets/js/admin.js', array( 'jquery' ), motionpointexpress()->get_setting('version'), true ); 376 wp_localize_script( 377 'motionpointexpress-admin', 378 'MotionPointExpress', 379 array( 380 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 381 'testConnectionNonce' => wp_create_nonce( 'motionpointexpress_test_connection' ), 382 'testConnectionAction' => 'motionpointexpress_test_connection', 383 ) 384 ); 359 385 } 386 } 387 388 389 /** 390 * Test connection of the configured project 391 */ 392 public function ajax_test_connection() { 393 try { 394 check_ajax_referer( 'motionpointexpress_test_connection', 'nonce' ); 395 396 $user_config = motionpointexpress()->get_user_config(); 397 398 $project_settings = motionpointexpress()->get_project_settings(); 399 if ( empty( $project_settings ) ) { 400 throw new Exception( __( 'Project settings are not saved yet', 'motionpoint-express' ), 1); 401 } 402 403 $subdir_locale_map = ! empty( $project_settings['subdir_locale_map'] ) ? $project_settings['subdir_locale_map'] : array(); 404 if ( empty( $subdir_locale_map ) ) { 405 throw new Exception( __( 'Languages are not configured', 'motionpoint-express' ), 1); 406 } 407 408 $location_host = $user_config['location_host'] === 'custom' ? $user_config['custom_location_host'] : $user_config['location_host']; 409 $location_host = ! empty( $location_host ) ? trim( $location_host ) : $location_host; 410 if ( empty( $location_host ) ) { 411 throw new Exception( __( 'MotionPoint Eexpress location is invalid', 'motionpoint-express' ), 1); 412 } 413 $locale_prefix = array_key_first( $subdir_locale_map ); 414 $locale = $subdir_locale_map[ $locale_prefix ]; 415 416 $result = motionpointexpress()->app_request( array( 417 'publishing_mode' => $user_config['publishing_mode'], 418 'locale' => $locale, 419 'project_code' => $user_config['project_code'], 420 'location_host' => $location_host, 421 'request_method' => 'GET', 422 'request_body' => null, 423 'request_uri' => "/{$locale_prefix}/", 424 ) ); 425 $response = $result['response']; 426 427 if ( is_wp_error( $response ) ) { 428 $error = sprintf( 429 __( 'Failed fetching %s, error: %s', 'motionpoint-express' ), 430 $result['proxy_url'], 431 $response->get_error_message() 432 ); 433 throw new Exception( $error, 1 ); 434 } 435 436 echo json_encode( array( 437 'result' => $result, 438 'status' => true, 439 'message' => sprintf( 440 __( 'Successfully fetched %s, response code %s', 'motionpoint-express' ), 441 $result['proxy_url'], 442 $response['response']['code'] 443 ), 444 ) ); 445 } catch (Exception $e) { 446 echo json_encode( array( 447 'status' => false, 448 'message' => $e->getMessage(), 449 ) ); 450 } 451 452 die(); 360 453 } 361 454 -
motionpoint-express/tags/1.9/inc/frontend.php
r3235656 r3236569 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.motionpointexpress.com";250 } else {251 // Proxy mode252 $proxy_host = "{$locale}-{$project_code}.{$location_host}";253 }254 255 256 // Prepare headers257 $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 args266 $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}";248 // if ( 'js' === $publishing_mode ) { 249 // $proxy_host = "{$locale}-{$project_code}-j.app.motionpointexpress.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 280 281 281 // Proxy request 282 $response = wp_remote_request( $proxy_url, $proxy_request_args ); 282 // $response = wp_remote_request( $proxy_url, $proxy_request_args ); 283 $result = motionpointexpress()->app_request( array( 284 'publishing_mode' => $publishing_mode, 285 'locale' => $locale, 286 'project_code' => $project_code, 287 'location_host' => $location_host, 288 'request_method' => $request_method, 289 'request_body' => $request_body, 290 'request_uri' => $server_request_uri, 291 ) ); 292 $response = $result['response']; 293 283 294 $response_body = ! is_wp_error( $response ) ? wp_remote_retrieve_body( $response ) : ''; 284 295 $response_body = is_wp_error( $response_body ) ? '' : $response_body; -
motionpoint-express/tags/1.9/motionpoint-express.php
r3235656 r3236569 4 4 Plugin URI: https://www.motionpointexpress.com/ 5 5 Description: MotionPoint Express website translation solution. 6 Version: 1. 86 Version: 1.9 7 7 Author: MotionPoint Express 8 8 Copyright: MotionPoint Express … … 82 82 private function __construct() { 83 83 $this->settings = array( 84 'version' => '1. 7',84 'version' => '1.9', 85 85 'path' => plugin_dir_path( __FILE__ ), 86 86 'url' => plugin_dir_url( __FILE__ ), … … 186 186 187 187 /** 188 * Performs request to the app server 189 */ 190 public function app_request( $params ) { 191 extract( $params ); // publishing_mode, locale, project_code, location_host, request_method, request_body, request_uri 192 193 $timeout = 180; 194 195 if ( 'js' === $publishing_mode ) { 196 $proxy_host = "{$locale}-{$project_code}-j.app.motionpointexpress.com"; 197 } else { 198 // Proxy mode 199 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 200 } 201 202 203 // Prepare headers 204 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 205 $headers['Origin'] = $http_host; 206 $headers['Host'] = $proxy_host; 207 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 208 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 209 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 210 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 211 212 // Prepare request args 213 $proxy_request_args = array( 214 'method' => $request_method, 215 'headers' => $headers, 216 'timeout' => $timeout, 217 'redirection' => 0, 218 ); 219 220 if ( ! empty( $request_body ) ) { 221 $proxy_request_args['body'] = $request_body; 222 } 223 224 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 225 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 226 $proxy_url = "{$request_scheme}://{$proxy_host}{$request_uri}"; 227 228 // Proxy request 229 set_time_limit( $timeout + 10 ); 230 231 return array( 232 'proxy_url' => $proxy_url, 233 'proxy_request_args' => $proxy_request_args, 234 'response' => wp_remote_request( $proxy_url, $proxy_request_args ), 235 ); 236 } 237 238 239 /** 188 240 * Initialize plugin 189 241 */ -
motionpoint-express/tags/1.9/readme.txt
r3235656 r3236569 4 4 Requires at least: 4.7 5 5 Tested up to: 6.7 6 Stable tag: 1. 86 Stable tag: 1.9 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 75 75 76 76 == Changelog == 77 = 1.9 = 78 Release Date: February 7th, 2025 79 80 Enhancements: 81 82 * Connection testing feature 83 77 84 = 1.8 = 78 85 Release Date: February 5th, 2025 -
motionpoint-express/trunk/assets/js/admin.js
r3094569 r3236569 19 19 $debugInfoBtn.toggleClass('active'); 20 20 } ); 21 22 $('#MotionPointExpressTestConnectionBtn').on( 'click', function( e ) { 23 e.preventDefault(); 24 testConnection(); 25 } ); 21 26 }); 27 28 function testConnection() { 29 $('#MotionPointExpressTestConnectionBtn').attr('disabled', 'disabled'); 30 31 $.ajax({ 32 'type': 'post', 33 'dataType': 'json', 34 'url': MotionPointExpress.ajaxUrl, 35 'data': { 36 'action': MotionPointExpress.testConnectionAction, 37 'nonce': MotionPointExpress.testConnectionNonce, 38 } 39 }) 40 .done(function onDone( data ) { 41 console.log('onDone', { data }); 42 if (data.status) { 43 $('#MotionPointExpressConnectionStatus').removeClass('notice-error').addClass('notice-success'); 44 } else { 45 $('#MotionPointExpressConnectionStatus').removeClass('notice-success').addClass('notice-error'); 46 } 47 $('#MotionPointExpressConnectionStatus').show().html( data.message ); 48 }) 49 .fail(function onFail() { 50 console.log('onFail'); 51 $('#MotionPointExpressConnectionStatus').removeClass('notice-success').addClass('notice-error'); 52 $('#MotionPointExpressConnectionStatus').show().html( 'Unknown error occurred' ); 53 }) 54 .always(function onFail() { 55 $('#MotionPointExpressTestConnectionBtn').removeAttr('disabled'); 56 }) 57 ; 58 } 22 59 23 60 function updateCustomLocationVisibility() { -
motionpoint-express/trunk/inc/admin.php
r3188804 r3236569 33 33 add_filter( 'plugin_action_links_' . motionpointexpress()->get_setting('basename'), array( $this, 'plugin_actions' ) ); 34 34 add_action( 'admin_notices', array( $this, 'admin_notices' ) ); 35 } 36 37 if ( is_admin() ) { 38 add_action( 'wp_ajax_motionpointexpress_test_connection', array( $this, 'ajax_test_connection' ) ); 35 39 } 36 40 } … … 157 161 } 158 162 163 $is_configured = ! empty( $project_settings['languages'] ) && ! empty( $config['project_code'] ); 159 164 160 165 $new_tab_link_icon = '<i aria-hidden="true" class="dashicons dashicons-external" style="text-decoration:none;"></i>'; … … 261 266 </tr> 262 267 <tr> 268 <th><?php esc_html_e( 'Connection testing', 'motionpoint-express' ) ?></th> 269 <td> 270 <a id="MotionPointExpressTestConnectionBtn" href="#" class="button button-primary"<?php echo $is_configured ? '' : ' disabled' ?>><?php esc_html_e( 'Test connection', 'motionpoint-express' ) ?></a> 271 <?php if ( ! $is_configured ) : ?> 272 <p><?php esc_html_e( 'Configure and save settings first before you can test your connection.', 'motionpoint-express' ) ?></p> 273 <?php else : ?> 274 <p id="MotionPointExpressConnectionStatus" class="notice" style="display: none;"></p> 275 <p><?php esc_html_e( 'Click to check if your connection works fine.', 'motionpoint-express' ) ?></p> 276 <?php endif; ?> 277 </td> 278 </tr> 279 <tr> 263 280 <th><?php esc_html_e( 'Floating language selector', 'motionpoint-express' ) ?></th> 264 281 <td> … … 268 285 <?php endforeach; ?> 269 286 </select> 270 <p><?php esc_html_e( 'Override project settings for the floating sidebar language selector or choose "Default" to leave it as it is.', ' easyling' ) ?></p>287 <p><?php esc_html_e( 'Override project settings for the floating sidebar language selector or choose "Default" to leave it as it is.', 'motionpoint-express' ) ?></p> 271 288 </td> 272 289 </tr> … … 357 374 wp_enqueue_style( 'motionpointexpress-admin', motionpointexpress()->get_setting('url') . 'assets/css/admin.css', array(), motionpointexpress()->get_setting('version'), 'all' ); 358 375 wp_enqueue_script( 'motionpointexpress-admin', motionpointexpress()->get_setting('url') . 'assets/js/admin.js', array( 'jquery' ), motionpointexpress()->get_setting('version'), true ); 376 wp_localize_script( 377 'motionpointexpress-admin', 378 'MotionPointExpress', 379 array( 380 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 381 'testConnectionNonce' => wp_create_nonce( 'motionpointexpress_test_connection' ), 382 'testConnectionAction' => 'motionpointexpress_test_connection', 383 ) 384 ); 359 385 } 386 } 387 388 389 /** 390 * Test connection of the configured project 391 */ 392 public function ajax_test_connection() { 393 try { 394 check_ajax_referer( 'motionpointexpress_test_connection', 'nonce' ); 395 396 $user_config = motionpointexpress()->get_user_config(); 397 398 $project_settings = motionpointexpress()->get_project_settings(); 399 if ( empty( $project_settings ) ) { 400 throw new Exception( __( 'Project settings are not saved yet', 'motionpoint-express' ), 1); 401 } 402 403 $subdir_locale_map = ! empty( $project_settings['subdir_locale_map'] ) ? $project_settings['subdir_locale_map'] : array(); 404 if ( empty( $subdir_locale_map ) ) { 405 throw new Exception( __( 'Languages are not configured', 'motionpoint-express' ), 1); 406 } 407 408 $location_host = $user_config['location_host'] === 'custom' ? $user_config['custom_location_host'] : $user_config['location_host']; 409 $location_host = ! empty( $location_host ) ? trim( $location_host ) : $location_host; 410 if ( empty( $location_host ) ) { 411 throw new Exception( __( 'MotionPoint Eexpress location is invalid', 'motionpoint-express' ), 1); 412 } 413 $locale_prefix = array_key_first( $subdir_locale_map ); 414 $locale = $subdir_locale_map[ $locale_prefix ]; 415 416 $result = motionpointexpress()->app_request( array( 417 'publishing_mode' => $user_config['publishing_mode'], 418 'locale' => $locale, 419 'project_code' => $user_config['project_code'], 420 'location_host' => $location_host, 421 'request_method' => 'GET', 422 'request_body' => null, 423 'request_uri' => "/{$locale_prefix}/", 424 ) ); 425 $response = $result['response']; 426 427 if ( is_wp_error( $response ) ) { 428 $error = sprintf( 429 __( 'Failed fetching %s, error: %s', 'motionpoint-express' ), 430 $result['proxy_url'], 431 $response->get_error_message() 432 ); 433 throw new Exception( $error, 1 ); 434 } 435 436 echo json_encode( array( 437 'result' => $result, 438 'status' => true, 439 'message' => sprintf( 440 __( 'Successfully fetched %s, response code %s', 'motionpoint-express' ), 441 $result['proxy_url'], 442 $response['response']['code'] 443 ), 444 ) ); 445 } catch (Exception $e) { 446 echo json_encode( array( 447 'status' => false, 448 'message' => $e->getMessage(), 449 ) ); 450 } 451 452 die(); 360 453 } 361 454 -
motionpoint-express/trunk/inc/frontend.php
r3235656 r3236569 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.motionpointexpress.com";250 } else {251 // Proxy mode252 $proxy_host = "{$locale}-{$project_code}.{$location_host}";253 }254 255 256 // Prepare headers257 $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 args266 $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}";248 // if ( 'js' === $publishing_mode ) { 249 // $proxy_host = "{$locale}-{$project_code}-j.app.motionpointexpress.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 280 281 281 // Proxy request 282 $response = wp_remote_request( $proxy_url, $proxy_request_args ); 282 // $response = wp_remote_request( $proxy_url, $proxy_request_args ); 283 $result = motionpointexpress()->app_request( array( 284 'publishing_mode' => $publishing_mode, 285 'locale' => $locale, 286 'project_code' => $project_code, 287 'location_host' => $location_host, 288 'request_method' => $request_method, 289 'request_body' => $request_body, 290 'request_uri' => $server_request_uri, 291 ) ); 292 $response = $result['response']; 293 283 294 $response_body = ! is_wp_error( $response ) ? wp_remote_retrieve_body( $response ) : ''; 284 295 $response_body = is_wp_error( $response_body ) ? '' : $response_body; -
motionpoint-express/trunk/motionpoint-express.php
r3235656 r3236569 4 4 Plugin URI: https://www.motionpointexpress.com/ 5 5 Description: MotionPoint Express website translation solution. 6 Version: 1. 86 Version: 1.9 7 7 Author: MotionPoint Express 8 8 Copyright: MotionPoint Express … … 82 82 private function __construct() { 83 83 $this->settings = array( 84 'version' => '1. 7',84 'version' => '1.9', 85 85 'path' => plugin_dir_path( __FILE__ ), 86 86 'url' => plugin_dir_url( __FILE__ ), … … 186 186 187 187 /** 188 * Performs request to the app server 189 */ 190 public function app_request( $params ) { 191 extract( $params ); // publishing_mode, locale, project_code, location_host, request_method, request_body, request_uri 192 193 $timeout = 180; 194 195 if ( 'js' === $publishing_mode ) { 196 $proxy_host = "{$locale}-{$project_code}-j.app.motionpointexpress.com"; 197 } else { 198 // Proxy mode 199 $proxy_host = "{$locale}-{$project_code}.{$location_host}"; 200 } 201 202 203 // Prepare headers 204 $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); 205 $headers['Origin'] = $http_host; 206 $headers['Host'] = $proxy_host; 207 $headers['X-TranslationProxy-Cache-Info'] = 'disable'; 208 $headers['X-TranslationProxy-EnableDeepRoot'] = 'true'; 209 $headers['X-TranslationProxy-AllowRobots'] = 'true'; 210 $headers['X-TranslationProxy-ServingDomain'] = $http_host; 211 212 // Prepare request args 213 $proxy_request_args = array( 214 'method' => $request_method, 215 'headers' => $headers, 216 'timeout' => $timeout, 217 'redirection' => 0, 218 ); 219 220 if ( ! empty( $request_body ) ) { 221 $proxy_request_args['body'] = $request_body; 222 } 223 224 $request_scheme = ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? strtolower( sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) : strtolower( sanitize_text_field( $_SERVER['REQUEST_SCHEME'] ) ); 225 $request_scheme = in_array( $request_scheme, array( 'http', 'https' ) ) ? $request_scheme : 'https'; 226 $proxy_url = "{$request_scheme}://{$proxy_host}{$request_uri}"; 227 228 // Proxy request 229 set_time_limit( $timeout + 10 ); 230 231 return array( 232 'proxy_url' => $proxy_url, 233 'proxy_request_args' => $proxy_request_args, 234 'response' => wp_remote_request( $proxy_url, $proxy_request_args ), 235 ); 236 } 237 238 239 /** 188 240 * Initialize plugin 189 241 */ -
motionpoint-express/trunk/readme.txt
r3235656 r3236569 4 4 Requires at least: 4.7 5 5 Tested up to: 6.7 6 Stable tag: 1. 86 Stable tag: 1.9 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 75 75 76 76 == Changelog == 77 = 1.9 = 78 Release Date: February 7th, 2025 79 80 Enhancements: 81 82 * Connection testing feature 83 77 84 = 1.8 = 78 85 Release Date: February 5th, 2025
Note: See TracChangeset
for help on using the changeset viewer.