Fire jQuery function when post edit screen loads

You have your jQuery hooked too early. The jQuery library has not yet loaded when the load-(page) action is fired. Use admin_print_scripts to print inline scripts. That action comes after scripts are enqueued. Here’s your original code using admin_print_scripts: add_action( ‘admin_print_scripts’, function () { $status = “status-started”; if($status == ‘status-started’): ?> <script> jQuery(document).ready(function($) { /* … Read more

Why do we include jQuery in the header?

Get rid of the plugin/theme that’s causing jQuery to load 🙂 jQuery is shipped with WordPress doesn’t mean that it’s loaded every time by default, it’s being loaded by a theme or plugin that you’re using. Look for a call to wp_enqueue_script 🙂 Good luck!

Deregister WordPress jquery on specific page

Hook to wp_enqueue_scripts. It will do the trick. Modified code is- if (!function_exists(‘modify_jquery’)) { function modify_jquery() { if (is_page(array(‘page 1’, ‘page 2’))) { wp_dequeue_script(‘jquery’); wp_deregister_script(‘jquery’); wp_register_script(‘jquery-custom’, ‘//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js’, false, ‘1.11.3’, ‘true’); wp_enqueue_script(‘jquery-custom’); } } } // add_action(‘init’, ‘modify_jquery’); add_action(‘wp_enqueue_scripts’, ‘modify_jquery’); Hope this is gonna help.

WordPress 5.2.1 deactivated my jQuery

5.2.1 includes a backported fix from jQuery 3.4.0 (commit). Because they’re now using a modified version of jQuery they suffixed the version number with ‘-wp’: $scripts->add( ‘jquery’, false, array( ‘jquery-core’, ‘jquery-migrate’ ), ‘1.12.4-wp’ ); Your code tries to copy the jQuery version number from the existing registration global $wp_scripts; if (isset($wp_scripts->registered[‘jquery’]->ver)) { $ver = $wp_scripts->registered[‘jquery’]->ver; … Read more

Click link on plugin/theme page and open the contextual help on a specific tab

Maybe the Q is bordering the off-topic, but IMO interesting in WordPress context. I’ve tested this directly in FireBug, in the Dashboard page (wp-admin/index.php). var $ =jQuery.noConflict(); // Remove ‘active’ class from all link tabs $(‘li[id^=”tab-link-“]’).each(function(){ $(this).removeClass(‘active’); }); // Hide all panels $(‘div[id^=”tab-panel-“]’).each(function(){ $(this).css(‘display’,’none’); }); // Set our desired link/panel $(‘#tab-link-help-content’).addClass(‘active’); $(‘#tab-panel-help-content’).css(‘display’,’block’); // Force click … Read more

WordPress: Sortable Metabox Fields Not Saving Position

Normally it should be enough to simply enqueue the postsbox script on a page where you want to have sortable meta boxes. Simply do the following: add_action( ‘admin_enqueue_scripts’, ‘wpse112022_postbox_enqueue’ ); function wpse112022_postbox_enqueue( $hook_suffix ) { // uncomment the next line to see what the $hook_suffix of your desired page is # var_dump( $hook_suffix ); if … Read more

jQuery and AJAX Not working with Select Form Element

instead of this: jQuery(‘#wpuf_new_post_form’).submit(function(e) { Try this way, it should work for you. jQuery(document).on(“submit”, “#wpuf_new_post_form” , (function(e)) { var data2 = jQuery(‘#wpuf_new_post_form’).serialize(); first do console.log(data2) try it, should print entire form ‘s data in console.

Add `datetimepicker` to form

You can try this. add_action( ‘wp_enqueue_scripts’, ‘wpcustom_enqueue_script’ ); function wpcustom_enqueue_script() { wp_enqueue_style( ‘datepicker-style’, ‘https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css’ ); wp_enqueue_script( ‘js-datepicker’, ‘https://code.jquery.com/ui/1.12.1/jquery-ui.js’, array(‘jquery’), null, true); } Readmore: http://jqueryui.com/datepicker/