WPChill / download-monitor

A WordPress plugin which provides an intuitive UI for uploading and managing downloadable files (including support for multiple versions), inserting download links into posts & logging downloads.
http://wordpress.org/extend/plugins/download-monitor/
261 stars 117 forks source link

Schedule doesn't work #429

Open luisarn opened 6 years ago

luisarn commented 6 years ago

Hi,

Seems the download monitor doesn't take into consideration the publish date.

Let's say if we want the download only available on 2018-01-01, you can't. If you have the post URL you can download the file before the scheduled date.

So I added the following lines on line 287 of class-dlm-download-handler.php to tackle this issue:

$post_date = get_the_date( 'Y-m-d H:i:s', $download_id ); $current_time = current_time( 'Y-m-d H:i:s' ); if ( $post_date > $current_time ) { wp_die( __( 'Download does not exist.', 'download-monitor' ) . ' <a href="' . home_url() . '">' . __( 'Go to homepage &rarr;', 'download-monitor' ) . '</a>', __( 'Download Error', 'download-monitor' ), array( 'response' => 404 ) ); }

Maybe you can merge this piece of code into the next release?

Best regards, Luis

barrykooij commented 6 years ago

Hey Luis,

If I understand correctly, you want to be able to add a version to an existing download but not make it available right away. Is this correct?

Kind Regards,

Barry Kooij

luisarn commented 6 years ago

Hi Barry!

Not an existing download, I’m trying to make a newly uploaded file only available on a future date. For example if we want to announce something on 15 November I could schedule a post on Wordpress to make it public on that day but Wordpress itself can’t schedule attachments. If you know the url of the file you can download it even the associated post is not public yet. So download monitor came to rescue, because it creates a new post type and should inherits some Wordpress posts features such as scheduling, however, the current version of download monitor ignores the post date. That’s why I’m asking if you could check the post date too in the next release then we would be able to schedule attachments too.

Thank you! Best regards, Luis