* Repairs a glitch in WordPress's save function. You cannot save a null value on update, see * https://github.com/woothemes/woocommerce/issues/7861 for more info on this. * * @param integer $post_id The ID of the subscription */ public static function repair_permission_data($post_id) { if (absint($post_id) !== $post_id) { return; } if ('shop_subscription' !== get_post_type($post_id)) { return; } global $wpdb; $wpdb->query($wpdb->prepare("\n\t\t\tUPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions\n\t\t\tSET access_expires = null\n\t\t\tWHERE order_id = %d\n\t\t\tAND access_expires = %s\n\t\t", $post_id, '0000-00-00 00:00:00')); } /** * Remove download permissions attached to a subscription when it is permenantly deleted. * * @since 2.0 */ public static function delete_subscription_permissions($post_id) { global $wpdb; if ('shop_subscription' == get_post_type($post_id)) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d", $post_id)); } } } WCS_Download_Handler::init();