Last active
September 1, 2023 13:32
-
-
Save andxbes/3be83aa4a9064d2455445008e6ae29fb to your computer and use it in GitHub Desktop.
Отключение переводов на рест запросах в wordpress
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
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
И лучше всего его подключать из /wp-content/mu-plugins/optimize.php , так как данные плагины стартуют раньше остальных , ну и ко всему по умолчанию включены.