设为首页 收藏本站
查看: 879|回复: 0

[经验分享] 【转载】Wordpress源代码分析之settings.php之三

[复制链接]

尚未签到

发表于 2017-4-1 08:34:55 | 显示全部楼层 |阅读模式
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);
}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-358378-1-1.html 上篇帖子: 解决Apache2+PHP上传文件大小限制的问题 下篇帖子: php中set_include_path函数的用法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表