WP Customizer compare and set a value via javascript

You’re binding changes to themeb_scheme via an anonymous callback function with the parameter value as the new setting of themeb_scheme. This should work: wp.customize( ‘themeb_scheme’, ‘themeb_footerbg’, function( themeb_scheme, themeb_footerbg ) { themeb_scheme.bind( function( value ) { if( value == ‘light’){ themeb_footerbg.set( ‘#eaeaea’ ); } else if( value == ‘dark’){ themeb_footerbg.set( ‘#323232’ ); } else { … Read more

Changing parent element’s class or style

So, the elements should be changed into <div class=”icheckbox disabled hide_empty” style=””> that’s different from the goal stated in the question where you say you want to add class “hide_empty” to the parent <li> of the <div class=”icheckbox”>. The code posted by @dhirenpatel22 should work to add class hide_empty to the li element, of course … Read more

I’m trying to set the cookie to my site to button on click action ,it is working on when user logged in .When user logged out it’s not working

Your script uses jQuery so you should make sure that: jQuery is enqueued on your site (it may be for logged-in users, especially admins, but not necessarily for logged-out users) your script is added with jQuery as a dependency so jQuery is available when your script runs I would use wp_add_inline_script() for this, like so: … Read more

How to include jQuery into my plugin so I can use it on plugin page?

JQuery is a part of WordPress core, so it is automatically there for you to use (i.e. you do not need to register it). However, you still need to enqueue it. This can be done as follows: function my_script() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_script’); This loads jQuery from WordPress core, the jQuery files can be … Read more

Unset session variable on page reload / setup but exclude AJAX

Try using wp_doing_ajax() like so: function unset_filter_session() { if ( ! wp_doing_ajax() ) { //Reset sessions on refresh page unset( $_SESSION[‘expenditure_filter’] ); } } UPDATE You can check the answer’s revision for this update part.. UPDATE #2 Sorry, I didn’t realize that you’re loading a page fragment (#content-area) using the jQuery.load() method. Or that you’re … Read more

WordPress error when replacing local jQuery by externally-hosted

The error message describes your problem quite clearly: Notice: wp_deregister_script was called incorrectly. Do not deregister the jquery script in the administration area. To target the front-end theme, use the wp_enqueue_scripts hook. You’re de-registering the script on the init hook: add_action(‘init’, ‘replace_jquery’); This hook runs for the back and front end, but the debugger isn’t … Read more

How register library to use jquery correct

You should use the built-in version of jQuery for compatibility reasons. All you need to do is to enqueue it: function theme_scripts() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘theme_scripts’); Or just add it as a dependency for your script: function theme_scripts() { wp_enqueue_script( ‘my-script’, <PATH>, array(‘jquery’), … ); } add_action(‘wp_enqueue_scripts’, ‘theme_scripts’); But then… you have to remember, … Read more