Skip to content

Instantly share code, notes, and snippets.

@kadai

kadai/functions.php

Created May 8, 2018
Embed
What would you like to do?
Función para conocer el desempeño de WordPress
<?php
add_filter('wp_footer', dtorrer_diagnostico);
function dtorrer_diagnostico(){
$datos = array();
$datos[] = 'Fecha: ' . date('Y-m-d H:i:s');
$datos[] = 'Tiempo: ' . timer_stop(0, 2) . ' segundos.';
if (function_exists('memory_get_usage')) {
$unidades = array('b','kb','mb','gb','tb','pb');
$memoria = memory_get_usage(true);
$i = floor(log($memoria,1024));
$valor = @round($memoria/pow(1024,$i),2) . ' ' . $unidades[$i];
$datos[] = 'Memoria: ' . $valor;
}
$datos[] = 'Consultas: ' . get_num_queries();
if(current_user_can('update_core')){
echo '<p>' . implode('<br>', $datos) . '</p>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment