WordPress: Download Monitor upload/insert into post broken

Print This Post Print This Post

With the latest update of download monitor plugin for wordpress I got a problem.  The download code was not any more inserted into the post.

I place the cursor in my new post and the clicked the download monitor symbol (the arrow down) to upload and insert a new file. After entering a title and selecting the file to upload using the browse button to upload a local file, I click [Save Download].

Screenshot-Edit Post ‹ Windows CE Programming — WordPress - Mozilla Firefox

Then at the bottom of the “Add Download” click on Save new download.

Screenshot-Edit Post ‹ Windows CE Programming — WordPress - Mozilla Firefox-1

A new dialog pops up and I click [Insert into post]

Screenshot-Edit Post ‹ Windows CE Programming — WordPress - Mozilla Firefox-2

Now nothing happens, the dialog remains on screen.

Unfortunately the developer (mikejoley) of  this usefull plugin stopped further development of the plugin. This is a shame and a bang against the head of all users of the plugin.

I decided to take a look at the code and setup a test xampp system with eclipse, xdebug and wordpress 3.5.1. Then installed the Donwload Monitor plugin and start to understand jQuery and all the code (not all, but the upload).

Then in Google Chrome’s developer console window I saw the problem and fixed it.

In uploader.php:

if (closed != '') {
  var ed = win.tinyMCE.activeEditor;
  var caret = ed.dom.select('span#caret_pos_holder')[0];
  ed.dom.setAttrib(caret, 'id', '')
  ed.selection.select(caret);
  // ed.dom.remove(caret);
});
}
exchange the last two line here (lines 751/752) and add a semicolon at end of ed.dom.setAttrib(caret, ‘id’, ”) / Line 748
if (closed != '') {
  var ed = win.tinyMCE.activeEditor;
  var caret = ed.dom.select('span#caret_pos_holder')[0];
  ed.dom.setAttrib(caret, 'id', '');
  ed.selection.select(caret);
  // ed.dom.remove(caret);
}
});

Now uploading and insert into post work:

Screenshot-Edit Post ‹ Windows CE Programming — WordPress - Mozilla Firefox-3

And you get the markup [Download id not defined] into your edited post.

I forked the github sources of download monitor and send a pull request to mikejolley.

One Comment

  1. Julius says:

    Great fix! I had the same problem and this solved it immediately.

    Thank you
    Julius

Leave a Reply