How to not translate specific ajax action
To exclude a specific ajax action from being translated, you can use the following filter in the example below:
// You can replace 'ajax_action_example' with the specific action that you want to exclude
add_filter('weglot_ajax_no_translate', 'custom_ajax_no_translate', 10, 1);
function custom_ajax_no_translate($ajax_action){
$ajax_action[] = 'ajax_action_example';
return $ajax_action;
}
You can also customize this filter if you want to exclude the translation of the action only on the original version, as shown in the example below:
add_filter('weglot_ajax_no_translate', 'custom_ajax_no_translate', 10, 1);
function custom_ajax_no_translate($ajax_action){
if( weglot_get_original_language() == weglot_get_current_language()){
$ajax_action[] = 'ajax_action_example';
}
return $ajax_action;
}
Example: Excluding the 'loadmore'
ajax action
'loadmore'
ajax actionadd_filter('weglot_ajax_no_translate', 'custom_ajax_no_translate', 10, 1);
function custom_ajax_no_translate($ajax_action){
$ajax_action[] = 'loadmore';
return $ajax_action;
}
Example: Excluding the 'et_fb_ajax_save'
ajax action
'et_fb_ajax_save'
ajax actionadd_filter('weglot_ajax_no_translate', 'custom_ajax_no_translate', 10, 1);
function custom_ajax_no_translate($ajax_action){
$ajax_action[] = 'et_fb_ajax_save';
return $ajax_action;
}
Last updated