Tuesday, 5 November 2013

Having a headache and TinyMCE plugging

I spent quite a bit of today in bed with a bad headache.

I also started work on a javascript version of my ebay listings plugin for wordpress. The first thing I wanted to do was to add a button to the editor screen for generating the shortcode. I found a tutorial on how to do this: Guide to Creating Your Own WordPress Editor Buttons. But no matter what I tried, I just could not get my button to show up.

Eventually I downloaded the source files provided as part of the tutorial, and they did work. After doing some debugging (change a bit of their code to be more like my code, refresh the page and see if the buttons still show up or not, repeat), I found the problem. I was using a dash (-) in my TinyMCE plugin's name, and it doesn't like this for some reason. Replace it with an underscore, and it works fine.

Another issue I had was that the tutorial is for an old version of TinyMCE. However, when I tried the code example for the current version of TinyMCE (TinyMCE: Creating a plugin), I received the javascript error message:

editor.addMenuItem is not a function

So it seems that Wordpress (as of version 3.7.1) must still use the old version of TinyMCE. I did try earlier to find info on what version Wordpress does use, but was not successful. I could probably find the actual file included, which might have a comment in it to say, but I would have thought that this sort of info would have been included in the Wordpress codex (docs).

I did actually post the above as a comment to the NetTuts tutorial, but after typing out the answer I was forced to sign in with Disqus before the comment could be posted. And after signing in, the page just reloaded with the comment box empty and no sign of my comment having been posted. So I'm including it here in my blog instead for reference for myself in the future and anyone else.

Hmm... I just had an email from Disqus to validate my account. (I had to sign up for an account to post the comment on the NetTuts article, though I signed up in a different tab so as not to loose my carefully written comment which then got lost when signing in anyway). When I clicked the link, I was asked to sign in. After signing in, I was then greeted by a message that I needed to validate my account and should have received an email with the validation link I need to click!

I don't think I'll ever understand why people implement useless commenting systems like Disqus. Although the facebook commenting system used on many sites is awful, at least it gives your site some exposure as their comment will appear on their timeline and might encourage their friends to visit your site. Disqus has no such benefits, only disadvantages. (Difficult to use, buggy, comments can't be crawled by Google, loads extra js and is slow).

No comments: