Created
September 19, 2012 19:22
-
-
Save ocean90/3751658 to your computer and use it in GitHub Desktop.
WordPress: Print some debug infos into backend footer.
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
/** | |
* For site admins: Print some debug infos into backend footer. | |
* - Time | |
* - DB Queries | |
* - Memory Usage | |
* - Cache Hts/Misses | |
* - Active Plugins | |
* | |
* @param string $text Existing footer text. | |
* | |
* @return string Footer text with infos. | |
*/ | |
function ds_footer_debug_infos( $text ) { | |
if ( ! is_super_admin() ) | |
return $text; | |
$text = 'Time : ' . timer_stop( 0 ) . ' | '; | |
$text .= 'DB Queries: ' . $GLOBALS['wpdb']->num_queries . ' | '; | |
$text .= 'Memory: ' . number_format( ( memory_get_peak_usage()/1024/1024 ), 1, ',', '' ) . '/' . ini_get( 'memory_limit' ) . ' | '; | |
$ch = empty( $GLOBALS['wp_object_cache']->cache_hits ) ? 0 : $GLOBALS['wp_object_cache']->cache_hits; | |
$cm = empty( $GLOBALS['wp_object_cache']->cache_misses ) ? 0 : $GLOBALS['wp_object_cache']->cache_misses; | |
$text .= 'Cache Hits: ' . $ch . ' | Cache Misses: ' . $cm . ' | '; | |
$ap = count( get_option('active_plugins') ); | |
$text .= 'Active Plugins: ' . $ap; | |
return $text; | |
} | |
add_filter( 'admin_footer_text', 'ds_footer_debug_infos' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment