You appear to be a bot. Output may be restricted
Description
Get Download File Url Constructs a secure file download url for a specific file.
Usage
$string = edd_get_download_file_url( $key, $email, $filekey, $download_id, $price_id );
Parameters
- $key
- ( string ) required – Payment key. Use edd_get_payment_key() to get key.
- ( string ) required – Customer email address. Use edd_get_payment_user_email() to get user email.
- $filekey
- ( int ) required – Index of array of files returned by edd_get_download_files() that this download link is for.
- $download_id
- ( int ) optional – Optional. ID of download this download link is for. Default is 0.
- $price_id
- ( bool|int ) optional – Optional. Price ID when using variable prices. Default is false.
Returns
string A secure download URL
Source
File name: easy-digital-downloads/includes/download-functions.php
Lines:
1 to 50 of 50
function edd_get_download_file_url( $key, $email, $filekey, $download_id = 0, $price_id = false ) { $hours = absint( edd_get_option( 'download_link_expiration', 24 ) ); if ( ! ( $date = strtotime( '+' . $hours . 'hours', current_time( 'timestamp') ) ) ) { $date = 2147472000; // Highest possible date, January 19, 2038 } // Leaving in this array and the filter for backwards compatibility now $old_args = array( 'download_key' => rawurlencode( $key ), 'email' => rawurlencode( $email ), 'file' => rawurlencode( $filekey ), 'price_id' => (int) $price_id, 'download_id' => $download_id, 'expire' => rawurlencode( $date ) ); $params = apply_filters( 'edd_download_file_url_args', $old_args ); $payment = edd_get_payment_by( 'key', $params['download_key'] ); if ( ! $payment ) { return false; } $args = array(); if ( ! empty( $payment->ID ) ) { // Get the array of parameters in the same order in which they will be validated. $args = array_fill_keys( edd_get_url_token_parameters(), '' ); // Simply the URL by concatenating required data using a colon as a delimiter. $args['eddfile'] = rawurlencode( sprintf( '%d:%d:%d:%d', $payment->ID, $params['download_id'], $params['file'], $price_id ) ); if ( isset( $params['expire'] ) ) { $args['ttl'] = $params['expire']; } // Ensure all custom args registered with extensions through edd_download_file_url_args get added to the URL, but without adding all the old args $args = array_merge( $args, array_diff_key( $params, $old_args ) ); $args = apply_filters( 'edd_get_download_file_url_args', $args, $payment->ID, $params ); $args['file'] = $params['file']; $args['token'] = edd_get_download_token( add_query_arg( array_filter( $args ), untrailingslashit( site_url() ) ) ); } return add_query_arg( array_filter( $args ), site_url( 'index.php' ) ); }