delete_transient( string $transient )
Delete a transient.
描述
参数
- $transient
-
(string)
(Required)
Transient name. Expected to not be SQL-escaped.
返回值
(bool) true if successful, false otherwise
源代码
File: wp-includes/option.php
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;
}
更新日志
Version | 描述 |
---|---|
2.8.0 | Introduced. |
相关函数
Uses
-
wp-includes/cache.php:
wp_cache_delete() -
wp-includes/load.php:
wp_using_ext_object_cache() -
wp-includes/plugin.php:
do_action() -
wp-includes/option.php:
deleted_transient -
wp-includes/option.php:
delete_option() -
wp-includes/option.php:
delete_transient_{$transient}
Show 1 more use
Hide more uses
Used By
-
wp-admin/includes/file.php:
_wp_handle_upload() -
wp-admin/includes/dashboard.php:
wp_dashboard_rss_control() -
wp-admin/includes/template.php:
get_settings_errors() -
wp-includes/class-wp-feed-cache-transient.php:
WP_Feed_Cache_Transient::unlink() -
wp-includes/media.php:
wp_maybe_generate_attachment_metadata() -
wp-includes/post.php:
wp_delete_attachment() -
wp-includes/author-template.php:
__clear_multi_author_cache()
Show 2 more used by
Hide more used by
User Contributed Notes
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Clearing our transient via the edit_term hook
// Create a simple function to delete our transient function wpdocs_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', 'wpdocs_edit_term_delete_transient' );
你可能对这些文章感兴趣:
- wordpress函数gd_edit_image_support()用法示例
- wordpress函数gallery_shortcode()用法示例
- wordpress函数funky_javascript_callback()用法示例
- wordpress函数funky_javascript_fix()用法示例
- wordpress函数format_to_edit()用法示例
- wordpress函数format_to_post()用法示例
- wordpress函数form_option()用法示例
- wordpress函数force_ssl_login()用法示例
- wordpress函数format_code_lang()用法示例
- wordpress函数format_for_editor()用法示例
- wordpress函数force_ssl_content()用法示例
- wordpress函数flush_rewrite_rules()用法示例
- wordpress函数force_balance_tags()用法示例
- wordpress函数force_ssl_admin()用法示例
如有疑问,请前往问答中心反馈!
反馈