The gettext
filter can be used to change strings that use the gettext
functions.
add_filter( 'gettext', 'wpse_change_error_string', 10, 3 );
/**
* Translate text.
*
* @param string $translation Translated text.
* @param string $text Text to translate.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*
* @return string
*/
function wpse_change_error_string( $translation, $text, $domain ) {
// The 'default' text domain is reserved for the WP core. If no text domain
// is passed to a gettext function, the 'default' domain will be used.
if ( 'default' === $domain && 'That action is currently not allowed.' === $text ) {
$translation = "This is the modified version of the original string...";
}
return $translation;
}
Note: Fortunately, the WordPress core does not currently use the string That action is currently not allowed., so that message will not be undesirably changed using the code above. But, that would happen if the core did use that message. This is one reason why it’s important for plugins and themes to use their own unique text domain.
The gettext
family of functions (__()
, _e
, etc) should always be passed a text domain though. The exception to this rule is for the WordPress core, which doesn’t pass a text domain explicitly, but it still has one named default
.
I would contact the plugin’s authors and suggest that they add their own text domain to their gettext function calls.