加载耗时
首先在主题的'functions.php'里面加入:

    function timer_start() {
        global $timestart;
        $mtime     = explode( ' ', microtime() );
        $timestart = $mtime[1] + $mtime[0];
        return true;
    }
    timer_start();
    function timer_stop( $display = 0, $precision = 3 ) {
        global $timestart, $timeend;
        $mtime     = explode( ' ', microtime() );
        $timeend   = $mtime[1] + $mtime[0];
        $timetotal = number_format( $timeend - $timestart, $precision );
        $r         = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
        if ( $display ) {
            echo $r;
        }
        return $r;
    }

然后找到'component/sidebar.php',在大约82行的ul列表中加入:

           <li class="list-group-item"> <i class="glyphicon glyphicon-time text-muted"></i> <span class="badge
           pull-right"><?php echo timer_stop();?></span><?php _me("加载耗时") ?></li>
Last modification:August 29th, 2019 at 06:17 pm
如果觉得我的文章对你有用,请随意赞赏