WordPress 6.3源代码阅读 wp-admin/install.php
`wp-admin/setup-config.php` 主要是生成`wp-config.php`和下载语言文件
接下来是执行`wp-admin/install.php`
这个代码分两部分:
显示安装提交表单
其实安装代码的前面还有一步选择语言,此时如果放弃安装,重新访问网站,就会到达安装前的选择语言步骤,如下
是否安装的判断在`wp-settings.php`可以看到wp_not_installed方法调用,具体逻辑可以仔细研究了。
我们来看下`wp-admin/install.php`
`if(false)`这里是无PHP环境的一个判断,可以看出代码写的很细致
接下来的代码是是否已经安装的判断
PHP版本和Mysql版本的判断是否满足要求
是否定义常量`DO_NOT_UPGRADE_GLOBAL_TABLES`
然后判断是否选择语言分为step 0 和 step 1
step 1就是显示安装提交表单
设置站点标题,管理员用户名和密码,邮箱以及是否搜索引擎可索引,新网站建议先不可见
安装处理
上一步表单提交的处理
提交数据的校验,安装逻辑封装在在`wp_install`,可以去细看一下
/**
* Installs the site.
*
* Runs the required functions to set up and populate the database,
* including primary admin user and initial options.
*
* @since 2.1.0
*
* @param string $blog_title Site title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $is_public Whether the site is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Default empty (random password).
* @param string $language Optional. Language chosen. Default empty.
* @return array {
* Data for the newly installed site.
*
* @type string $url The URL of the site.
* @type int $user_id The ID of the site owner.
* @type string $password The password of the site owner, if their user account didn't already exist.
* @type string $password_message The explanatory message regarding the password.
* }
*/
function wp_install( $blog_title, $user_name, $user_email, $is_public, $deprecated = '', $user_password = '', $language = '' )
至此Wordpress安装完毕
感谢您的阅读,如果有什么WordPress的问题欢迎提出一起讨论
请先 后发表评论~