Created
July 20, 2015 16:39
-
-
Save pascalknecht/106593e2ecb8d6384e50 to your computer and use it in GitHub Desktop.
Fix Woocommerce Translation Checkout Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('locale', 'localize_backend'); | |
function localize_backend( $locale ) { | |
// set langauge if user is in admin area | |
if( defined( 'WP_ADMIN' ) || ( isset( $_REQUEST['pwd'] ) && isset( $_REQUEST['kau-boys_backend_localization_language'] ) ) ){ | |
// ajax call from frontend | |
if ( 'admin-ajax.php' == basename( $_SERVER[ 'SCRIPT_FILENAME' ] ) && strpos( admin_url(), $_SERVER[ 'HTTP_REFERER' ] ) === false ) { | |
// if lang request param was set, change locale for AJAX response, else, don't overwrite locale (use frontend locale) | |
if ( isset($_COOKIE['lang'] ) ) { | |
$locale = $_COOKIE['lang']; | |
} | |
} | |
} | |
return $locale; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment