WordPress源码分析

index.php
设置使用主题define(‘WP_USE_THEMES’, true);
加载wp-blog-header.php

wp-blog-header.php
加载wp-load.php
执行wp()
加载include/template-loader.php

wp-load.php
设置绝对路径:define( ‘ABSPATH’, dirname(__FILE__) . ‘/’ );
检测并加载wp-config.php,如果该文件不存在,提示安装WordPress,安装路径为wp-admin/setup-config.php

wp-config.php
设置数据库(数据库名,数据库帐号密码,数据库服务器ip)以及身份密钥
加载wp-settings.php

wp-settings.php
加载include/load.php
加载include/default-contants.php
加载include/version.php
初始化常量:wp_initial_constants( ),设置内存上限(单站32M多站64M)
关闭字符串转义:set_magic_quotes_runtime( 0 );
@ini_set( ‘magic_quotes_sybase’, 0 );
设置时区:
if ( function_exists( ‘date_default_timezone_set’ ) )
date_default_timezone_set( ‘UTC’ );
取消全局变量:
wp_unregister_GLOBALS();
保证以下全局变量与WordPress不冲突:
unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
标准化$_SERVER变量与值:
wp_fix_server_vars();
检查mysql与php版本:
wp_check_php_mysql_versions();
如果请求的是favicon.ico(因为如果favicon.ico存在,则不会请求至index.php),则返回。
wp_favicon_request();
检测是否在维护状态(检测.maintenance文件是否存在,并且时间是否在10分钟之内):
wp_maintenance();
设置起始运行时间点值:
timer_start();
检测是否是调试模式:
wp_debug_mode();
设置cache:
if ( WP_CACHE )
WP_DEBUG ? include( WP_CONTENT_DIR . ‘/advanced-cache.php’ ) : @include( WP_CONTENT_DIR . ‘/advanced-cache.php’ );
设置语言目录:
wp_set_lang_dir();
加载php兼容性支持文件:include/compat.php
加载公共方法文件:include/functions.php
加载WordPress核心类:include/classes.php
加载数据库访问对象:
require_wp_db();
?wp_set_wpdb_vars();
?wp_start_object_cache();
加载插件处理文件:include/plugin.php
加载默认过滤器:include/default-filters.php
加载语言操作文件:include/pomo/mo.php(po=>portable object,mo=>machine object)加载本地化处理文件:include/l10n.php

加载

include/formatting.php
include/capabilities.php
include/query.php
include/theme.php
include/user.php
include/meta.php
include/general-template.php
include/link-template.php
include/author-template.php
include/post.php
include/post-template.php
include/category.php
include/category-template.php
include/comment.php
include/comment-template.php
include/rewrite.php
include/feed.php
include/bookmark.php
include/bookmark-template.php
include/kses.php
include/cron.php
include/deprecated.php
include/script-loader.php
include/taxonomy.php
include/update.php
include/canonical.php
include/shortcodes.php
include/media.php
include/http.php
include/class-http.php
include/widgets.php
include/nav-menu.php
include/nav-menu-template.php

您可能还喜欢...