delete_transient

The timeline below displays how wordpress function delete_transient has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 9.1

/**
 * Deletes a transient.
 *
 * @since 2.8.0
 *
 * @param string $transient Transient name. Expected to not be SQL-escaped.
 * @return bool True if the transient was deleted, 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() || 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;
}

WordPress Version: 5.5

/**
 * Deletes a transient.
 *
 * @since 2.8.0
 *
 * @param string $transient Transient name. Expected to not be SQL-escaped.
 * @return bool True if the transient was deleted, 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;
}

WordPress Version: 5.4

/**
 * Deletes 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;
}

WordPress Version: 4.7

/**
 * 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;
}

WordPress Version: 4.1

/**
 * 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;
}

WordPress Version: 3.9

/**
 * 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;
}

WordPress Version: 3.7

/**
 * Delete a transient.
 *
 * @since 2.8.0
 * @package WordPress
 * @subpackage Transient
 *
 * @uses do_action() Calls 'delete_transient_$transient' hook before transient is deleted.
 * @uses do_action() Calls 'deleted_transient' hook on success.
 *
 * @param string $transient Transient name. Expected to not be SQL-escaped.
 * @return bool true if successful, false otherwise
 */
function delete_transient($transient)
{
    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) {
        do_action('deleted_transient', $transient);
    }
    return $result;
}