public static function init()
{
if (isset($_GET['download_file']) && isset($_GET['order']) && isset($_GET['email'])) {
add_action('init', array(__CLASS__, 'download_product'));
}
add_action('woocommerce_download_file_redirect', array(__CLASS__, 'download_file_redirect'), 10, 2);
add_action('woocommerce_download_file_xsendfile', array(__CLASS__, 'download_file_xsendfile'), 10, 2);
add_action('woocommerce_download_file_force', array(__CLASS__, 'download_file_force'), 10, 2);
}
* * IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set. * * @param array $headers * @return array */ public static function ie_nocache_headers_fix($headers) { if (is_ssl() && !empty($GLOBALS['is_IE'])) { $headers['Cache-Control'] = 'private'; unset($headers['Pragma']); } return $headers; } /** * Die with an error message if the download fails. * @param string $message * @param string $title * @param integer $status * @access private */ private static function download_error($message, $title = '', $status = 404) { if (!strstr($message, '<a ')) { $message .= ' <a href="' . esc_url(wc_get_page_permalink('shop')) . '" class="wc-forward">' . __('Go to shop', 'woocommerce') . '</a>'; } wp_die($message, $title, array('response' => $status)); } } WC_Download_Handler::init();