delete_blog_option

函数
delete_blog_option ( $id, $option )
参数
  • (int) $id A blog ID. Can be null to refer to the current blog.
    Required:
  • (string) $option Name of option to remove. Expected to not be SQL-escaped.
    Required:
返回值
  • (bool) True if the option was deleted, false otherwise.
定义位置
相关方法
get_blog_optiondelete_optionupdate_blog_optionadd_blog_optiondelete_user_option
引入
-
弃用
-

delete_blog_option: 这个函数删除整个网站的一个选项。它用于删除不再需要的选项。

按名字删除给定博客ID的选项。防止删除受保护的WordPress选项。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function delete_blog_option( $id, $option ) {
$id = (int) $id;
if ( empty( $id ) ) {
$id = get_current_blog_id();
}
if ( get_current_blog_id() == $id ) {
return delete_option( $option );
}
switch_to_blog( $id );
$return = delete_option( $option );
restore_current_blog();
return $return;
}
function delete_blog_option( $id, $option ) { $id = (int) $id; if ( empty( $id ) ) { $id = get_current_blog_id(); } if ( get_current_blog_id() == $id ) { return delete_option( $option ); } switch_to_blog( $id ); $return = delete_option( $option ); restore_current_blog(); return $return; }
function delete_blog_option( $id, $option ) {
	$id = (int) $id;

	if ( empty( $id ) ) {
		$id = get_current_blog_id();
	}

	if ( get_current_blog_id() == $id ) {
		return delete_option( $option );
	}

	switch_to_blog( $id );
	$return = delete_option( $option );
	restore_current_blog();

	return $return;
}

常见问题

FAQs
查看更多 >