Skip to content

Instantly share code, notes, and snippets.

@hadamlenz
Last active July 22, 2016 14:13
Show Gist options
  • Save hadamlenz/ce0914acfabe6dd0085889c2c1f633b0 to your computer and use it in GitHub Desktop.
Save hadamlenz/ce0914acfabe6dd0085889c2c1f633b0 to your computer and use it in GitHub Desktop.
<?php
/*
*a wordpress funtion for dumping in a <pre> and dying
*
*param any $thing the thing you want to var_dump
*param bool $die = should we wp_die or just echo
*/
function wp_predump($thing,$die=true){
$output = '<pre>';
ob_start();
var_dump($thing);
$output .= ob_get_clean();
$output .= '</pre>';
if($die){
wp_die($output);
}else{
echo $output;
}
}
/*usage*/
wp_predump($thing1,false);
wp_predump($thing2,false);
wp_predump($thing3)
@hadamlenz
Copy link
Author

hadamlenz commented Jul 22, 2016

I often find myself writing the whole thing out so instead I made a function. I usually will put this in a utility class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment