Drag and drop multiple file upload using Ajax WordPress
Drag and drop multiple file upload using Ajax WordPress
Drag and drop multiple file upload using Ajax WordPress
I found it First, I want to note that the approach I mentionned in my question is bad according to almost tutorials talking about AJAX in wordpress. So I decided to change the approach and use the built-in AJAX of WordPress. In other words, the best way for my situation is to use the wp-admin/admin-ajax.php. … Read more
Yes! Yes you can! You can use this code to retrieve a stored option: $value = get_post_meta($post->ID,’customfieldname’,true); // where true means only return 1 custom field by this name You can use this code to save a stored option: update_post_meta($post->ID,’customfieldname’,$valuetobestored); The above code will need to be inside the post loop, though you can supply … Read more
I have no words 🤦♂️ A simple change dirname(plugin_basename(__FILE__)) . ‘/languages/’ inside wp_set_script_translations() function (3rd argument) to plugin_dir_path(__FILE__) . ‘languages/’ fixed the problem
To answer your broader question about resources – while there are many articles out there, I would always recommend checking out the official WordPress API Handbook first. You first have to decide which JavaScript library you want to use to make HTTP requests to access the REST API. Axios is one example. To set the … Read more
So… through some trial and error, I discovered that I’d gotten some of the logic wrong in order to detect and ensure the result of the API call (and subsequent state change) was treated properly. I suspect that “other” state changes were firing and I was unsubscribing before I needed to – hence the unsubscribe … Read more
You can use WordPress built in functionality Function Reference/is page and attach a if statement in your script_enqueue() function in your functions.php file. Read more in the Codex: https://codex.wordpress.org/Function_Reference/is_page Here’s an example from a theme I’m building: if (is_page( array(‘mortgage-calculator’, ‘contact’ ) )){ wp_enqueue_script(‘angularjs’, get_template_directory_uri().’/js/angular.min.js’, array(), ‘1.4.1’, true); wp_enqueue_script(‘d3′, get_template_directory_uri().’/js/d3.min.js’, array(), ’10/22/2015′, true); wp_enqueue_script(‘c3-js’, get_template_directory_uri().’/js/c3.min.js’, … Read more
The problem was in the .htaccess file the installation script generated. Specificaly, those two lines: RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) home/itaymoav/dev/lmspages/$2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ home/itaymoav/dev/lmspages/$2 [L] The path in there is the actual path to the files. While it had to be the relative path from root dir of the worpress installation. Or, to put it simply: RewriteRule … Read more
As the names themselves seem to state, one of those hooks to the customize-controls, the other to the customize-preview. They are not the same and you could in fact use them both, for different purposes. If you’re hooking in JS code to affect the controls in the customizer, then you would want to use customize_controls_enqueue_scripts. … Read more
I also found that Cloudflare Rocket Loader would cause javascript errors in this situation. When the .js file was marked to be ignored, but the inline js was unable to be so marked, undefined errors would occur when the script tried to access the async-loaded inline data. The approach detailed in How to intercept already … Read more