Manipulate get_bloginfo() Output

If you want to change the output of anything the get_bloginfo() returns, there’s a couple of filters that make it simple:

(I’m going to leave the practical application brainstorming up to you)

For text:

add_filter( 'bloginfo', 'be_excited', 10, 2 );
function be_excited( $output, $show ) {
    if ( 'name' == $show )
        $output .= ' OMG BBQ!!! FTW';
    return $output;
}

For URLs: change the filter hook to bloginfo_url

Change “Register” Link to “Sign Up”

Very similar to a previous post about the “Log In” links, but for the “Register” link. If you think your users would be more comfortable with different verbiage, then make your users comfortable:

add_filter( 'register', 'reg2sign' );
function reg2sign( $link ) {
	$link = str_replace( '>Register<', '>Sign Up<', $link );
	return $link;
}

Remove Special Characters From Uploaded Files

This is probably more practical if you deal with a lot of special characters, perhaps in foreign languages. But if you want to make sure particular characters are removed from file name when uploaded, you can. As always, WordPress makes this easy.

add_filter( 'sanitize_file_name_chars', 'add_chars_to_filter', 10, 2 );
function add_chars_to_filter ( $special_chars, $filename_raw ) {
	$special_chars[] = 'e';
	return $special_chars;
}

This particular is example is useless as-is, unless you have something against our favorite vowel ‘e.’

Change the Virtual Robots.txt File

Did you know that WordPress will create a robots.txt file for you – well, sorta…

If you don’t create an actual robots.txt file, WordPress will create a virtual one for you, meaning that if yoursite.com/robots.txt is requested, WordPress will serve up robots.txt page, even though it doesn’t actually exist on your server.

Now that we’ve got that covered. How can you edit your virtual robots file? Easy

add_filter( 'robots_txt', 'robots_mod', 10, 2 );
function robots_mod( $output, $public ) {
	$output .= "Disallow: /topsecret/\n";
	return $output;
}