Skip to content

Instantly share code, notes, and snippets.

@AmmarCodes
Last active December 26, 2015 13:59
Show Gist options
  • Save AmmarCodes/7162251 to your computer and use it in GitHub Desktop.
Save AmmarCodes/7162251 to your computer and use it in GitHub Desktop.
Useful functions to include in your theme functions file.
/**
* Dumping a variable surrounded with <pre> tag.
* @param object $var the variable to dump
* @param boolean $die wether to die() after printing the output
* @return null
*/
function d($var, $exit = false) {
echo "<pre dir='ltr'>";
ob_start();
if(is_array($var)) {
echo "(".count($var).") ";
print_r($var);
}
else {
var_dump($var);
}
$a = ob_get_contents();
ob_end_clean();
echo htmlspecialchars($a,ENT_QUOTES);
echo "</pre>";
if($exit != false)
die();
}
// remove the generator html tag, which displaying the WordPress version!
add_filter('the_generator', 'the_generator_filter');
function the_generator_filter() {
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment