函数文档

delete_site_option()

💡 云策文档标注

概述

delete_site_option() 函数用于删除当前网络的指定选项。它是 delete_network_option() 的包装器,自 WordPress 4.4.0 起实现此功能。

关键要点

  • 函数接受一个必需参数 $option,表示要删除的选项名称,不应进行 SQL 转义。
  • 返回布尔值:删除成功返回 true,否则返回 false。
  • 自 WordPress 4.4.0 起,此函数被修改为 delete_network_option() 的包装器,简化了网络选项管理。
  • 相关函数包括 delete_network_option()、upgrade_network()、update_core() 等,用于网络级操作。

代码示例

if ( delete_site_option( 'wpdocs_option' ) ) {
    // Current network's option deleted successfully.
}

📄 原文内容

Removes an option by name for the current network.

Description

See also

Parameters

$optionstringrequired
Name of the option to delete. Expected to not be SQL-escaped.

Return

bool True if the option was deleted, false otherwise.

Source

function delete_site_option( $option ) {
	return delete_network_option( null, $option );
}

Changelog

Version Description
4.4.0 Modified into wrapper for delete_network_option()
2.8.0 Introduced.

User Contributed Notes