0

I have a Wordpress theme that the author is no longer maintaining, and has stopped functioning properly with the update to Wordpress 3.x. Over the past few months, I have been working to resolve the issues with the theme. Most of these issues have been related to JavaScript, and I have been able to fix most of them. I'm finally down to one I can't fix:

This theme contains a function in the admin panel to add new shortcodes that a user can create and performs all the steps correctly except the last: send the shortcode to wordpress editor.

Chrome inspect gives me this error:

Uncaught TypeError: undefined is not a function --- shortcode-box.js:1305

shortcode.sendToEditor --- shortcode-box.js:1305

(anonymous function) --- shortcode-box.js:16

The lines referred to by the errors:

line 1305

sendToEditor :function(){
        window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, shortcode.generate());
    }

line 16

jQuery('#shortcode_send').click(function(){
            shortcode.sendToEditor();
        });

I attached the shortcode-box.js file: http://www.samuguerra.com/shortcode-box.js

Can anyone help me? Excuse my English, as I wrote this with the help of Google Translate

  • Help, please! :'( – Guiloviu Jul 6 '14 at 11:00
  • If you're using TinyMCE 4.x, you'll need to use tinymce instead of tinyMCE. Actually, can you try window.tinymce.editorManager.get("content").execCommand("mceInsertContent", false, shortcode.generate());? – Schism Jul 7 '14 at 18:42
  • Thanks Schism! I tried your solution but still not working :( Now the Chrome Inspect gives me the following error: Uncaught TypeError: Cannot read property 'get' of undefined --- shortcode-box.js:1305 – Guiloviu Jul 8 '14 at 7:52
  • I have some free time tonight; I can look into this deeper for you, but it'll have to wait about 12 hours. – Schism Jul 8 '14 at 14:22
  • What shortcode are you trying to send to the editor? As a hunch, whatever shortcode you are trying to pass is not a member of the case statement is the shortcode_box.js – eyoung100 Jul 8 '14 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.