Adding scripts for uploading files

In Chapter 4, Building Custom Modules with Plugin Development, we created a plugin to upload attachments to posts. However, we had to select a file and upload files one by one while updating the post for each file. This is not ideal in situations where we have many files to be uploaded. Instead, we have to use AJAX and let the user upload multiple files without refreshing the browser. Before moving into the process of uploading files, we need to add the necessary scripts to the plugin. First, you have to create a new directory inside wpquick-woo-product-files as js, and create a new file called wqwpf-admin.js. Next, we can add the script to the plugins, as shown in the following code:

add_action( 'admin_enqueue_scripts', ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.