Update functions.php

fixed braces, fixed unnecessary else, fixed docblock, replaced printf with echo