Solved: Patch for js errors / "Insert Title" button
-
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);
and
--- 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}); }
- The topic ‘Solved: Patch for js errors / "Insert Title" button’ is closed to new replies.