wordpress全局变量$wpdb初始化并声明为全局变量的方法


本文整理自网络,侵删。

首先从wordpress程序index.php入手:


代码如下:

define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

index.php加载了wp-blog-header.php文件,再打开看看:


代码如下:

if ( !isset($wp_did_header) ) {
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
}

再打开wp-load.php:


代码如下:

if ( file_exists( ABSPATH . 'wp-config.php') ) {

/** The config file resides in ABSPATH */
require_once( ABSPATH . 'wp-config.php' );

} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) {

/** The config file resides one level above ABSPATH but is not part of another install */
require_once( dirname(ABSPATH) . '/wp-config.php' );

} else {
……
}

它加载了配置文件config.php,打开config.php看看:

阅读剩余部分

相关阅读 >>

wordpress之js库集合研究介绍

详解wordpress中分类函数wp_list_categories的使用

apache服务器中.htaccess文件的实用配置示例集锦

wordpress的6种主题框架对比分析

wordpress速度优化-nginx fastcgi_cache缓存加速

wordpress中鼠标悬停显示和隐藏评论及引用按钮的实现

在centos 6 中安装wordpress(一) 安装apache,mysql, php环境

wordpress链接google字体慢的完美解决教程

wordpress wp_list_categories(分类的链接列表)的使用方法

不用wordpress插件显示文章浏览统计功能代码修改(原理分析)

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...