Creating an Exit Confirmation Popup

First things first, change the name of the functions – you have them the same as the tutorial – as a rule, always make them something unique just to reduce the possibility of conflicts. So instead of wpb_confirm_leaving() you should maybe change it to something like jkkr_confirm_leaving. Just make sure you change it everywhere. But … Read more

Javascript code inside “” in core WordPress files .php

These are Underscore Templates, handled by the wp.template() JavaScript function (source here) which takes in a template ID corresponding to a <script type=”text/html” id=”tmpl-{template ID}”> element containing such code and compiles it into a function. This function can then be executed with the variables used in the template in order to produce a string of … Read more

Insert shortcode in post editor from javascript (Visual / HTML)

I was pulling my hair out on this one, but I might have figured it out. Try this (with jQuery): if( ! tinyMCE.activeEditor || tinyMCE.activeEditor.isHidden()) { jQuery(‘textarea#content’).val(“[SHORTCODE]test[/SHORTCODE] “); } else { tinyMCE.execCommand(‘mceInsertRawHTML’, false, “[SHORTCODE]test[/SHORTCODE] “); } Basically, you need to set the value of the textarea directly if the editor is hidden.

Disable / Deregister all JS from all plugins

You could install a plug-in like asset Queue Manager to keep track of all the active stylesheets and javascript files (it’s preaty neat, you can live-preview how the page would look without an asset to see if your site gets broken or not), and then in your theme’s functions.php file, put a code like the … Read more