0

Random question but I can't work it out or find a solution. I need to find a way to change the WordPress "nonce" message.

I'd like to replace to replace "nonce" with "error" when it's output as a message. Here in the UK "nonce" is a common term for a child sex offender and I'm getting complaints.

Basically I just need a way so users never see the word "nonce" on the site. It's used in schools so the browser security means there are issues with caching and cookies so occasionally it does pop up.

7
  • have you enabled the British GB language translation or is it still using the default American?
    – Tom J Nowell
    Oct 5, 2021 at 15:36
  • Hey Tom, long time no speak! Will that change it? I've just defiend it in wp-congig: define('WPLANG', 'en_GB');
    – Paul
    Oct 5, 2021 at 15:37
  • I'm not sure but you'll need to download the language files too, that define will only make WP use it if it's present
    – Tom J Nowell
    Oct 5, 2021 at 15:47
  • 1
    nonce would be an uncharacteristically technical term for WP to use in an error message. Are you referring to WP core or a plugin?
    – vancoder
    Oct 5, 2021 at 16:34
  • 1
    fast search in core files and could not find the use of nonce as a word in a string which is being output to the user. Oct 5, 2021 at 17:03

1 Answer 1

0

I did a quick search in WordPress core files, for patterns like __(.*nonce and _e(.*nonce and didn't really find any. I also went ahead and did a search on core translation files for the word nonce and didn't find anything at all, so my guess is that you're looking at some error message, generated by a third-party WordPress plugin or theme.

If you're lucky, the developer of that plugin or theme included translation functions (__(), _e(), etc.) around those strings. This means you can change them with a language file, perhaps using an editor, such as Loco Translate, or maybe using the gettext filter.

If you're really lucky, the developer or a contributor may have already created an en_GB package for the plugin/theme which uses a different word. Then you don't really need to do anything, except set the language to UK English in your site Settings.

But chances are the strings are just hard-coded in the php/js files of these third-party products. In which case, your best bet is to reach out to them and ask nicely. If it's an actively maintained product, they'll probably just reword it, because "nonce" doesn't make sense unless you're a developer, regardless of the language. If it's not maintained, your only option is to dig through the files and replace the word in all public-facing strings, which might take a while if it's a complex plugin/theme.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.