Skip to content

Instantly share code, notes, and snippets.

@gregrickaby
Last active September 26, 2022 04:27
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save gregrickaby/5894969 to your computer and use it in GitHub Desktop.
Save gregrickaby/5894969 to your computer and use it in GitHub Desktop.
Show me dev info in WordPress
add_action( 'wp_footer', 'wds_debug' );
/*
* Show me some dev info during development! DELETE ME BEFORE GOING LIVE!!!
*
*/
function wds_debug() {
global $template; ?><br />
<?php echo $template; ?><br />
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds<br />
Server load: <?php $load = sys_getloadavg(); echo $load[0]; ?>%<br />
Memory usage:
<?php $mem_usage = memory_get_usage(true);
if ($mem_usage < 1024)
echo $mem_usage." bytes";
elseif ($mem_usage < 1048576)
echo round($mem_usage/1024,2)." kilobytes";
else
echo round($mem_usage/1048576,2)." megabytes";
?><br />
PHP v<?php echo phpversion(); ?><br />
Server date: <?php echo date('Y/j/m'); ?><br />
Server time: <?php echo date('h:i:s a'); ?>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment