import_from_file($path); } add_action( 'plugins_loaded', __NAMESPACE__ . '\\init' ); /** * A fail-safe in case a transltion does not exist shows the default translation (English) * * @param $msgstr string Translated text (Usually starts with "payplug_") * @param $msgid string Text to translate (irrelevant because it is equal to $msgstr in this case) * @param $domain string the domain is always = "payplug" (filter "gettext_payplug" is only for payplug translation domain) * * @return string */ function wpdocs_translate_text($msgstr, $msgid, $domain) { $pattern = '/^payplug_.+/'; if (preg_match($pattern, $msgstr) === 1) { if(isset($GLOBALS["mo"]->entries[$msgstr])) return $GLOBALS["mo"]->entries[$msgstr]->translations[0]; } return $msgstr; } add_filter('gettext_payplug', __NAMESPACE__ . '\\wpdocs_translate_text', 10, 3);