Predefined callback functions for filters

wordpress-code-small

wordpress-code-smallFilters are often used for removing content. For example, if you want to hide the admin bar you can do the following:

function hide_admin_bar() {
return FALSE;
}
add_filter( ‘show_admin_bar’ , ‘hide_admin_bar’ );

It’s a bit tedious to define an additional function just to return “FALSE“. Since version 3.0 WordPress provides various functions to shorten the code:

__return_true()
__return_false()
__return_zero()
__return_empty_array()

The above code can now be written as

add_filter( ‘show_admin_bar’, ‘__return_false’ );