/**
 * Output direct EDD download file url
 */
function vp_edd_fd_download_url($atts, $content = null)
{
    extract(shortcode_atts(array('label' => 'link'), $atts));
    $did = isset($_GET['did']) ? $_GET['did'] : '';
    $file = isset($_GET['file']) ? $_GET['file'] : '';
    $url = '';
    if ($did !== '' and $file !== '') {
        $url = vp_edd_fd_build_download_url($did, $file);
    }
    return '<a href="' . $url . '">' . $atts['label'] . '</a>';
}
/**
 * Output download gateway script
 */
function vp_edd_download_gateway_script()
{
    global $edd_options;
    $download_page = isset($edd_options['vp_edd_fd_download_page']) ? $edd_options['vp_edd_fd_download_page'] : '';
    $member_page = isset($edd_options['vp_edd_fd_member_page']) ? $edd_options['vp_edd_fd_member_page'] : '';
    $countdown = (isset($edd_options['vp_edd_fd_countdown']) and is_numeric($edd_options['vp_edd_fd_countdown'])) ? $edd_options['vp_edd_fd_countdown'] : 2000;
    if (is_page($download_page)) {
        $did = isset($_GET['did']) ? $_GET['did'] : '';
        $file = isset($_GET['file']) ? $_GET['file'] : '';
        if ($did !== '' and $file !== '') {
            $url = vp_edd_fd_build_download_url($did, $file);
            ?>
			<script>
				jQuery(document).ready(function(){
					setTimeout(function(){
						var download_url = "<?php 
            echo $url;
            ?>
";
						window.location.assign(download_url);
					}, <?php 
            echo $countdown;
            ?>
);
				});
			</script>
			<?php 
        }
    }
}