O'Reilly logo

WordPress 3 Plugin Development Essentials by Everett Griffiths, Brian Bondari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required