Prevent update_checkout from firing mid-typing

It’s been a while and maybe you don’t need this information. But i am having exactly the same problem. So i have come up with this solution: window.setTimeout( function () { $(‘form.checkout’).off(‘input keydown change’, ‘.address-field input.input-text, .update_totals_on_change input.input-text’); }, 0); It removes all “input/keydown/change” events from zipcode and address fields. I have used setTimeout to … Read more

enqueue script won’t work (enqueue style does work)

You’re using the wrong hook. wp_enqueue_scripts is the correct hook for both: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_scripts’ ); But since they’re the same hook you can just enqueue both files in the same callback: function my_theme_enqueue_assets() { wp_enqueue_style( ‘parent-style’, get_parent_theme_file_uri( ‘style.css’ ) ); wp_enqueue_script( ‘behavior’, get_theme_file_uri( ‘behavior.js’ ), array(), null, true ); } … Read more

Don’t allow JavaScript in the content area

You could use the_content filter: add_filter( ‘the_content’, ‘remove_script_tag’ ); function remove_script_tag( $content ) { return strip_tags( $content, ‘<script>’ ); } When you also want the content of the tag to be removed you could use this one: add_filter( ‘the_content’, ‘remove_script_tag_and_content’ ); function remove_script_tag_and_content( $content ) { $striped_text = preg_replace(‘@<script>.*?<\/script>@si’, ”, $content); return $striped_text; }

Javascript code doesn’t work in my wordpress theme

First – set jquery in dependencies array. And if you are using libraries – include them. All libraries must be registered, not enqueue. Use wp_register_script();. And set libs in dependencies array. wp_register_script(‘my-masonry’, ‘path to lib’, array(), null, true); wp_enqueue_script( ‘scripts’, get_template_directory_uri() . ‘/assets/js/scripts.js’, array(‘jquery’, ‘my-masonry’), null, true ); Code like this must fix your issue. … Read more

Calling a WordPress Custom JavaScript file

You’re using the function wp_enqueue_scripts() where you should be using wp_enqueue_script(). function my_custom_javascript(){ // Creates the function wp_enqueue_script( ‘my_custom_javascript’, plugin_dir_url(__FILE__) . ‘/assets/js/custom.js’, array(‘jquery’) ); // Loads the script into the function } add_action(‘wp_enqueue_scripts’, ‘my_custom_javascript’); // calls the function where the script is located wp_enqueue_script() enqueues the script; wp_enqueue_scripts() is a wrapper for do_action( ‘wp_enqueue_scripts’ ).

This page can’t load Google Maps correctly [closed]

Welcome to the new world of Google Maps 🙁 You now have to have your credit card linked to your Google Maps API. They give you $250 a month of “credit” so you will likely not get charged, but you do have to have the card linked. https://venturebeat.com/2018/05/02/google-maps-platform-arrives-with-pay-as-you-go-billing-free-support-and-cloud-requirement-starting-june-11/