Skip to content

Instantly share code, notes, and snippets.

@pascalknecht
Created July 20, 2015 16:39
Show Gist options
  • Save pascalknecht/106593e2ecb8d6384e50 to your computer and use it in GitHub Desktop.
Save pascalknecht/106593e2ecb8d6384e50 to your computer and use it in GitHub Desktop.
Fix Woocommerce Translation Checkout Process
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