How to listen to color changes on the color picker?

I hate answering my own question, but hopefully this can help someone else with similar issues: WordPress uses Iris color picker. http://automattic.github.io/Iris/# WordPress also creates a jquery widget with default settings for Iris. The file can be found under wp-admin/js/color-picker.js At first I was trying to pass values directly to iris(), which works, but that … Read more

Apply jquery script to only woocommerce product pages and categories

There are two ways you could do that. 1. Using JS only WordPress themes normally use the body_class() function. As a result you’ll see that the <body> tag will have lots of classes. You can then target pages with a specific class to run your code in JavaScript: if( $(‘body.whateverclass’).length || $(‘body.anotherclass’).length ){ // Your … Read more

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

Is it possible to get a theme customizer setting from wp.customize using jquery?

Not sure what you try to accomplish, but you can get a value by key using the wp.customize object: wp.customize.value(‘show_on_front’)(); wp.customize.value(‘blogname’)(); …. sorry no jQuery here, just javascript, and yes, the extra () are intentional. Edit: Full overview of all settings: wp.customize._value; console.log(wp.customize._value); Edit II: different approach: a) lookup all available settings by using console.log(wp.customize._value); … Read more

jQuery UI in Admin (Best Practice?)

WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait. Also, it sounds like you’re outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own. This is done using wp_deregister_script() and wp_enqueue_script().

How to alter the text of the post “Excerpt” box label in WordPress post editor?

there is a filter hook you can use and it is gettext here: add_filter( ‘gettext’, ‘wpse22764_gettext’, 10, 2 ); function wpse22764_gettext( $translation, $original ) { if ( ‘Excerpt’ == $original ) { return ‘My Excerpt label’; }else{ $pos = strpos($original, ‘Excerpts are optional hand-crafted summaries of your’); if ($pos !== false) { return ‘My Excerpt … Read more

WordPress Ajax always returns a 404 error

This was very frustrating to figure out. I spent hours on this issue and discovered your problem is in this input: <input type=”text” name=”name” id=”name” size=”30″ value=””/> Try changing the input field name to anything but “name”, for example: <input type=”text” name=”user_name” id=”name” size=”30″ value=””/>