You could put the code at the bottom of the functions.php file of your theme.
Be sure to remove "public" from "public function ...", unless you know what PHP Classes are and will place the code within a class.
@maplewang:
No, this is specifically for the polylang plugin.