[wp-hackers] Improving Plugin (and Theme) metadata

Stephen Rider wp-hackers at striderweb.com
Fri Jan 25 20:42:25 GMT 2008


On Jan 25, 2008, at 12:44 PM, Jennifer Hodgdon wrote:
>
> The plan would be:
>
> /*
>    Description: My great plugin that you need.
>
> (rest of header)
> */
>
> $mydomain_desc = __("My great plugin that you need.", "mydomain" );

This bugs me because such redundancy is best avoided.  I've been  
pondering it, and here's an idea:  DON'T repeat.  If a header string  
has a localization, _only_ put it in the __() line.  The new core  
code would look for one or the other, and if it finds something in  
the __() line, it would not be needed in the header comment.

/*
Plugin Name: My Plugin
Plugin URI: http://example.com/myplugin/
Version: 1.0
Author: Stephen Rider
Author URI: http://example.com/
Text Domain: myplugin
*/
$loc_Description = __("My great plugin that you need.", "wpplugin" );

It would have to be there for any plugins requiring backwards  
compatibility, but after a while the redundancy could be dropped  
entirely.

Note also in the example:

1) A new special domain of "wpplugin".  This would trigger a minor  
fork in the normal __() function telling it to use the found "Text  
Domain" string, _and_ to not add it to the WP catalog.  (Otherwise we  
_can_ just use a different function -- just bouncing ideas here!)

2) _Any_ of the metadata strings can be localized by turning it into  
a variable name $loc_ + metadata name -- e.g. $loc_Plugin_Name or  
$loc_Plugin_URI

Stephen


-- 
Stephen Rider
<http://striderweb.com/>



More information about the wp-hackers mailing list