Edit plugin without hooks in functions.php

There is a filter you can use, but it is well hidden. Take a look at the WordPress function __. As you can see it calls another function, translate. And there it is, a filter called gettext. You can use it to intercept any (translated) text that is run through __.

Basically, what you do is overwrite the translation, which will be the same as the original text if no translation is available for the current language. Like this:

add_filter ('gettext','wpse305425_change_string',10,3);
function wpse305425_change_string ($translation, $text, $domain) {
    if ($text == 'I consent to ...') $translation = 'your text';
    return $translation;
    }

Leave a Comment