Wordpress source code reading

Record yourself reading the process of wordpress. Going to go through it first.

The wordpress version I downloaded is 4.9.5.

The first is the entry file index.php

Just tell to use the theme, then load the wordpress environment and templates.

Enter the wp-blog-header.php file to see

Use a singleton to execute the content in if. It mainly includes 3 parts.

1. Load wp-load.php //Load the libraries required by wordpress

2. wp(); //Set the wordpress query, here is the main execution part of wordpress.

3. Load template-loader.php // theme template

wp-load.php is a bootstrap file that sets absolute path constants and loads the wp-config.php file, which mainly sets data such as database user passwords. Set error output, etc. wordpress environment settings. There is also a judgment to prevent nested installations.

wp-config.php sets the database information, debug mode, and loads wp-settings.php.

wp-settings.php fixes common variables and includes wordpress programs and function libraries

Mainly introduced in wp-includes

load.php //wordpress's own function class library

default-constants.php //define constants and global variables

plugin.php //Load some APIs of the plugin

Load version.php //mainly the required db, php, wordpress version support information

Then execute wp_initial_constants(); as the name implies, it is to be initialized. Set the runtime memory of wordpress. Define many constants.

wp_check_php_mysql_versions(); //Check whether the mysql version of wordpress is supported

Disable magic boot, define time zone, turn off register_globals to prevent user fields from being registered as globals

wp_fix_server_vars(); //Standardize $_SERVER variable

wp_favicon_request(); //Check the request, if it is a request for favicon.ico, you don't need to load all wordpress

The function of the header here is not very clear, mark it, and find the relevant answer tomorrow.

Guess you like