Issue with gettext functions via admin-ajax.php in WordPress

58 Views Asked by At

I have set up a PHP filter in functions.php for the gettext filter.

This filter works nicely without any problems. However, if the same text that I change appears inside the AJAX call, there is no change, meaning my filter is not executed.

Here is simple example:

add_filter('gettext', function($translation, $text, $domain) {
    
    if($translation == 'Something') {
        $translation = 'Something new';
    }
    
    return $translation;
}, 20, 3);

Has anyone encountered a similar problem and found a solution?

0

There are 0 best solutions below