Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied

I had the same problem. You need to reclassify the mediaelement style and script, like it is explained in this post. So just call this funtion, after your ajax call: function enqueue_mediaelement(){ wp_enqueue_style( ‘wp-mediaelement’ ); wp_enqueue_script( ‘wp-mediaelement’ ); } add_action( ‘wp_enqueue_scripts’, ‘my_enqueue_scripts’ ); If you wanna add your own styles for specific pages (in the … Read more

Ajax not firing properly using Firefox, but works in Chrome

This is the barebones for an AJAX call and response. Take a look and make sure this is working on Chrome and Firefox for you — works for me. <?php // Some function for data we’ll pass function dgx_donate_get_countries_requiring_postal_code() { return “cc postal code stuff…”; } // Register everything add_action(‘init’, function () { // Add … Read more

Passing PHP Variables to JS using Localize Script

Your code should be in an action callback function: function wpse186202_enqueue_scripts(){ wp_enqueue_script( ‘stats’, get_stylesheet_directory_uri() .’/js/t5-demo.js’ , array( ‘jquery’ ), ‘1.0.0’, true ); $categories = implode( ‘, ‘, wp_list_pluck( get_the_category( get_the_ID() ), ‘name’ ) ); $datatoBePassed = array( ‘author’ => get_queried_object()->post_author, ‘category’ => $categories, ‘title’ => single_post_title( ”, false ) ); wp_localize_script( ‘stats’, ‘php_vars’, $datatoBePassed ); … Read more

How to pre-fill Google Forms URLs with logged-in WordPress user’s data

AS easy as you said: $user = wp_get_current_user(); if(!empty($user)) { $email = $user->user_email; $fname = $user->user_firstname; $sname = $user->user_lastname; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=’.$fname.’&entry.165661554=’.$sname; echo $url; } else { $email=”[email protected]”; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=First&entry.165661554=Last’; echo $url; } If the user is logged in (if !empty ($user) ) then it grabs the data from the user variable wp_get_current_user, we could also wrap in … Read more

Changing the entire control choices using wp.customize with JavaScript

You’re close. You just need to replace changeTheChoices() with set() as this is a method on wp.customize.Setting. See the following which also refactors a bit: wp.customize( ‘setting_category’, ‘setting_font’, function( categorySetting, fontSetting ) { categorySetting.bind( function( category ) { var newChoices = {}; // get new data from JSON using ‘category’ and populate the ‘newChoices’ fontSetting.set( … Read more