🔧 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>
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Database migration script for WP Digital Download
 | 
						|
 * Adds missing columns and updates database schema
 | 
						|
 */
 | 
						|
 | 
						|
if (!defined('ABSPATH')) {
 | 
						|
    exit;
 | 
						|
}
 | 
						|
 | 
						|
function wpdd_migrate_database() {
 | 
						|
    global $wpdb;
 | 
						|
    
 | 
						|
    // Check if available_at column exists in wpdd_creator_earnings table
 | 
						|
    $column_exists = $wpdb->get_results(
 | 
						|
        "SHOW COLUMNS FROM {$wpdb->prefix}wpdd_creator_earnings LIKE 'available_at'"
 | 
						|
    );
 | 
						|
    
 | 
						|
    if (empty($column_exists)) {
 | 
						|
        // Add the missing available_at column
 | 
						|
        $result = $wpdb->query(
 | 
						|
            "ALTER TABLE {$wpdb->prefix}wpdd_creator_earnings 
 | 
						|
             ADD COLUMN available_at datetime DEFAULT NULL AFTER payout_status,
 | 
						|
             ADD INDEX available_at (available_at)"
 | 
						|
        );
 | 
						|
        
 | 
						|
        if ($result !== false) {
 | 
						|
            error_log('WPDD Migration: Successfully added available_at column to wpdd_creator_earnings table');
 | 
						|
            
 | 
						|
            // Update existing pending earnings to have an available_at date
 | 
						|
            $holding_days = intval(get_option('wpdd_earnings_holding_days', 15));
 | 
						|
            $wpdb->query(
 | 
						|
                $wpdb->prepare(
 | 
						|
                    "UPDATE {$wpdb->prefix}wpdd_creator_earnings 
 | 
						|
                     SET available_at = DATE_ADD(created_at, INTERVAL %d DAY)
 | 
						|
                     WHERE payout_status = 'pending' AND available_at IS NULL",
 | 
						|
                    $holding_days
 | 
						|
                )
 | 
						|
            );
 | 
						|
            
 | 
						|
            return true;
 | 
						|
        } else {
 | 
						|
            error_log('WPDD Migration Error: Failed to add available_at column - ' . $wpdb->last_error);
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
    }
 | 
						|
    
 | 
						|
    return true; // Column already exists
 | 
						|
}
 | 
						|
 | 
						|
// Run migration if accessed directly (for manual execution)
 | 
						|
if (basename($_SERVER['SCRIPT_FILENAME']) === 'wpdd-db-migrate.php') {
 | 
						|
    wpdd_migrate_database();
 | 
						|
} |