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

@@ -109,12 +109,23 @@ class WPDD_PayPal {
$paypal_order = self::api_request('/v2/checkout/orders', $order_data, 'POST');
if (isset($paypal_order['id'])) {
$_SESSION['wpdd_paypal_order_' . $paypal_order['id']] = array(
'product_id' => $product_id,
'amount' => $final_price,
'customer_email' => sanitize_email($_POST['customer_email'] ?? ''),
'customer_name' => sanitize_text_field($_POST['customer_name'] ?? '')
);
// Ensure session is available before storing data
if (WP_Digital_Download::ensure_session()) {
$_SESSION['wpdd_paypal_order_' . $paypal_order['id']] = array(
'product_id' => $product_id,
'amount' => $final_price,
'customer_email' => sanitize_email($_POST['customer_email'] ?? ''),
'customer_name' => sanitize_text_field($_POST['customer_name'] ?? '')
);
} else {
// Fallback: use WordPress options table with short expiry
set_transient('wpdd_paypal_order_' . $paypal_order['id'], array(
'product_id' => $product_id,
'amount' => $final_price,
'customer_email' => sanitize_email($_POST['customer_email'] ?? ''),
'customer_name' => sanitize_text_field($_POST['customer_name'] ?? '')
), 600); // 10 minutes
}
wp_send_json_success(array('orderID' => $paypal_order['id']));
} else {
@@ -134,7 +145,17 @@ class WPDD_PayPal {
$capture_response = self::api_request('/v2/checkout/orders/' . $paypal_order_id . '/capture', array(), 'POST');
if (isset($capture_response['status']) && $capture_response['status'] === 'COMPLETED') {
$session_data = $_SESSION['wpdd_paypal_order_' . $paypal_order_id] ?? array();
// Try to get data from session first, then fallback to transient
$session_data = array();
if (WP_Digital_Download::ensure_session() && isset($_SESSION['wpdd_paypal_order_' . $paypal_order_id])) {
$session_data = $_SESSION['wpdd_paypal_order_' . $paypal_order_id];
} else {
// Try transient fallback
$session_data = get_transient('wpdd_paypal_order_' . $paypal_order_id);
if ($session_data === false) {
$session_data = array();
}
}
// Add error logging for debugging session issues
if (empty($session_data)) {
@@ -212,7 +233,11 @@ class WPDD_PayPal {
update_post_meta($session_data['product_id'], '_wpdd_sales_count',
intval(get_post_meta($session_data['product_id'], '_wpdd_sales_count', true)) + 1);
unset($_SESSION['wpdd_paypal_order_' . $paypal_order_id]);
// Clean up stored data (both session and transient)
if (WP_Digital_Download::ensure_session() && isset($_SESSION['wpdd_paypal_order_' . $paypal_order_id])) {
unset($_SESSION['wpdd_paypal_order_' . $paypal_order_id]);
}
delete_transient('wpdd_paypal_order_' . $paypal_order_id);
wp_send_json_success(array(
'redirect_url' => add_query_arg(
@@ -267,8 +292,26 @@ class WPDD_PayPal {
private static function generate_download_link($order_id) {
global $wpdb;
// Get the order to find the product
$order = $wpdb->get_row($wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}wpdd_orders WHERE id = %d",
$order_id
));
if (!$order) {
return false;
}
// Get download limit from product settings
$download_limit = get_post_meta($order->product_id, '_wpdd_download_limit', true);
$download_limit = $download_limit ?: 0; // Default to 0 (unlimited) if not set
// Get download expiry from product settings
$download_expiry = get_post_meta($order->product_id, '_wpdd_download_expiry', true);
$download_expiry = $download_expiry ?: 30; // Default to 30 days if not set
$token = wp_hash(uniqid() . $order_id . time());
$expires_at = date('Y-m-d H:i:s', strtotime('+7 days'));
$expires_at = date('Y-m-d H:i:s', strtotime('+' . $download_expiry . ' days'));
$wpdb->insert(
$wpdb->prefix . 'wpdd_download_links',
@@ -276,7 +319,7 @@ class WPDD_PayPal {
'order_id' => $order_id,
'token' => $token,
'expires_at' => $expires_at,
'max_downloads' => 5,
'max_downloads' => $download_limit,
'created_at' => current_time('mysql')
),
array('%d', '%s', '%s', '%d', '%s')