去掉版本号

默认情况下,Typecho 的源代码头部会显示<meta name="generator" content="Typecho 1.2.0" />等信息。

如果想去掉版本号显示,编辑主题的header.php,将:

<?php $this->header(Content::exportGeneratorRules($this)); ?>

更改为:

<?php $this->header('wlw=&xmlrpc=&rss2=&atom=&rss1=&template=&pingback=&generator'); ?>

显示加载耗时

在主题的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;
}

然后在需要显示加载耗时的地方(如footer.php)插入代码:

<?php echo timer_stop();?>

显示访客总数

在主题的functions.php文件中加入以下代码:

function theAllViews()
  {
      $db = Typecho_Db::get();
      $row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
          echo number_format($row[0]['SUM(VIEWS)']);
  }

然后在需要显示访客总数的地方(如footer.php)插入代码:

<?php theAllViews(); ?>