WordPress Debug Function aka PRINTF

Being a longtime C programmer, I love printfs. Printfs are the quickest way to debug simple bugs. Here is my WordPress version of Printf. This 3 line function ensures that it will spew junk only if you are logged in as the Administrator.

function debug_wp($string) {
        if (is_user_logged_in() ) {
                if (current_user_can( 'level_10' ) )
                        echo $string;


I know its very trivial, so it goes into the “As An Aside” category. Nevertheless, the above 5 lines are a life saver for me and hence worth a mention. 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.