How to add code to just before closing body tag

If you’re just using a small script or other markup, you can hook a function to the wp_footer filter, which should be included in all properly-coded themes: add_action( ‘wp_footer’, function () { ?> <script language=”javascript” type=”text/javascript”> startcart() </script> <?php } ); However, if your JavaScript code is more substantial, or you wish to use built-in … Read more

Remove extra Google Maps script

EDIT : use wp_enqueue_script as you want (enqueue in header or footer after jQuery as you want) to enqueue file called something like : gmap.js included in your plugin wp_enqueue_script(‘custom-gmap’, plugin_dir_url( __FILE__ ).’inc/js/gmap.js’, array(‘jquery’), false, true);//just change your path and name of file write this in your Js file 🙂 $(document).ready(function() { if (typeof google … Read more

How to replace regular jquery calls with CDN calls from Google?

You should be loading jQuery with wp_enqueue_script(‘jquery’) – that way, you won’t end up with multiple instances if plugins try to load it too. To use Google CDN, place this in your functions.php; wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js’, null, // Dependencies – none null // Version – use null to prevent WP adding version … Read more

Reset Undo on the tinymce editor

The global variable tinyMCE has an array of editors. So you have to call the undoManager inside them. Like this for default wp editor on post edit/create screen: tinyMCE.editors[0].undoManager.clear(); If you want to do it in a specific editor, select the editor id in n like this: var n = 0; // editor id tinyMCE.editors[n].undoManager.clear();

How to only enqueue block javascript on the frontend when its needed [duplicate]

To register scripts/styles conditionally if the page has a certain block you can follow the solution that @Will posted in the comments from a similar question. Copy/pasting with some modifications from that question: add_action( ‘enqueue_block_assets’, ‘myplugin_enqueue_if_block_is_present’ ); // Can only be loaded in the footer // add_action( ‘wp_enqueue_scripts’, ‘myplugin_enqueue_if_block_is_present’ ); // Can be loaded in … Read more

REST API: Backbone and custom endpoint

It looks like you are trying to send a POST request to the /istermactive endpoint, is that correct? (I think you may want to remove the trailing slash from the endpoint?) I’m not really sure the wp-api client is the right tool for a standard ajax POST, you may want to use jQuery.ajax or use … Read more