函数文档

wp_not_installed()

💡 云策文档标注

概述

wp_not_installed() 函数用于在 WordPress 未安装时重定向到安装程序。如果启用了 Multisite,则显示错误消息并终止执行。

关键要点

  • 检查 WordPress 是否已安装或处于安装模式,若已安装则直接返回。
  • 设置 nocache_headers 以防止缓存。
  • 如果启用了 Multisite,使用 wp_die() 显示错误消息并终止。
  • 否则,加载 kses.php 和 pluggable.php,生成安装链接并重定向到 install.php。

代码示例

function wp_not_installed() {
    if ( is_blog_installed() || wp_installing() ) {
        return;
    }

    nocache_headers();

    if ( is_multisite() ) {
        wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
    }

    require ABSPATH . WPINC . '/kses.php';
    require ABSPATH . WPINC . '/pluggable.php';

    $link = wp_guess_url() . '/wp-admin/install.php';

    wp_redirect( $link );
    die();
}

注意事项

  • 函数在 WordPress 3.0.0 版本中引入。
  • 相关函数包括 is_blog_installed(), wp_installing(), is_multisite(), wp_die(), wp_redirect(), wp_guess_url(), nocache_headers(), __() 等。

📄 原文内容

Redirects to the installer if WordPress is not installed.

Description

Dies with an error message when Multisite is enabled.

Source

function wp_not_installed() {
	if ( is_blog_installed() || wp_installing() ) {
		return;
	}

	nocache_headers();

	if ( is_multisite() ) {
		wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
	}

	require ABSPATH . WPINC . '/kses.php';
	require ABSPATH . WPINC . '/pluggable.php';

	$link = wp_guess_url() . '/wp-admin/install.php';

	wp_redirect( $link );
	die();
}

Changelog

Version Description
3.0.0 Introduced.