delete_transient

函数
delete_transient ( $transient )
参数
  • (string) $transient Transient name. Expected to not be SQL-escaped.
    Required:
返回值
  • (bool) True if the transient was deleted, false otherwise.
定义位置
相关方法
delete_site_transientset_transientget_transientdelete_expired_transientsget_site_transient
引入
2.8.0
弃用
-

delete_transient: 此函数删除一个暂存器。应将暂存器的名称作为参数指定。

删除瞬态。

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() || wp_installing() ) {
		$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;
}

常见问题

FAQs
查看更多 >