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

Calling a WordPress Custom JavaScript file

You’re using the function wp_enqueue_scripts() where you should be using wp_enqueue_script(). function my_custom_javascript(){ // Creates the function wp_enqueue_script( ‘my_custom_javascript’, plugin_dir_url(__FILE__) . ‘/assets/js/custom.js’, array(‘jquery’) ); // Loads the script into the function } add_action(‘wp_enqueue_scripts’, ‘my_custom_javascript’); // calls the function where the script is located wp_enqueue_script() enqueues the script; wp_enqueue_scripts() is a wrapper for do_action( ‘wp_enqueue_scripts’ ).

Using wp_localize_script to get data from cpt and pass it to maplace-js locations

You don’t need to use json_encode() when using wp_localize_script(). The last argument of wp_localize_script() should be a PHP array. This will be converted to JSON for you. So to resolve the issue, remove this line: $location_json = json_encode($location_array); And change wp_localize_script() to use $location_array: wp_localize_script(‘sage/main.js’, ‘locationJSON’, $location_array); Because $location_array had been double-encoded the locationJSON variable … Read more

JavaScript in a PHP plugin

So the question and answer you linked to is still valid, the only part that changes is the AJAX part. Specifically, there are now 2 options: Admin AJAX API: A legacy API, most tutorials will use this, but it’s much harder to secure, and provides little to no help. If it isn’t implemented right you … Read more

Add JS in footer via shortcode?

I’ll address your address and thruthfully you should probably be enqueuing this, and consider using wp_add_inline_script() or wp_localize_script(). However, if you can’t be bothered to do that for some reason, you can just remove the return of your shortcode, and instead use add_action(‘wp_footer’, ‘…’);. This is actually similar to how I enqueue registered scripts/styles only … Read more

This page can’t load Google Maps correctly [closed]

Welcome to the new world of Google Maps 🙁 You now have to have your credit card linked to your Google Maps API. They give you $250 a month of “credit” so you will likely not get charged, but you do have to have the card linked. https://venturebeat.com/2018/05/02/google-maps-platform-arrives-with-pay-as-you-go-billing-free-support-and-cloud-requirement-starting-june-11/

Implementing Webflow JS in WordPress

Got it working. I had to add a couple more data attributes in the HTML markup to match those in the Webflow export. Then replace both the instances of window.$ with window.jQuery in webflow.js. An alternative to this to add var $ = jQuery at the beginning of that file. Now need to figure out … Read more