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
檢視更多 >