[wp-hackers] Howdy Don't plugin (was Decision time in re: admin rework)

Stephen Rider wp-hackers at striderweb.com
Wed Dec 26 15:12:45 GMT 2007


Decided I needed a little exercise:

<http://striderweb.com/wp-content/docs/nerd/downloads/howdy-dont.zip>

Now it's a plugin.  Knock yerselves out.  Option page and everything.

I do have a question.  Since the filter only works when there is a  
localization file in use, I wanted to make it so the Options page  
only appears under the same condition.  I tried the following:

function howdy_load_optionspage() {
	global $l10n;
	if( isset( $l10n[$domain] ) ) {
		add_options_page( "Howdy Don't", "Howdy Don't", 'manage_options',  
basename(__FILE__), 'howdy_options_page');
	}
}

But for some reason the if( isset() ) always results in "false".  I  
copied that test straight out of the l10n.php file from core.  Any  
idea why it doesn't work here?

Regards,
Stephen

On Dec 23, 2007, at 8:04 AM, Edward Dale wrote:

> I was going to make a plugin to allow simpler customization of Howdy,
> for example, random greetings from around the world.  I haven't gotten
> around to that part though.  I did come up with a code snippet that
> changes the text without having to deal with .PO files, etc.  I
> haven't tested it in a while, but here it is:
>
> add_action('admin_head', 'scompt_add_gettext');
> function scompt_add_gettext() {
>     add_filter( 'gettext', 'scompt_gettext', 10, 2);
> }
> function scompt_gettext($translated, $text) {
>     if( $text == 'Howdy, <strong>%s</strong>.' ) {
>         remove_filter('gettext', 'scompt_gettext', 10, 2);
>         return "woohoo, <strong>%s</strong>";
>     }
>     return $translated;
> }


More information about the wp-hackers mailing list