Best practices

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 ...

Get WordPress 3 Plugin Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.