{"id":5785426,"date":"2015-02-13T13:16:38","date_gmt":"2015-02-13T13:16:38","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/tinymce-shortcode-button-fix\/"},"modified":"2016-08-22T16:30:30","modified_gmt":"2016-08-22T16:30:30","slug":"tinymce-shortcode-button-fix","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/tinymce-shortcode-button-fix\/","title":{"rendered":"TinyMCE Shortcode button fix"},"content":{"rendered":"<p>Hi,<\/p>\n<p>I fixed the issue with the shortcode button in the visual editor for newer wordpress versions. I hope Will Zachmann could implement it in the next version \ud83d\ude42<\/p>\n<p>There are other issues that come with the visual editor (TinyMCE) because the functions get updated sooner or later and break older plugins. I just focused on the issue with the shortcode insert button.<\/p>\n<p>Open the <strong>shortcode-exec-php-class.php<\/strong> in the plugin-folder and scroll to this js-part (about line 1189):<\/p>\n<pre><code>$(&#039;#scep-tinymce-form&#039;).submit(function() {\n    if (window.tinyMCE) {\n        window.tinyMCE.execInstanceCommand(&#039;content&#039;, &#039;mceInsertContent&#039;, false, &#039;[&#039; + $(&#039;#scep-tinymce-shortcode&#039;).val() + &#039;]&#039;);\n\ttinyMCEPopup.editor.execCommand(&#039;mceRepaint&#039;);\n\ttinyMCEPopup.close();\n    }\n    return false;\n});<\/code><\/pre>\n<p>Change it this way and save it:<\/p>\n<pre><code>$(&#039;#scep-tinymce-form&#039;).submit(function() {\n    if (window.tinyMCE) {\n        if (tinyMCE.majorVersion&gt;=&quot;4&quot;) {\n            window.tinyMCE.execCommand(&#039;mceInsertContent&#039;, false, &#039;[&#039; + $(&#039;#scep-tinymce-shortcode&#039;).val() + &#039;]&#039;);\n        } else {\n            window.tinyMCE.execInstanceCommand(&#039;content&#039;, &#039;mceInsertContent&#039;, false, &#039;[&#039; + $(&#039;#scep-tinymce-shortcode&#039;).val() + &#039;]&#039;);\n        }\n        tinyMCEPopup.editor.execCommand(&#039;mceRepaint&#039;);\n\ttinyMCEPopup.close();\n    }\n    return false;\n});<\/code><\/pre>\n<p>That&#8217;s all \ud83d\ude09<\/p>\n<p>https:\/\/wordpress.org\/plugins\/shortcode-exec-php\/<\/p>\n","protected":false},"template":"","class_list":["post-5785426","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5785426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5785426\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5785426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}