Adding a new panel to the WordPress Debug Bar plugin

You can extend the WordPress Debug Bar plugin adding new custom panels to fit your needs; for instance, showing responses from external APIs or webservices, or for other custom features.

// the 'debug_bar_panels' filter it's used by the plugin;
// hook into it to add your custom panel
add_filter( 'debug_bar_panels', 'my_custom_panel_init' );

/**
 * Initialize my custom debug panel
 * @param array $panels Debug bar panels objects
 * @return array Debug bar panels with your custom panels
 */
function my_custom_panel_init( $panels ) {
    // you'll be extending the Debug_Bar_Panel class provided
    // by the plugin
    class Debug_Bar_Custom_Panel extends Debug_Bar_Panel{
        public function init(){
            // you should set at least the title of your custom
            // panel. it'll be used as the tab title
            $this->title( 'Custom Panel' );
        }
        public function render(){
            // build and echo your relevant output
        }
    }
    // add your custom panel
    $panels[] = new Debug_Bar_Custom_Panel();
    return $panels;
}

That’s an extremely simple example. You can check a more complex and complete one by viewing the source of one of the Debug Bar extender plugins, such as the Debug-Bar-Shortcodes GitHub repo.

Debugging memory usage in PHP apps

As your app gets increasingly more complex, you might run into Memory exhausted errors, and even though you can always increase the allowed memory usage — either by tweaking php.ini or locally with ini_set() — it should be a better option to find out what’s using so much memory in the first place.

Continue reading

Are you boy-scouting your code?

Simple, humble and effective. Whenever you’re reviewing old code, or other people’s code, apply one simple rule:

Leave it better than you found it

Are you a boy scout?

An Orangutan Has Some Human Rights, Argentine Court Rules

An Argentine court ruled that an orangutan has some human rights. I get that this is exciting news for animalists, but I’m guessing that post/transhumanists and defenders of AI and other sentient beings might also be thrilled, setting legal precedent for nonhuman rights.

 

Revisiting the “Cookieless Domain” Recommendation

It’s always nice to see someone question established beliefs, specially on the highly evolving world of web development.

Jonathan Klein from Etsy revisits the “cookieless domain” recommendation for serving static assets (CSS in particular) and analyses the pros, cons and the importance of taking DNS lookups and latency into consideration.

Revisiting the “Cookieless Domain” Recommendation

Comments on the Sony hack

That we live in the world where we aren’t sure if any given cyberattack is the work of a foreign government or a couple of guys should be scary to us all

Bruce Schneier – Comments on the Sony hack

Check Sony got hacked hard: what we know and what we don’t know so far from Wired for a broad synthesis of the hack or A breakdown and analysis of the December, 2014 Sony hack from Risk Based Security for a more detailed perspective.

Debian Lenny Vagrant base box

I was recently working on a project where they’re still using Debian 5.0 as their OS. Since I couldn’t find a Vagrant base box with it, I rolled up my sleeves and created my own, so here it is: felipelavinz/debian-lenny

In case you need to create another rare base box, you might want to check this excellent tutorial on creating a Vagrant base box as an starting point.

To CAPTCHA or not to CAPTCHA

The new CAPTCHA method recently introduced by Google seems like an important improvement over the ever-more-sludgy letters we were getting used to see across the web.

image

It’s good to see that the use of CAPTCHAs as an anti-spam method it’s not yet a completely over discussion, and there are still some of us that believe that there are better, unobtrusive alternatives that should be explored, if not preferred.

For now, while CAPTCHAs still are a  requirement for some security audit policies, we can at least offer a better experience… Even if it’s just a cleverly disguised white-list