Display admin_notice error message form jQuery event

Thanks to Douglas.Sesar for pointing me in the right direction. Much appreciated! This is what I did… First put the following id in the title heading of the plugin. I am adding the admin message html (via jQuery) directly after this heading. <h1 id=”my-admin-message”>My Plugin Title</h1> My jQuery function: function fnDisplayAdminMessage(adminMessage, adminMessageColor) { jQuery.ajax({ type: … Read more

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