1. 首页
  2. WordPress 函数手册

delete_transient()

delete_transient( string $transient )

删除瞬态。
Deletes a transient.

目录锚点:#参数#返回#源码#笔记


参数(Parameters)

参数 类型 必填 说明
$transient (string) 必需 暂时的名字。应为非SQL转义。

返回(Return)

(bool)如果成功则为true,否则为false


源码(Source)

/**
 * 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;
}
更新版本 源码位置 使用 被使用
2.8.0 wp-includes/option.php:632 8 6

笔记(Notes)

通过编辑术语挂钩清除瞬态

delete_transient() 为WP2原创文章,链接:https://www.wp2.cn/functions/delete_transient/

发表评论

您的电子邮箱地址不会被公开。