Support » Plugin: Multi-page Toolkit » Solved: Patch for js errors / "Insert Title" button

  • Resolved p14nd4


    A site I maintain still uses this plugin, and it was recently brought to my attention that the “insert title” button in the WP visual editor wasn’t working. Throwing a javascript debugger into the mix exposed errors along the lines of “no method ‘onInit’ for undefined” or “no index ‘window_height’ for undefined”.

    The issue I discovered boiled down to a few minor changes in the TinyMCE code, since this plugin was written against TinyMCE API 3 and WordPress is, at the time of this writing, using TinyMCE API 4. Thankfully, though, a TinyMCE 3 compatibility layer is present, significantly easing the transition. (I apologize for taking the lazy way out and not taking the time to properly port this to TinyMCE API 4.)

    The two scripts in wp-content/plugins/multi-page-toolkit/buttons/js needed to be patched as follows:

    --- dialog-20160124-1824-drh-port-tinymce-4.js  2009-04-08 21:53:39.000000000 -0500
    +++ dialog.js   2016-01-24 18:30:00.320786435 -0600
    @@ -23,4 +23,4 @@
    -tinyMCEPopup.onInit.add(PageTitleDialog.init, PageTitleDialog);
    +tinyMCEPopup.editor.onInit.add(PageTitleDialog.init, PageTitleDialog);


    --- tiny_mce_popup.20160124-1700-drh-port-tinymce-4.js  2016-01-24 17:00:00.308056097 -0600
    +++ tiny_mce_popup.js   2016-01-24 18:53:20.791169867 -0600
    @@ -20,7 +20,7 @@
                    tinymce = w.tinymce;
                    tinyMCE = w.tinyMCE;
                    t.editor = tinymce.EditorManager.activeEditor;
    -               t.params = t.editor.windowManager.params;
    +               t.params = t.editor.windowManager.getParams();
                    // Setup local DOM
                    t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
    @@ -28,7 +28,7 @@
                    // Setup on init listeners
                    t.listeners = [];
    -               t.onInit = {
    +               t.editor.onInit = {
                            add : function(f, s) {
                                    t.listeners.push({func : f, scope : s});

Viewing 1 replies (of 1 total)
  • Thread Starter p14nd4


    I apparently missed the edit window, but wanted to add that I did go back to grab the original error messages, which may help other people find this in the future:

    Uncaught TypeError: Cannot read property 'mce_inline' of undefined tinyMCEPopup.getWindowArg @ tiny_mce_popup.js:47


    Uncaught TypeError: Cannot read property 'plugin_url' of undefined tinyMCEPopup.getWindowArg @ tiny_mce_popup.js:47

    I’ve also posted this on my blog, and may respond more quickly there if you have comments or questions.

Viewing 1 replies (of 1 total)
  • The topic ‘Solved: Patch for js errors / "Insert Title" button’ is closed to new replies.