It may seem completely counter-intuitive, but you must avoid using variables for your message text. Consider the following two examples:
_e('This is an Ok message', 'my-textdomain'); $msg = 'This never shows up on the radar'; _e($msg, 'my-textdomain');
As far as PHP syntax is concerned, both of those functions are properly formed. However, the second example causes problems down the road when we need to extract translatable messages into a dedicated language file. It's maddening, but the scraping tools rely on simple text parsing, not PHP parsing, so they don't attempt to figure out variable values. We will cover the Poedit application and creation language files momentarily, but for now, just make sure you are using literal strings in conjunction with the __()
and _e()
functions and not variables. Don't forget!
In conjunction with the basic "scrape-friendly" syntax, here are a handful of best-practices that WordPress recommends along with a few of our own:
Use regular, proper...