Is it ok to use a function to output the text domain name in a wordpress theme

No, this is not okay. NO NO NO. Here’s my favourite Otto quote:

Inside all translation functions, no PHP variables are allowed in the
strings, for any reason, ever.

Otto explains this in more detail, but the simple way to say it is that translation calls are parsed, not executed . So your variable (let alone your function) may not be evaluated and the text-domain breaks.

So, you’re better off using a unique name like wpse241589 for your textdomain temporarily and do a search and replace once you have a better name.

Leave a Comment