[API] Fixed the download limit and expiry to accept empty string as unlimited/never value

This commit is contained in:
Claudio Sanches 2015-01-22 11:15:52 -02:00
parent 44fd8f69cf
commit 1dafa5d3cd
1 changed files with 2 additions and 4 deletions

View File

@ -1078,14 +1078,12 @@ class WC_API_Products extends WC_API_Resource {
// Download limit
if ( isset( $data['download_limit'] ) ) {
$download_limit = absint( $data['download_limit'] );
update_post_meta( $id, '_download_limit', ( ! $download_limit ) ? '' : $download_limit );
update_post_meta( $id, '_download_limit', ( '' === $data['download_limit'] ) ? '' : absint( $data['download_limit'] ) );
}
// Download expiry
if ( isset( $data['download_expiry'] ) ) {
$download_expiry = absint( $data['download_expiry'] );
update_post_meta( $id, '_download_expiry', ( ! $download_expiry ) ? '' : $download_expiry );
update_post_meta( $id, '_download_expiry', ( '' === $data['download_expiry'] ) ? '' : absint( $data['download_expiry'] ) );
}
// Download type