diff --git a/includes/class-wc-download-handler.php b/includes/class-wc-download-handler.php index bd91e32b328..a5395674f43 100644 --- a/includes/class-wc-download-handler.php +++ b/includes/class-wc-download-handler.php @@ -205,6 +205,10 @@ class WC_Download_Handler { $remote_file = false; $file_path = ABSPATH . $file_path; + } elseif ( '/wp-content' === substr( $file_path, 0, 11 ) ) { + $remote_file = false; + $file_path = realpath( WP_CONTENT_DIR . substr( $file_path, 11 ) ); + // Check if we have an absolute path } elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ) ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] ) ) { $remote_file = false; diff --git a/includes/class-wc-product-download.php b/includes/class-wc-product-download.php index 80feed84acb..5bad4305ed5 100644 --- a/includes/class-wc-product-download.php +++ b/includes/class-wc-product-download.php @@ -97,6 +97,8 @@ class WC_Product_Download implements ArrayAccess { $file_url = $this->get_file(); if ( '..' === substr( $file_url, 0, 2 ) || '/' !== substr( $file_url, 0, 1 ) ) { $file_url = realpath( ABSPATH . $file_url ); + } elseif ( '/wp-content' === substr( $file_url, 0, 11 ) ) { + $file_url = realpath( WP_CONTENT_DIR . substr( $file_url, 11 ) ); } return apply_filters( 'woocommerce_downloadable_file_exists', file_exists( $file_url ), $this->get_file() ); }