This commit is contained in:
2026-03-11 15:57:27 +01:00
parent 481271c972
commit b4b460fd21
10775 changed files with 2071579 additions and 26409 deletions

View File

@@ -21,15 +21,56 @@ $.fn.wplupload = function($options) {
// Create a progress bar containing the filename
$('#progress').css({'visibility':'visible', 'display':'block'});
$('#select-files').hide();
// Hide drag-drop overlay and remove fullscreen extension when upload starts
$('#wpallimport-fullscreen-drag-overlay').hide();
$('#wpallimport-drag-drop-area').removeClass('fullscreen-active');
})
});
$up.init();
$up.bind('Error', function(up, err) {
$up.bind('Error', function(up, err) {
// Check if this is an Excel file and we haven't tried alternative processing yet
var file = err.file;
var isExcelFile = file && file.name && /\.(xls|xlsx)$/i.test(file.name);
var hasTriedAlternative = file && (file.wpai_tried_alternative || false);
if (isExcelFile && !hasTriedAlternative) {
// Mark that we've tried alternative processing for this file
file.wpai_tried_alternative = true;
// Show retry message
$('#progressbar').html('<span>Retrying with alternative Excel processing method...</span>');
$('#progress').show();
// Set flag for alternative Excel processing
$up.settings.multipart_params.use_alternative_excel = '1';
// Reset file status and retry
setTimeout(function() {
file.status = plupload.QUEUED;
file.percent = 0;
file.loaded = 0;
$up.start();
}, 1000);
return; // Don't show error yet
}
//$('#upload_process').html(err.message);
//$('.wpallimport-header').next('.clear').after(err.message);
$('.error-upload-rejected').show();
// Reset drag-drop state on error
$('#wpallimport-fullscreen-drag-overlay').hide();
$('#wpallimport-drag-drop-area').removeClass('fullscreen-active');
if (typeof window.isDragDropUpload !== 'undefined') {
window.isDragDropUpload = false;
}
if (typeof window.dragCounter !== 'undefined') {
window.dragCounter = 0;
}
});
$up.bind('FilesAdded', function(up, files) {
@@ -63,20 +104,46 @@ $.fn.wplupload = function($options) {
$up.bind('FileUploaded', function(up, file, r) {
var fetch = typeof(shortform) == 'undefined' ? 1 : 2;
var response = r.response;
r = _parseJSON(r.response);
var fetch = typeof(shortform) == 'undefined' ? 1 : 2;
var response = r.response;
r = _parseJSON(r.response);
if (r.OK === 0)
{
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
if (r.OK === 0)
{
// Check if this is an Excel file and we haven't tried alternative processing yet
var isExcelFile = file.name && /\.(xls|xlsx)$/i.test(file.name);
var hasTriedAlternative = file.wpai_tried_alternative || false;
if (isExcelFile && !hasTriedAlternative) {
// Mark that we've tried alternative processing for this file
file.wpai_tried_alternative = true;
// Show retry message
$('#progressbar').html('<span>Retrying with alternative Excel processing method...</span>');
$('#progress').show();
// Set flag for alternative Excel processing
$up.settings.multipart_params.use_alternative_excel = '1';
// Reset file status and retry
setTimeout(function() {
file.status = plupload.QUEUED;
file.percent = 0;
file.loaded = 0;
$up.start();
}, 1000);
return; // Don't show error yet
}
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
$('.wpallimport-import-from.selected').click();
$('#wpallimport-url-upload-status').html('');
$('#progress').hide();
$('#progressbar').html('<span></span>');
$('#select-files').fadeIn();
//$('.wpallimport-header').next('.clear').after('<div class="error inline"><p>' + response + '</p></div>');
$('.error-upload-rejected').show();
}
@@ -84,7 +151,33 @@ $.fn.wplupload = function($options) {
{
if (r.error !== null){
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
// Check if this is an Excel file and we haven't tried alternative processing yet
var isExcelFile = file.name && /\.(xls|xlsx)$/i.test(file.name);
var hasTriedAlternative = file.wpai_tried_alternative || false;
if (isExcelFile && !hasTriedAlternative) {
// Mark that we've tried alternative processing for this file
file.wpai_tried_alternative = true;
// Show retry message
$('#progressbar').html('<span>Retrying with alternative Excel processing method...</span>');
$('#progress').show();
// Set flag for alternative Excel processing
$up.settings.multipart_params.use_alternative_excel = '1';
// Reset file status and retry
setTimeout(function() {
file.status = plupload.QUEUED;
file.percent = 0;
file.loaded = 0;
$up.start();
}, 1000);
return; // Don't show error yet
}
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
$('.wpallimport-import-from.selected').click();
$('#wpallimport-url-upload-status').html('');
@@ -99,36 +192,63 @@ $.fn.wplupload = function($options) {
}
else
{
$('.wpallimport-header').next('.clear').after('<div class="error inline"><p>' + r.error.message + '</p></div>');
}
$('.wpallimport-header').next('.clear').after('<div class="error inline"><p>' + r.error.message + '</p></div>');
}
}
else{
// Check if this was a successful retry with alternative Excel processing
var isExcelFile = file.name && /\.(xls|xlsx)$/i.test(file.name);
var hasTriedAlternative = file.wpai_tried_alternative || false;
var usedAlternative = $up.settings.multipart_params.use_alternative_excel === '1';
if (isExcelFile && hasTriedAlternative && usedAlternative) {
// Reset the flag for future uploads
$up.settings.multipart_params.use_alternative_excel = '0';
// Check the alternative Excel processing checkbox on the page
$('#use_alternative_excel_processing').prop('checked', true);
}
if (r.post_type)
{
var index = $('#custom_type_selector li:has(input[value="'+ r.post_type +'"])').index();
if (index != -1)
// Find the option with the matching value
var $option = $('#custom_type_selector option[value="'+ r.post_type +'"]');
if ($option.length)
{
$('#custom_type_selector').ddslick('select', {index: index });
$('#custom_type_selector').val(r.post_type).trigger('change');
if (r.taxonomy_type){
var $taxOption = $('#taxonomy_to_import option[value="'+ r.taxonomy_type +'"]');
if ($taxOption.length){
$('#taxonomy_to_import').val(r.taxonomy_type).trigger('change');
}
}
if (r.gravity_form_title){
var $gfOption = $('#gravity_form_to_import option[value="'+ r.gravity_form_title +'"]');
if ($gfOption.length){
$('#gravity_form_to_import').val(r.gravity_form_title).trigger('change');
}
}
if (typeof r.url_bundle != "undefined")
{
$('.auto-generate-template').css({'display':'inline-block'}).attr('rel', 'url_type');
$('.wpallimport-url-type').click();
{
$('input[name=url]').val(r.name);
$('input[name=template]').val(r.template);
$('input[name=bundle_xpath]').val(r.bundle_xpath);
$('.auto-generate-template').css({'display':'inline-block'}).attr('rel', 'url_type');
$('.wpallimport-url-type').click();
$('.wpallimport-download-from-url').click();
}
else
{
$('.auto-generate-template').css({'display':'inline-block'}).attr('rel', 'upload_type');
}
}
}
else
{
$('.auto-generate-template').hide();
}
}
}
else
{
@@ -137,44 +257,46 @@ $.fn.wplupload = function($options) {
$('#filepath').val(r.name);
$('#progressbar').html('<span>Upload Complete</span> - ' + file.name + ' (' + ( (file.size / (1024*1024) >= 1) ? (file.size / (1024*1024)).toFixed(2) + 'mb' : (file.size / (1024)).toFixed(2) + 'kb') + ')');
$('#progressbar').html('<span>Upload Complete</span> - ' + file.name + ' (' + ( (file.size / (1024*1024) >= 1) ? (file.size / (1024*1024)).toFixed(2) + 'mb' : (file.size / (1024)).toFixed(2) + 'kb') + ')');
$('.wpallimport-import-types').find('h2').slideUp();
setTimeout(function() {
setTimeout(function() {
if (r.post_type && r.notice !== false)
{
var $note = $('.wpallimport-upload-type-container[rel=upload_type]').find('.wpallimport-note');
$note.html("<div class='wpallimport-free-edition-notice'>" + r.notice + "</div>").show();
$note.find('span').html("<div class='wpallimport-free-edition-notice'>" + r.notice + "</div>");
$note.show();
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
$('.wpallimport-choose-file').find('.wpallimport-upload-resource-step-two').slideUp();
$('input[name=filepath]').val('');
}
else
{
if (r.post_type && r.warning !== false)
{
var $note = $('.wpallimport-upload-type-container[rel=upload_type]').find('.wpallimport-note');
$note.html("<div class='wpallimport-free-edition-notice'>" + r.warning + "</div>").show();
}
$('.wpallimport-choose-file').find('.wpallimport-upload-resource-step-two').slideDown();
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').show();
}
$('.wpallimport-choose-file').find('.wpallimport-submit-buttons').show();
}
if (r.OK) {
if (r.OK) {
} else if (r.error != undefined && '' != r.error.message) {
//$('#progressbar').html(r.error.message);
$('.error-upload-rejected').show();
}
}, 1000);
}, 1000);
}
}
});
$up.bind('UploadComplete', function(up) {
$('#cancel-upload').attr('disabled', 'disabled');
$('#cancel-upload').attr('disabled', 'disabled');
$('#advanced_upload').show();
// Reset drag-drop state
if (typeof window.isDragDropUpload !== 'undefined') {
window.isDragDropUpload = false;
}
});
$('#cancel-upload').on('click', function() {