WordPress函数文档delete_transient()
删除某个保留在数据库的临时值 描述 Delete a transient. If the specified …
删除某个保留在数据库的临时值
描述
Delete a transient. If the specified transient does not exist then no action will be taken.
用法
<?php delete_transient( $transient ); ?>
参数
$transient
(string) (必填) Transient name. Expected to not be SQL-escaped.
默认值: None
返回值
(boolean)
True if successful, false otherwise.
示例
Clearing our transient via the edit_term hook
1
2
3
4
5
6
7
8
9
10
11
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
<?php
// Create a simple function to delete our transient
function edit_term_delete_transient() {
delete_transient( ‘special_query_results’ );
}
// Add the function to the edit_term hook so it runs when categories/tags are edited
add_action( ‘edit_term’, ‘edit_term_delete_transient’ );
?>
|
历史
添加于 版本: 2.8
源文件
delete_transient() 函数的代码位于 wp-includes/option.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Delete a transient.
*
* @since 2.8.0
*
* @param string $transient Transient name. Expected to not be SQL-escaped.
* @return bool true if successful, false otherwise
*/
function delete_transient( $transient ) {
/**
* Fires immediately before a specific transient is deleted.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
* @since 3.0.0
*
* @param string $transient Transient name.
*/
do_action( ‘delete_transient_’ . $transient, $transient );
if ( wp_using_ext_object_cache() ) {
$result = wp_cache_delete( $transient, ‘transient’ );
} else {
$option_timeout = ‘_transient_timeout_’ . $transient;
$option = ‘_transient_’ . $transient;
$result = delete_option( $option );
if ( $result )
delete_option( $option_timeout );
}
if ( $result ) {
/**
* Fires after a transient is deleted.
*
* @since 3.0.0
*
* @param string $transient Deleted transient name.
*/
do_action( ‘deleted_transient’, $transient );
}
return $result;
}
|
相关
Transients API:
set_transient(),
get_transient(),
delete_transient(),
set_site_transient(),
get_site_transient(),
delete_site_transient()
- 原文:http://codex.wordpress.org/Function_Reference/delete_transient
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!