Last active
December 26, 2015 13:59
-
-
Save AmmarCodes/7162251 to your computer and use it in GitHub Desktop.
Useful functions to include in your theme functions file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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