2. wp-blog-header.php File Analysis (1)

Source: Internet
Author: User
II. wp-blog-header.php File Analysis (1) the previous chapter we know that the index file only declares a constant to confirm loading, and then contains the wp-blog-header file // wp-blog-header.php all content & lt ;? Phpif (! Isset ($ wp_did_heade II. wp-blog-header.php File Analysis (1)
In the previous chapter, we know that the index file only declares a constant to confirm loading, and then contains the wp-blog-header file.

// All wp-blog-header.php content
 

From the above code we can divide the wp-blog-header.php into three parts.
1. load the wp-load.php file in the current directory
2. call the wp () function
3. load the template-loder.php file under the wp-include Directory

We gradually analyze, starting from the wp-load.php, this file is also very simple, up to set the root directory and the way the error report, and then is to include the wp-config.php file.


Define ('abspath', dirname (_ FILE __). '/'); // wordpress Root Directory // check whether the wp-config.php file under the root directory exists. If yes, the '/' in the root directory constant will be removed and re-included. if you cannot find it, the installation page will be displayed. If (file_exists (ABSPATH. 'WP-config. php ') {require_once (ABSPATH. 'WP-config. php ');} elseif (file_exists (dirname (ABSPATH ). '/wp-config.php ')&&! File_exists (dirname (ABSPATH ). '/wp-settings.php') {require_once (dirname (ABSPATH ). '/wp-config.php');} else {// installation code, because do not study the installation, do not write}


We have installed wordpress by default here, so the program should smoothly load the wp-config.php file, which is the database configuration information and identity key, then the wp-setting.php file under the wp-include directory is loaded again.

// Database information and identity key is skipped // you can see, clearly defined in the wp-load.php file root directory constant, here due to the need to load the wp-settings.php and made a judgment, to avoid accidents, we need to learn this rigorous programming habit. If (! Defined ('abspath') define ('abspath', dirname (_ FILE _). '/');/** set WordPress variables and include files. */Require_once (ABSPATH. 'WP-settings. php ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.