Tag Info

Hot answers tagged

2

Replacing the WordPress version of jQuery is generally a bad idea. Checkout Pippin's article Why Loading Your Own jQuery is Irresponsible for more information. Instead of completely replacing jQuery, you could instead move the supplied version to the footer. However you need to be mindful that this will most likely break plugins if they load scripts in the ...


1

Here's a working example: add_action( 'wp_enqueue_scripts', 'menu_scripts' ); function menu_scripts() { wp_enqueue_script( 'responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ...


1

I haven't tested this, but this should work and don't forget to replace the jQuery selector with your own: $(function() { if(typeof jQuery.datepicker === 'function'){ $( ".your_date_picker_field_selector" ).datepicker({ beforeShowDay: function (t) { var e = t.getDay(); return [e == 3, ""] } }); } }); ...


1

Your code is wrong. You are confusing wp_enqeue_script function and wp_enqueue_scripts action. It should be: function theme_script(){ wp_deregister_script( 'jquery' ); wp_register_script('jquery',get_template_directory_uri().'/sliderengine/jquery.js'); wp_enqueue_script('jquery'); ...


1

If you are going to add a inline script that depends on jQuery, the best and correct way is to use wp_enqeue_scripts action hook, or wp_footer, depends on the situation, combined with wp_script_is() function: add_action( 'wp_footer', 'cyb_print_inline_script' ); function cyb_print_inline_script() { //Check that jQuery has been printed if ( wp_script_is( ...


1

How this line (9th) is created within your theme code? <script type="text/javascript" src="/wp-content/themes/blankslate/js/jquery-1.11.1.min.js"></script> If it is hard-coded in header.php, then I would recommend to remove it. Scripts should be enqueued instead of hard-coding them. Next, you can de-register jquery.migrate script with the ...


1

What would you do if the user uses a proxy and randomizes his IP address? There are numerous browser plugins to simplify that to a click of a button to download multiple times. The same goes for cookies. Aside from that you are trying to collect data that allows to identify users, which is illegal in lots of countries. What (could) work much better is a ...


1

First of all, some recommended reading - AJAX in Plugins. I realise this is not a plugin, but the Codex is still relevant, and as you'll see in the PHP section, you can use the WP AJAX handler to handle front end calls as well as those from the admin area. Javascript For this, you would be better advised putting your JS in an external *.js file that is ...


1

Your AJAX callback method should be outputting something followed by a die() statement. function wp_insert() { ..your code echo $whatever_your_results_are; // die(); } I would also recommend against prefixing your custom methods with wp_. That should be reserved for WordPress and will cause confusion to other developers - and probably you ...


1

the following may work function wpdocs_dequeue_script() { wp_dequeue_script( 'jquery' ); } add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );



Only top voted, non community-wiki answers of a minimum length are eligible