Major improvements: Fix download limits, enhance license display, fix software filenames
Some checks failed
Create Release / build (push) Failing after 3s

🔧 Bug Fixes:
- Fixed download limits defaulting to 5 instead of 0 for unlimited downloads
- Fixed software license filename sanitization (spaces→dashes, dots→underscores, proper .zip extension)
- Software downloads now show as "Test-Plugin-v2-2-0.zip" instead of "Test Plugin v2.2.0"

 UI/UX Enhancements:
- Redesigned license key display to span full table width with FontAwesome copy icons
- Added responsive CSS styling for license key rows
- Integrated FontAwesome CDN for modern copy icons

🏗️ Architecture Improvements:
- Added comprehensive filename sanitization in both download handler and API paths
- Enhanced software license product handling for local package files
- Improved error handling and logging throughout download processes

📦 Infrastructure:
- Added Gitea workflows for automated releases on push to main
- Created comprehensive .gitignore excluding test files and browser automation
- Updated documentation with all recent improvements and technical insights

🔍 Technical Details:
- Software license products served from wp-content/uploads/wpdd-packages/
- Download flow: token → process_download_by_token() → process_download() → deliver_file()
- Dual path coverage for both API downloads and regular file delivery
- Version placeholder system for automated deployment

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-09 19:16:57 -07:00
parent 6d86d5ef4f
commit 4731637f33
28 changed files with 3709 additions and 156 deletions

View File

@@ -356,9 +356,11 @@ class WPDD_Shortcodes {
}
$orders = $wpdb->get_results($wpdb->prepare(
"SELECT o.*, p.post_title as product_name
"SELECT o.*, p.post_title as product_name, l.license_key,
(SELECT COUNT(*) FROM {$wpdb->prefix}wpdd_downloads d WHERE d.order_id = o.id) as download_count
FROM {$wpdb->prefix}wpdd_orders o
LEFT JOIN {$wpdb->posts} p ON o.product_id = p.ID
LEFT JOIN {$wpdb->prefix}wpdd_licenses l ON o.id = l.order_id
WHERE o.customer_email = %s
AND o.status = 'completed'
ORDER BY o.purchase_date DESC",
@@ -370,9 +372,11 @@ class WPDD_Shortcodes {
// Get orders by user ID or email (to include guest purchases before account creation)
$orders = $wpdb->get_results($wpdb->prepare(
"SELECT o.*, p.post_title as product_name
"SELECT o.*, p.post_title as product_name, l.license_key,
(SELECT COUNT(*) FROM {$wpdb->prefix}wpdd_downloads d WHERE d.order_id = o.id) as download_count
FROM {$wpdb->prefix}wpdd_orders o
LEFT JOIN {$wpdb->posts} p ON o.product_id = p.ID
LEFT JOIN {$wpdb->prefix}wpdd_licenses l ON o.id = l.order_id
WHERE (o.customer_id = %d OR o.customer_email = %s)
AND o.status = 'completed'
ORDER BY o.purchase_date DESC",
@@ -409,6 +413,7 @@ class WPDD_Shortcodes {
<?php foreach ($orders as $order) : ?>
<?php
$download_limit = get_post_meta($order->product_id, '_wpdd_download_limit', true);
$download_limit = $download_limit ?: 0; // Convert empty string to 0 (unlimited)
$download_expiry = get_post_meta($order->product_id, '_wpdd_download_expiry', true);
$is_expired = false;
@@ -417,7 +422,9 @@ class WPDD_Shortcodes {
$is_expired = current_time('mysql') > $expiry_date;
}
$can_download = !$is_expired && ($download_limit == 0 || $order->download_count < $download_limit);
// Ensure download_count is a number
$current_downloads = (int) $order->download_count;
$can_download = !$is_expired && ($download_limit == 0 || $current_downloads < $download_limit);
?>
<tr>
<td><?php echo esc_html($order->order_number); ?></td>
@@ -431,9 +438,9 @@ class WPDD_Shortcodes {
<td>
<?php
if ($download_limit > 0) {
echo sprintf('%d / %d', $order->download_count, $download_limit);
echo sprintf('%d / %d', $current_downloads, $download_limit);
} else {
echo $order->download_count;
echo sprintf('%d / %s', $current_downloads, __('unlimited', 'wp-digital-download'));
}
?>
</td>
@@ -470,6 +477,19 @@ class WPDD_Shortcodes {
<?php endif; ?>
</td>
</tr>
<?php if (!empty($order->license_key)) : ?>
<tr class="wpdd-license-row">
<td colspan="6" class="wpdd-license-cell">
<div class="wpdd-license-info">
<small><?php _e('License Key:', 'wp-digital-download'); ?></small>
<code class="wpdd-license-key"><?php echo esc_html($order->license_key); ?></code>
<button type="button" class="wpdd-copy-license" data-license="<?php echo esc_attr($order->license_key); ?>" title="<?php _e('Copy to clipboard', 'wp-digital-download'); ?>">
<i class="fas fa-copy"></i>
</button>
</div>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>