Skip to content

Instantly share code, notes, and snippets.

@andxbes
Last active September 1, 2023 13:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andxbes/3be83aa4a9064d2455445008e6ae29fb to your computer and use it in GitHub Desktop.
Save andxbes/3be83aa4a9064d2455445008e6ae29fb to your computer and use it in GitHub Desktop.
Отключение переводов на рест запросах в wordpress
<?php
add_filter('override_load_textdomain', function ($result, $domain, $mofile ) {
$url = urldecode($_SERVER["REQUEST_URI"]);
if (
(function_exists('is_ajax') && is_ajax())
|| str_contains($url, 'wp-json/')
|| str_contains($url, 'ap-api/')
) {
$result = true;
//error_log('отключаем переводы' .' ' . $domain );
}else{
//error_log('Перевод получен');
}
return $result;
},99,3);
@andxbes
Copy link
Author

andxbes commented Jun 9, 2022

И лучше всего его подключать из /wp-content/mu-plugins/optimize.php , так как данные плагины стартуют раньше остальных , ну и ко всему по умолчанию включены.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment