Penny Whiteley

Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
Sep 11, 2020 at 3:02 am
#136212
Participant
Penny Whiteley
OP

Ah! Thanks. We have not updated yet.

In the meantime this is what I did

I made a slight alteration in the following file

…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php

The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs

The change I made was this.

Find this bit of code. Around Line 325

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

And replace with this.

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

var d = new Date().getTime(); // Moved variable before loop

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

Sep 11, 2020 at 3:00 am
#136211
Participant
Penny Whiteley
OP

OK, I managed to get a workaround for this problem.

This is what I did

I made a slight alteration in the following file

…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php

The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs

The change I made was this.

Find this bit of code. Around Line 325

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

And replace with this.

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

var d = new Date().getTime(); // Moved variable before loop

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

Sep 11, 2020 at 3:00 am
#136210
Participant
Penny Whiteley
OP

OK, I managed to get a workaround for this problem.

This is what I did

I made a slight alteration in the following file

…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php

The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs

The change I made was this.

Find this bit of code. Around Line 325

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

And replace with this.

function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}

var d = new Date().getTime(); // Moved variable before loop

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}

Sep 9, 2020 at 5:52 am
#136047
Participant
Penny Whiteley
OP

I’m getting closer to understanding why this is assigning duplicate IDs.

Unfortunately, the unique IDs are being created based on milliseconds using the jQeury.getTime function.

Now this is in the attach-file.php file.

I need to slow this down or have a better way to assign unique IDs

function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
</script>
</div>
<?php

Sep 7, 2020 at 11:12 pm
#135947
Participant
Penny Whiteley
OP

Hi,
We have come across a bug when adding multiple files from Select from Server when adding files into a package.
We have noticed that, often, there are duplicate IDs being created. After updating, duplicates are omitted from being added to the package and the user has to navigate the cumbersome process of going through Select from Server again.
I believe this is an error in coding which should be wrapped up in a transaction to check that unique IDs are being created beforehand.
I created a 30 second video showing the problem. Link below

Can you please investigate this please?
Thanks

Jul 29, 2020 at 1:36 am
#133596
Participant
Penny Whiteley
OP

If i disable scripts then the page doesnt work at all for the feature that I have setup on the page

Jul 28, 2020 at 12:02 am
#133494
Participant
Penny Whiteley
OP

This error prevents another wordpress plugin to work so its very important – its not feasible to just use a browser work around

I told you that the following error occurs (see below) becuase you have not included the js.map file into the project – the other bootstrap js files all have a map file

Could not load content for wp-content/plugins/download-manager/assets/bootstrap/js/popper.min.js.map

Can you fix this in future releases

Jul 21, 2020 at 6:08 am
#133122
Participant
Penny Whiteley
OP

i cannot do this as we are testing the plugin behind a firewall and we dont allow access

Viewing 8 posts - 1 through 8 (of 8 total)