http://hi.baidu.com/wordpressing/blog/item/64b8f538163069f53a87cec7.html
/**
* timer_start() - PHP 4 standard microtime start capture
*
* @access private
* @since 0.71
* @global int $timestart Seconds and Microseconds added together from when function is called
* @return bool Always returns true
*/
function timer_start() {
global $timestart;
$mtime = explode(' ', microtime() );
$mtime = $mtime[1] + $mtime[0];
$timestart = $mtime;
return true;
}
microtime -- 返回当前 Unix 时间戳和微秒数。
如果调用时不带可选参数,本函数以 "msec sec" 的格式返回一个字符串,其中 sec 是自 Unix 纪元(0:00:00 January 1, 1970 GMT)起到现在的秒数,msec 是微秒部分。字符串的两部分都是以秒为单位返回的。
/**
* timer_stop() - Return and/or display the time from the page start to when function is called.
*
* You can get the results and print them by doing:
* <code>
* $nTimePageTookToExecute = timer_stop();
* echo $nTimePageTookToExecute;
* </code>
*
* Or instead, you can do:
* <code>
* timer_stop(1);
* </code>
* which will do what the above does. If you need the result, you can assign it to a variable, but
* most cases, you only need to echo it.
*
* @since 0.71
* @global int $timestart Seconds and Microseconds added together from when timer_start() is called
* @global int $timeend Seconds and Microseconds added together from when function is called
*
* @param int $display Use '0' or null to not echo anything and 1 to echo the total time
* @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
* @return float The "second.microsecond" finished time calculation
*/
function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
global $timestart, $timeend;
$mtime = microtime();
$mtime = explode(' ',$mtime);
$mtime = $mtime[1] + $mtime[0];
$timeend = $mtime;
$timetotal = $timeend-$timestart;
$r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
if ( $display )
echo $r;
return $r;
}
timer_start();
时间函数,开始记录时间,结束时间是timer_stop
// Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development.
/*在 WordPress 2.3.1 版本中,又增加了新的参数,调试参数(WP_DEBUG)。这是一个逻辑参数,也就是只有是(true)和否(false)两个选项。如果设置为是,则 WordPress 发生错误是,会将错误报告给用户。如果你没有在 wp-config.php 中设置此参数,默认参数为否,即不发送错误报告。*/
if (defined('WP_DEBUG') and WP_DEBUG == true) {
error_reporting(E_ALL);
} else {
error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
}
// For an advanced caching plugin to use, static because you would only want one
if ( defined('WP_CACHE') )
@include ABSPATH . 'wp-content/advanced-cache.php';
/**
* Stores the location of the WordPress directory of functions, classes, and core content.
*
* @since 1.0.0
*/
define('WPINC', 'wp-includes');
if ( !defined('LANGDIR') ) {
/**
* Stores the location of the language directory. First looks for language folder in wp-content
* and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
*
* @since 2.1.0
*/
if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') )
define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash
else
define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash
}
关于语言的操作。如果存在wp-content/languages文件夹,就定义常量LANGDIR为wp-content/languages
否则就是wp-includes/languages
/**
* Allows for the plugins directory to be moved from the default location.
*
* This isn't used everywhere. Constant is not used in plugin_basename()
* which might cause conflicts with changing this.
*
* @since 2.1
*/
if ( !defined('PLUGINDIR') )
define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
require (ABSPATH . WPINC . '/compat.php');
require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/classes.php');
require_wp_db();
if ( !empty($wpdb->error) )
dead_db();
$prefix = $wpdb->set_prefix($table_prefix);
if ( is_wp_error($prefix) )
wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.');
if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
require_once (ABSPATH . 'wp-content/object-cache.php');
else
require_once (ABSPATH . WPINC . '/cache.php');
wp_cache_init();
require (ABSPATH . WPINC . '/plugin.php');
require (ABSPATH . WPINC . '/default-filters.php');
include_once(ABSPATH . WPINC . '/streams.php');
include_once(ABSPATH . WPINC . '/gettext.php');
require_once (ABSPATH . WPINC . '/l10n.php');
if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
if ( defined('WP_SITEURL') )
$link = WP_SITEURL . '/wp-admin/install.php';
elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
$link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
else
$link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
require_once(ABSPATH . WPINC . '/kses.php');
require_once(ABSPATH . WPINC . '/pluggable.php');
wp_redirect($link);
die(); // have to die here ~ Mark
}
require (ABSPATH . WPINC . '/formatting.php');
require (ABSPATH . WPINC . '/capabilities.php');
require (ABSPATH . WPINC . '/query.php');
require (ABSPATH . WPINC . '/theme.php');
require (ABSPATH . WPINC . '/user.php');
require (ABSPATH . WPINC . '/general-template.php');
require (ABSPATH . WPINC . '/link-template.php');
require (ABSPATH . WPINC . '/author-template.php');
require (ABSPATH . WPINC . '/post.php');
require (ABSPATH . WPINC . '/post-template.php');
require (ABSPATH . WPINC . '/category.php');
require (ABSPATH . WPINC . '/category-template.php');
require (ABSPATH . WPINC . '/comment.php');
require (ABSPATH . WPINC . '/comment-template.php');
require (ABSPATH . WPINC . '/rewrite.php');
require (ABSPATH . WPINC . '/feed.php');
require (ABSPATH . WPINC . '/bookmark.php');
require (ABSPATH . WPINC . '/bookmark-template.php');
require (ABSPATH . WPINC . '/kses.php');
require (ABSPATH . WPINC . '/cron.php');
require (ABSPATH . WPINC . '/version.php');
require (ABSPATH . WPINC . '/deprecated.php');
require (ABSPATH . WPINC . '/script-loader.php');
require (ABSPATH . WPINC . '/taxonomy.php');
require (ABSPATH . WPINC . '/update.php');
require (ABSPATH . WPINC . '/canonical.php');
require (ABSPATH . WPINC . '/shortcodes.php');
require (ABSPATH . WPINC . '/media.php');
if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) {
// Used to guarantee unique hash cookies
$cookiehash = md5(get_option('siteurl'));
/**
* Used to guarantee unique hash cookies
* @since 1.5
*/
define('COOKIEHASH', $cookiehash);
}