$value, 'exp' => $expiration, ] ); } else { // transient found, update it $data['value'] = $value; $data['exp'] = $expiration; $result = update_option( $option_name, $data ); } return $result; } /** * To be used in conjunction with `thrive_set_transient` * * @param string $transient * * @return bool * @see thrive_set_transient() * */ function tpm_delete_transient( $transient ) { return delete_option( "_thrive_tr_{$transient}" ); } /** * Replacement for WordPress's get_transient() * There are cases when get_transient() will simply fail if an external cache plugin declares * the global $_wp_using_ext_object_cache ( e.g. using memcached ) BUT the memcached server is not reachable. * In this case both set_transient() and get_transient() will not work. * * @param string $transient Transient name * * @return mixed transient value, or false if transient is not set or is expired */ function tpm_get_transient( $transient ) { $data = get_option( "_thrive_tr_{$transient}" ); $value = is_array( $data ) && isset( $data['value'], $data['exp'] ) ? $data['value'] : false; /* if data has the correct format, then check expiration - if not zero and in the past, return false */ if ( $value !== false && $data['exp'] && $data['exp'] < time() ) { $value = false; } return $value; }