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>
159 lines
5.4 KiB
JavaScript
159 lines
5.4 KiB
JavaScript
jQuery(document).ready(function($) {
|
|
// Format currency
|
|
function formatCurrency(amount) {
|
|
return '$' + parseFloat(amount).toFixed(2);
|
|
}
|
|
|
|
// Handle creator selection for manual payout
|
|
$('#creator_id').on('change', function() {
|
|
var selectedOption = $(this).find('option:selected');
|
|
var balance = selectedOption.data('balance');
|
|
var balanceDisplay = $('#creator_balance_display');
|
|
var balanceAmount = $('#creator_balance_amount');
|
|
|
|
if ($(this).val() && balance !== undefined) {
|
|
balanceAmount.text(formatCurrency(balance));
|
|
balanceDisplay.show();
|
|
} else {
|
|
balanceDisplay.hide();
|
|
}
|
|
});
|
|
|
|
// Handle creator selection for balance adjustment
|
|
$('#adj_creator_id').on('change', function() {
|
|
var selectedOption = $(this).find('option:selected');
|
|
var balance = selectedOption.data('balance');
|
|
var balanceDisplay = $('#adj_creator_balance_display');
|
|
var balanceAmount = $('#adj_creator_balance_amount');
|
|
|
|
if ($(this).val() && balance !== undefined) {
|
|
balanceAmount.text(formatCurrency(balance));
|
|
balanceDisplay.show();
|
|
} else {
|
|
balanceDisplay.hide();
|
|
}
|
|
});
|
|
|
|
// Handle individual payout processing
|
|
$('.wpdd-process-payout').on('click', function(e) {
|
|
e.preventDefault();
|
|
|
|
var $button = $(this);
|
|
var payoutId = $button.data('payout-id');
|
|
var originalText = $button.text();
|
|
|
|
// Disable button and show loading
|
|
$button.prop('disabled', true).text('Processing...');
|
|
|
|
$.ajax({
|
|
url: ajaxurl,
|
|
type: 'POST',
|
|
data: {
|
|
action: 'wpdd_process_payout',
|
|
payout_id: payoutId,
|
|
nonce: wpdd_admin_nonce
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
$button.closest('tr').find('.payout-status').text('Processing');
|
|
$button.text('Processed').removeClass('wpdd-process-payout').addClass('button-disabled');
|
|
} else {
|
|
alert('Error: ' + (response.data || 'Unknown error occurred'));
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Ajax request failed');
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Handle payout request approval
|
|
$('.wpdd-approve-request').on('click', function(e) {
|
|
e.preventDefault();
|
|
|
|
var $button = $(this);
|
|
var requestId = $button.data('request-id');
|
|
var originalText = $button.text();
|
|
|
|
// Disable button and show loading
|
|
$button.prop('disabled', true).text('Processing...');
|
|
|
|
$.ajax({
|
|
url: ajaxurl,
|
|
type: 'POST',
|
|
data: {
|
|
action: 'wpdd_approve_payout_request',
|
|
request_id: requestId,
|
|
nonce: wpdd_admin_nonce
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
location.reload(); // Reload to show updated status
|
|
} else {
|
|
alert('Error: ' + (response.data || 'Unknown error occurred'));
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Ajax request failed');
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Handle bulk payout processing
|
|
$('#wpdd-process-bulk-payouts').on('click', function(e) {
|
|
e.preventDefault();
|
|
|
|
var checkedPayouts = $('.wpdd-payout-checkbox:checked');
|
|
|
|
if (checkedPayouts.length === 0) {
|
|
alert('Please select at least one payout to process.');
|
|
return;
|
|
}
|
|
|
|
if (!confirm('Are you sure you want to process ' + checkedPayouts.length + ' payout(s)?')) {
|
|
return;
|
|
}
|
|
|
|
var $button = $(this);
|
|
var originalText = $button.text();
|
|
var payoutIds = [];
|
|
|
|
checkedPayouts.each(function() {
|
|
payoutIds.push($(this).val());
|
|
});
|
|
|
|
// Disable button and show loading
|
|
$button.prop('disabled', true).text('Processing...');
|
|
|
|
$.ajax({
|
|
url: ajaxurl,
|
|
type: 'POST',
|
|
data: {
|
|
action: 'wpdd_process_bulk_payouts',
|
|
payout_ids: payoutIds,
|
|
nonce: wpdd_admin_nonce
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
location.reload(); // Reload to show updated status
|
|
} else {
|
|
alert('Error: ' + (response.data || 'Unknown error occurred'));
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Ajax request failed');
|
|
$button.prop('disabled', false).text(originalText);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Handle select all checkboxes
|
|
$('#wpdd-select-all-payouts').on('change', function() {
|
|
$('.wpdd-payout-checkbox').prop('checked', $(this).prop('checked'));
|
|
});
|
|
}); |