Why is this Ajax not working?

When you load a php file directly via an ajax request (UncheckPackageThemeHelper.php) it’s loaded outside the context of WordPress, so no WordPress core functions are available. All WordPress ajax requests should be routed through admin-ajax.php. You can print the URL with the function admin_url: admin_url( ‘admin-ajax.php’ ) When admin-ajax.php is loaded, WordPress is bootstrapped, so … Read more

Accept AJAX call with serialized form data

When working with AJAX and Forms in WordPress I like to code in the ajax action to the form so serialize works out of the box. Actually I wrote an article on this last year: https://webdevstudios.com/2015/02/12/handling-ajax-in-wordpress/ But, you’re here for answers, not a blog article, so here’s the brief part of it. You have three … Read more

Need To Deregister Scripts Via Functions.Php

Ok the following does work now, I think it was a caching issue and I forgot to add the correct priorities Using the priorities now it definitely works and I also managed to de-register Buddypress scripts add_action( ‘wp_print_scripts’, ‘de_script’, 100 ); function de_script() { wp_dequeue_script( ‘jquery’ ); wp_deregister_script( ‘jquery’ ); wp_dequeue_script( ‘bp-legacy-js’ ); wp_deregister_script( ‘bp-legacy-js’ … Read more

HTML5 Youtube wrapper works in jsfiddle but not in WP?

If you are talking about this, I can see it’s working. However, taking a look at the source code, I found you have two instances of jQuery. You might want to remove the first one found just below the opening <html> tag. It’s not only the improper way to enqueue jQuery, but may also conflict … Read more

Loading jQuery and jQuery plugin script files correctly [duplicate]

Add the jquery script as a dependency for your jquery-ticker.js and site.js files within the wp_enqueue_script function. Example: function bbc_frontend_script() { wp_enqueue_script(‘ticker’, plugins_url(“/js/jquery-ticker.js”, __FILE__), array( ‘jquery’ ) ); wp_enqueue_script(‘sitejs’, plugins_url(“/js/site.js”, __FILE__), array( ‘jquery’, ‘ticker’ ) ); } add_action( ‘wp_enqueue_scripts’, ‘bbc_frontend_script’ ); You also don’t have to enqueue jquery separately if you define it as a … Read more

Load jQuery inside Page Template

You should use the wp_enqueue_script() function to first enqueue your script and then wp_enqueue_scripts action hook to properly add your script to your footer or header of your theme. Also, you should take a look at conditional tags and how they are used to load functions/scripts/styles/etc on a conditional basis. So you would do something … Read more

Woocommerce checkout field maxlength, make input number field only (postcode)

By the time woocommerce_checkout_fields filter is run, the arrays for billing and shipping have already been created. You can see that here: https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101 If you want to effect the default fields, use this hook. function wpse215677_checkout_fields ( $fields ) { $fields[‘postcode’][‘maxlength’] = 4; return $fields; } add_filter(‘woocommerce_default_address_fields’, ‘wpse215677_checkout_fields’); If you want to adjust just the … Read more